Steve,
The folowing is from TechDocs 738.htm ans should explain about
%variables. I also use the following command after I have set
each % var to another correctly typed variable.
"CLEAR VAR __-_"
Percent Variables
A percent variable is created when a value is passed to a
command file
from the R> prompt or another command file. Percent variables
are
created and named by R:BASE. A percent variable is named
%n, where n
is a number from 1 to 9. You can pass up to nine parameters.
The first
parameter passed is named %1, the second %2 and so on. Percent
variables are commonly used with library routines, a single
routine
that is used by many different application.
Percent variables are commonly referenced as just %n, but
the actual
name is %n-m, where m is the run level, for example %1-0.
>From the R>
prompt, m is 0, from the first level, m is 1 and so on. Referring
to a
percent variable as %1 only, automatically refers to the
first
parameter passed to that particular command file. If you
are passing
parameters at multiple levels, refer to the variable explicitly,
e.g.
%1-2. You may have variables, %1-0, %1-2 and %1-3, there
is no %1-1
variable if no USING parameter was used at run level 1.
Look at this example with multiple levels of passing parameters.
R>RUN test.cmd USING 'one', 'two'
SHOW VAR
Variable = Value
Type
------------------ ------------------------------
--------
#DATE = 07/22/93
DATE
#TIME = 10:29:27
TIME
#PI = 3.14159265358979
DOUBLE
SQLCODE = 0
INTEGER
%1-0 = one
TEXT
%2-0 = two
TEXT
-- two parameters were passed, they are names %1-0 and %1-2
-- from within this file, RUN another file and pass parameters
RUN test1.cmd USING 'three','four'
-- run level 1, the first nested RUN
SET VAR vlevel1 = .%1
SHOW VAR
Variable = Value
Type
------------------ ------------------------------
--------
#DATE = 07/22/93
DATE
#TIME = 10:29:28
TIME
#PI = 3.14159265358979
DOUBLE
SQLCODE = 0
INTEGER
%1-0 = one
TEXT
%2-0 = two
TEXT
%1-1 = three
TEXT
%2-1 = four
TEXT
vlevel1 = three
TEXT
-- the parameters passed to file test1 are named with a "-1"
-- indicating
-- the run level. Notice that setting a variable to just
%1
-- sets it to the first parameter passed at this run level.
-- From within this file, RUN another file, but don't pass
parameters.
RUN test2.cmd
-- run level 2, the second nested RUN
SET VAR vlevel2_1 =.%1
SET VAR vlevel2_2 = .%1-1
SHOW VAR
Variable = Value
Type
------------------ ------------------------------
--------
#DATE = 07/22/93
DATE
#TIME = 10:29:30
TIME
#PI = 3.14159265358979
DOUBLE
SQLCODE = 0
INTEGER
%1-0 = one
TEXT
%2-0 = two
TEXT
%1-1 = three
TEXT
%2-1 = four
TEXT
vlevel1 = three
TEXT
vlevel2_1 = .%1
TEXT
vlevel2_2 = three
TEXT
-- no parameters are passed at this level so there are no
percent
-- variables created. Setting a variable to just %1 finds
no value
-- because no parameter was passed at this level. The variable
takes
-- on the literal text value ".%1".
-- RUN another file and pass parameters.
RUN test3.cmd using 'five','six'
-- run level 3, the third nested RUN
SHOW VAR
Variable = Value
Type
------------------ ------------------------------
--------
#DATE = 07/22/93
DATE
#TIME = 10:29:32
TIME
#PI = 3.14159265358979
DOUBLE
SQLCODE = 0
INTEGER
%1-0 = one
TEXT
%2-0 = two
TEXT
%1-1 = three
TEXT
%2-1 = four
TEXT
vlevel1 = three
TEXT
vlevel2_1 = .%1
TEXT
vlevel2_2 = three
TEXT
%1-3 = five
TEXT
%2-3 = six
TEXT
-- Now there are percent variables named "-3", for run level
3.
-- We are actually four RUNs deep, but this is the third
nested RUN
-- command. The first run, from the R> prompt, is named "-0"
and
-- is not nested.
Parameters pass values, they do not pass data types. You
cannot
pre-type a percent variable. It is recommended to set a percent
variable to a defined variable of the appropriate datatype
in the
command file and then use that variable in subsequent commands
rather
than using the percent variable itself.
--
Jim Bentley
American Celiac Society
[EMAIL PROTECTED] - email
(973) 325-8837 voice
(973) 669-8808 Fax
---- Troy Sosamon <[EMAIL PROTECTED]> wrote:
> Steve,
>
> That is correct, otherwise if you don't change many, when you
> do cle var %1,
> you will clear all of your vars.
>
> You want to clear the % vars out so they don't pile up and cause
> other
> problems.
>
> Troy
>
> >===== Original Message From [EMAIL PROTECTED] =====
> >Troy, lemme' ask you f/confirmation. Did you use the SET MANY=~
> so that the
> >following CLE VAR %1, %2 would work properly?
> >
> >TIA,
> >Steve in Memphis
> >
> >> -----Original Message-----
> >> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]On
> >> Behalf Of Troy Sosamon
> >> Sent: Wednesday, July 17, 2002 9:41 AM
> >> To: [EMAIL PROTECTED]
> >> Subject: RE: Parameters, Value of
> >>
> >>
> >> Steve,
> >>
> >> You have the ability to pass parameters in R:base, but you
> should
> >> be sure to
> >> clean the stuff up so you don't have any weird problems.
> >>
> >> Example, I want a program that computes the area of a square,
> and
> >> I want to
> >> pass it the length of the sides and the program will write
> the
> >> result to the
> >> screen.
> >>
> >> I call it like this:
> >> run square.cmd using 3, 2
> >>
> >> square.cmd looks something like this:
> >> set var side1 real = 0
> >> set var side2 real = 0
> >>
> >> set var side1 = .%1
> >> set var side2 = .%2
> >> set many=~
> >> cle var %1, %2
> >> set many=%
> >>
> >> set var varea real
> >> set var varea = (.side1 * .side2)
> >> write 'The area of a box of', .side1, 'by', .side2, 'is',
> .varea
> >>
> >> cle var side1, side2, varea
> >> return
> >>
> >>
> >> You want to clear out your % vars as soon as you are done
> w/ them so they
> >> don't get in the way in case you call other programs passing
> parameters.
> >> Because all vars in R:base are global, it really is not necessare
> >> to use them.
> >>
> >> Troy Sosamon
> >>
> >>
> >> >===== Original Message From [EMAIL PROTECTED] =====
> >> >Could y'all gimme' a few words about parameters? I'm wondering
> >> about their
> >> >value, given that var's are global in RB, yet I see echoed
> by SHO VAR,
> >> >%1-1..N, %2-1..N, etc. Such elucidation would be appreciated.
> >> >
> >> >TIA,
> >> >Steve in Memphis
> >> >
> >> >================================================
> >> >TO SEE MESSAGE POSTING GUIDELINES:
> >> >Send a plain text email to [EMAIL PROTECTED]
> >> >In the message body, put just two words: INTRO rbase-l
> >> >================================================
> >> >TO UNSUBSCRIBE: send a plain text email to [EMAIL PROTECTED]
> >> >In the message body, put just two words: UNSUBSCRIBE rbase-l
> >> >================================================
> >> >TO SEARCH ARCHIVES:
> >> >http://www.mail-archive.com/rbase-l%40sonetmail.com/
> >>
> >> Troy Sosamon
> >> Denver Co
> >> [EMAIL PROTECTED]
> >>
> >> ================================================
> >> TO SEE MESSAGE POSTING GUIDELINES:
> >> Send a plain text email to [EMAIL PROTECTED]
> >> In the message body, put just two words: INTRO rbase-l
> >> ================================================
> >> TO UNSUBSCRIBE: send a plain text email to [EMAIL PROTECTED]
> >> In the message body, put just two words: UNSUBSCRIBE rbase-l
> >> ================================================
> >> TO SEARCH ARCHIVES:
> >> http://www.mail-archive.com/rbase-l%40sonetmail.com/
> >>
> >
> >================================================
> >TO SEE MESSAGE POSTING GUIDELINES:
> >Send a plain text email to [EMAIL PROTECTED]
> >In the message body, put just two words: INTRO rbase-l
> >================================================
> >TO UNSUBSCRIBE: send a plain text email to [EMAIL PROTECTED]
> >In the message body, put just two words: UNSUBSCRIBE rbase-l
> >================================================
> >TO SEARCH ARCHIVES:
> >http://www.mail-archive.com/rbase-l%40sonetmail.com/
>
> Troy Sosamon
> Denver Co
> [EMAIL PROTECTED]
>
> ================================================
> TO SEE MESSAGE POSTING GUIDELINES:
> Send a plain text email to [EMAIL PROTECTED]
> In the message body, put just two words: INTRO rbase-l
> ================================================
> TO UNSUBSCRIBE: send a plain text email to [EMAIL PROTECTED]
> In the message body, put just two words: UNSUBSCRIBE rbase-l
> ================================================
> TO SEARCH ARCHIVES:
> http://www.mail-archive.com/rbase-l%40sonetmail.com/
>
================================================
TO SEE MESSAGE POSTING GUIDELINES:
Send a plain text email to [EMAIL PROTECTED]
In the message body, put just two words: INTRO rbase-l
================================================
TO UNSUBSCRIBE: send a plain text email to [EMAIL PROTECTED]
In the message body, put just two words: UNSUBSCRIBE rbase-l
================================================
TO SEARCH ARCHIVES:
http://www.mail-archive.com/rbase-l%40sonetmail.com/