Article View: bit.listserv.script-l
Article #400How to test a variable
From: 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
Technical Details
Message-ID:
<940302.001420.EST.BEC@albany.edu>Path:
arc1-ca.pugleaf.net!gmd.de!newsserver.jvnc.net!howland.reston.ans.net!vixen.cso.uiuc.edu!sdd.hp.com!saimiri.primate.wisc.edu!nntp.msstate.edu!paladin.american.edu!auvm!ALBANY.EDU!BECShow Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 11353d,2be3885144b57674,start X-Google-Attributes: gid11353d,public X-Google-ArrivalTime: 1994-03-01 21:14:20 PST Path: arc1-ca.pugleaf.net!gmd.de!newsserver.jvnc.net!howland.reston.ans.net!vixen.cso.uiuc.edu!sdd.hp.com!saimiri.primate.wisc.edu!nntp.msstate.edu!paladin.american.edu!auvm!ALBANY.EDU!BEC Comments: Gated by NETNEWS@AUVM.AMERICAN.EDU Newsgroups: bit.listserv.script-l Return-Path: <@AUVM.AMERICAN.EDU,@UGA.CC.UGA.EDU:owner-script-l@UGA.CC.UGA.EDU> Return-Path: <@UGA.CC.UGA.EDU,@UACSC2.ALBANY.EDU:BEC@UACSC2.ALBANY.EDU> X-Acknowledge-To: <BEC@albany.edu> Message-ID: <940302.001420.EST.BEC@albany.edu> Date: Wed, 2 Mar 1994 00:14:20 EST Sender: IBM vs Waterloo SCRIPT discussion group <SCRIPT-L@UGA.BITNET> From: Benjamin Chi <BEC@ALBANY.EDU> Organization: University at Albany Computing and Network Services Subject: How to test a variable Lines: 29