Thread View: bit.listserv.script-l
1 messages
1 total messages
Started by Benjamin Chi
Wed, 02 Mar 1994 05:14
How to test a variable
Author: Benjamin Chi
Date: Wed, 02 Mar 1994 05:14
Date: Wed, 02 Mar 1994 05:14
30 lines
2039 bytes
2039 bytes
I have a situation where if variable x contains the string "XXX" I want
one thing to happen; if it contains anything else (say, "YYY ZZZ") I want
something else to happen. How do I perform this test?
The fragment
.se x = 'XXX'
.if &x = XXX;.th FOO;.el BAR
.if XXX = &x;.th FOO;.el BAR
gives FOO BAR when processed by SCRIPT; I should think it would give
FOO FOO . If I replace the first statement with
.se x = 'YYY ZZZ'
then I get the diagnostic statement
INVALID KEYWORD FOR CONDITION ON .IF.
'TRY' LINE 3: .if YYY ZZZ = XXX;.th FOO;.el BAR
(which I understand), and still FOO BAR .
Questions:
(1) Why aren't the two .if statements in either of the two examples
entirely equivalent?
(1a) Why didn't I get the same diagnostic for line 2 of the second
example?
(2) What is the syntactically correct way to test the contents of a
variable whose value may be a string with embedded spaces? (I've tried
messing around with single quotes, double quotes, both, etc., and also
RTFM, all to no effect.) Any insight gratefully accepted.
/b
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads