Passing values to another program

Started by oradba4u, March 09, 2015, 07:35:01 PM

Previous topic - Next topic

oradba4u

All:

I have a program (Prog2.wbt) that I am successfully passing values to from Prog1.wbt
I know Prog1 is passing the correct values, as you'll soon see why.

Here is my code:

;Prog2.wbt
Var1=%param1%
Var2=%param2%
Var3=%param3%
Var4=%param4%
; -------- Var4="Hello"
Var5=%param5%
Var6=%param6%

NewVal=StrCat(Var1,"  ",Var2,"  ",Var3,"  ",Var4,"  ",Var5,"  ",Var6)
Message("Value is:",NewVal)
exit


When I run Prog1 I have a message in the program that shows me what I'm sending... No Problem there
When it runs Prog2, I get the following ERROR message:
3061: Illegal Syntax
On Line 5 of Prog2.wbt
Var4=

Then I substitue line 5 with Var4="Hello" (a hard-coded value) and all works fine...
All the values are displayed in my Message statement, and all is fine with the world.

So, the question is: What's the problem with %param4% ?

ALL the other "params" seem to be working as advertised.
Hope someone can point out the error of my ways.
As always, thanks for your HELP!

Perplexed in Peoria

JTaylor

If you show an example of what you are passing that might help.   

Also, why the percent signs around the param variables?  Those are not needed and may be your problem.

Jim

oradba4u

OK... I found the problem...

It was a misspelled variable name in Prog1

ARRRRGH!


Sometimes you just can't see the forest for the trees!


Thanks for your help

snowsnowsnow

Quote from: oradba4u on March 09, 2015, 08:57:58 PM
OK... I found the problem...

It was a misspelled variable name in Prog1

ARRRRGH!


Sometimes you just can't see the forest for the trees!


Thanks for your help

It sounds like you are saying that the variable Param4 was empty/null - hence the error in line 5.

Line 5 expands to:

Var4=

which is, of course, not valid WinBatch syntax.

But, the point is, that using % signs is almost certainly wrong, and even if you think you have it working, it is still (almost certainly) wrong.

It will seem to work if the value of, say, Param1 is "this is a test" (N.B., *with* the quotes), so that the line expands to:

Var1="this is a test"

which is syntactically valid and assigns Var1 the value: this is a test (without the quotes)

I think you can see now that it is all cleaner if you just do:

Var1=Param1