assigning output variables
Posted: Fri Sep 18, 2015 3:08 pm
Project Designer updates:What does this do and how can we use it?
Enhanced Projects to support specifying the ${} syntax when assigning an output variable.
I would have thought it would allow me create a new variable based on the contents of another variable like this:
Code: Select all
<project name="testvar" mainModule="Main" version="2.0" logLevel="verbose">
<module name="Main">
<setVariable name="VAR1" value="VAR2" version="2.0" />
<setVariable name="${VAR1}" value="TestVal 2" version="2.0" />
<print version="1.0">
<![CDATA[Var 1 is ${VAR1}
Var 2 is ${VAR2}
]]>
</print>
</module>
</project>
</project>
But the project fails because VAR2 does not exist.
Code: Select all
So I tried something else and got a very unexpected result.INFO Start Date and Time: 9/18/15 1:36:49 PM
INFO Job Number: 1406770255948
INFO Project Name: /Chris/Test/testvar
INFO Submitted By: PGCH
INFO Submitted From: Administrator UI
INFO GoAnywhere 5.1.0 running on OS/400 V7R1M0 (ppc64)
INFO Executing project 'testvar'
INFO Project location: /linoma/goanywhere/userdata/projects/Chris/Test/testvar.xml
INFO Executing module 'Main'
INFO Executing task 'setVariable 2.0'
INFO Variable 'VAR1' was created and set to 'VAR2'.
INFO Finished task 'setVariable 2.0'
INFO Executing task 'setVariable 2.0'
INFO Variable '${VAR1}' was created and set to 'TestVal 2'.
INFO Finished task 'setVariable 2.0'
INFO Executing task 'print 1.0'
ERROR Variable not found: VAR2
INFO Finished project 'testvar'
ERROR [8099 - Print] An unexpected error occurred.
Code: Select all
Output:
<project name="testvar" mainModule="Main" version="2.0" logLevel="verbose">
<module name="Main">
<setVariable name="VAR1" value="VAR2" version="2.0" />
<setVariable name="VAR1A" value="${VAR1}" version="2.0" />
<print version="1.0">
<![CDATA[Var 1 is ${VAR1}]]>
</print>
<setVariable name="${VAR1}" value="TestVal 2" version="2.0" />
<setVariable name="VAR1B" value="${VAR1}" version="2.0" />
<print version="1.0">
<![CDATA[Var 1 is ${VAR1}]]>
</print>
<setVariable name="VAR1" value="What is in here now" version="2.0" />
<print version="1.0">
<![CDATA[Var 1 is ${VAR1}]]>
</print>
<setVariable name="${VAR1}" value="Why Would you do this" version="2.0" />
<print version="1.0">
<![CDATA[Var 1 is ${VAR1}]]>
</print>
</module>
</project>
Code: Select all
It appears that once you use this new syntax you can no longer access the value of the original variable.INFO Executing module 'Main'
INFO Executing task 'setVariable 2.0'
INFO Variable 'VAR1' was created and set to 'VAR2'.
INFO Finished task 'setVariable 2.0'
INFO Executing task 'setVariable 2.0'
INFO Variable 'VAR1A' was created and set to 'VAR2'.
INFO Finished task 'setVariable 2.0'
INFO Executing task 'print 1.0'
INFO Var 1 is VAR2
INFO Finished task 'print 1.0'
INFO Executing task 'setVariable 2.0'
INFO Variable '${VAR1}' was created and set to 'TestVal 2'.
INFO Finished task 'setVariable 2.0'
INFO Executing task 'setVariable 2.0'
INFO Variable 'VAR1B' was created and set to 'TestVal 2'.
INFO Finished task 'setVariable 2.0'
INFO Executing task 'print 1.0'
INFO Var 1 is TestVal 2
INFO Finished task 'print 1.0'
INFO Executing task 'setVariable 2.0'
WARN Variable 'VAR1' was replaced with 'What is in here now'.
INFO Finished task 'setVariable 2.0'
INFO Executing task 'print 1.0'
INFO Var 1 is What is in here now
INFO Finished task 'print 1.0'
INFO Executing task 'setVariable 2.0'
INFO Variable '${VAR1}' was created and set to 'Why Would you do this'.
INFO Finished task 'setVariable 2.0'
INFO Executing task 'print 1.0'
INFO Var 1 is Why Would you do this
INFO Finished task 'print 1.0'
INFO Finished module 'Main'
INFO Finished project 'testvar'
So what is the intended use of this enhancement?
All it appears to do is make these two statements interchangeable:
Code: Select all
<setVariable name="VAR1" value="First Value" version="2.0" />
<setVariable name="${VAR1}" value="Second Value" version="2.0" />
Is there some sort of memory allocation fix that this is supposed to deal with?
When you use the name="${VAR1}" syntax are you always creating a new variable like the job log states?
Variable '${VAR1}' was created and set to...Once the ${} variable is created, can it be accessed independently of the prior variable?
Edit 9/28/2015
Apparently the new syntax was added so that Output variables could be used with the same ${} syntax as input variables to tasks.
Prior syntax
Code: Select all
New syntax allows all the “output” variable names to be expressed using the ${} syntax.
<put label="put action" sourceFile="${FTPPUT.sourcefile}"
destinationFile="${FTPPUT.destinationfile}" type="${FTPPUT.datatype}"
destinationFilesVariable="FTP_RUN.remotefilelist"
numFilesUploadedVariable="FTPPUT.count"
processedSourceFilesVariable="FTP_RUN.localfilelist" />
Code: Select all
<put label="put action" sourceFile="${FTPPUT.sourcefile}"
destinationFile="${FTPPUT.destinationfile}" type="${FTPPUT.datatype}"
destinationFilesVariable="${FTP_RUN.remotefilelist}"
numFilesUploadedVariable="${FTPPUT.count}"
processedSourceFilesVariable="${FTP_RUN.localfilelist}" />