Subject: | |
From: | |
Reply To: | Stigers, Greg [And] |
Date: | Wed, 16 Aug 2000 14:07:40 -0400 |
Content-Type: | text/plain |
Parts/Attachments: |
|
|
X-no-Archive:yes
With Jeff's permission, here is his lucid answer to this wondrous question,
and a guide for the perplexed.
Greg Stigers
http://www.cgiusa.com
-----Original Message-----
From: VANCE,JEFF (HP-Cupertino,ex1) [mailto:[log in to unmask]]
Sent: Tuesday, August 15, 2000 5:31 PM
To: Stigers, Greg [And]
Subject: RE: Command file wonders
Hello Greg,
You can post this to 3000-L if you wish.
...
> Why does this happen? Why doesn't the variable x increment to 4?
>
> MPEiX:PRINT TEST
>1) parm x
>2) setvar x !x + 1
>3) echo !x
>4) setvar x !x + 1
>5) echo !x
>
> MPEiX:test 2
> 2
> 2
>
> MPEiX:showvar x
> X = 3
All parms in UDCs and command files must be referenced explicitly
via !parm_name. Variables can be referenced explicitly or implicitly
(name only -- no "!"). However implicit referencing is only permitted
in the following CI commands: CALC, ELSEIF, IF, SETVAR, WHILE and
![expression] constructs. Last, parm value cannot be changed within
the UDC/script, that is, they are like Pascal 'readonly' arguments.
Analyzing the above script:
line 1 defines a parm named X
line 2 creates a CI variable named X to the value of the parm X plus one
(3, in this example)
line 3 echo's the value of the parm X (2)
line 4 modifies the CI variable X to the value of the parm X + 1. (3)
line 5 echo's the value of the parm X (2)
The SHOWVAR X displays the value of the variable X.
The following script will create a variable of the same name as a parm
(why you would want to do this I have no idea!) and displays the value
of the parm and of the variable:
parm y=2
setvar y !y+1
echo parm=!y # see 2
echo var=![y] # see 3
calc y # see 3
calc !y # see 2
setvar y y+1
showvar y # see 4
echo !y # see 2
setvar y !y+1
showvar y # see 3
More info is on Jazz at:
http://jazz.external.hp.com/papers/SolSymposium_00/CIprogramming/index.htm
Hope this helps,
Jeff Vance, CSY
|
|
|