Dan
 
TO understand your problem here, you must understand the difference between a variable to the LEFT of an equal sign and either to the RIGHT or embedded in a command in R:Base.
 
If to the LEFT, your & syntax works correctly because R:base subsitutes the value of the variable for the &var
 
So
SET V &vword1 = partnum FROM
 
becomes
 
SET VAR vfrprts1 = partnum FROM
 
However, the SAME is true when on the right side of the equal sign, so when you later say:
 
AND partnum = &vword1
R:Base listens and correctly replaces vword1 with the TEXT vfrprts1!
 
To get what you want, yuo must do this:
 
SET VAR vCommand = +
('SET V' & .vword2 & '= frquantity FROM flatrateeassy +
WHERE frrpenum =' & '.'+'vfrrepnum and partnum =' +
'.' + .vword1)
 
&vCommand
 
The SET VAR vCommand will become:
 
SET V vfrprts1Quan = frquantity FROM flatrateeassy WHERE frrpenum = .vfrrepnum and partnum =
.vfrprts
 
I've tested this at the R> prompt and it works - you need the '.' to put the period in where you want - before the variable name!
 
David Blocker
[EMAIL PROTECTED]
781-784-1919
Fax: 781-784-1860
Cell: 339-206-0261
----- Original Message -----
Sent: Tuesday, August 03, 2004 10:42 AM
Subject: [RBASE-L] - Creating variables on the fly

Hi,
  I am hoping someone can see what I am doing wrong here:  I am creating variables on the fly in a loop. Each time through the loop the variable name is incremented (and works fine) However I am having troubles using the & variable correctly.  see notes in the code.


  set v vfrnew text   -- this was an INT that gets incremented in the loop
  SET V vword1 = "vfrprts" 
  set v vword1 = (.vword1 + .vfrnew) -- now .vword1 = "vfrprts1"
  set v vword2 = (.vword2 + .vfrnew + "Quan") -- now .vword2 = "vfrprts1Quan"
     
      SET V &vword1 = partnum FROM flatrateassy WHERE frrepnum = .vfrrepnum +
      AND .vfrprtsd not cont partnum
      -- this acurately fills the variable .vfrprts1 with the partnum so
      -- .vfrprts1 = "W402"
     
     
      SET V Vfrprtsd = .vfrprtsd +", "+ &vword1
      -- this acurately sets the variable .vfrprtsd = " , W402"
     
      SET V &vword2 = frquantity FROM flatrateassy +
      WHERE frrepnum = .vfrrepnum AND partnum = &vword1
      -- here is where the problem is...  The lookup instead of looking up
      -- the partnumber "W402" it looks for "vfrprts1"


Why in one place does it correctly use the value of &vword1 but then on the next line it uses it as though I typed .vword1

Thanks for any advice.

Dan



Dan Champion
www.championsolutions.net
616-299-7420

Reply via email to