assigning output variables

Post any question you may have in regards to GoAnywhere MFT and let our talented support staff and other users assist you.
If you need a quicker response, please create a support ticket via the customer portal my.goanywhere.com or contact our support team by email at [email protected].
2 posts Page 1 of 1

ChrisHiebert

Posts: 8
Joined: Tue Mar 05, 2013 2:47 pm

Post by ChrisHiebert » Fri Sep 18, 2015 3:08 pm
Project Designer updates:
Enhanced Projects to support specifying the ${} syntax when assigning an output variable.
What does this do and how can we use it?


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
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. 
So I tried something else and got a very unexpected result.

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="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>
Output:
Code: Select all
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'
It appears that once you use this new syntax you can no longer access the value of the original variable.

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
        <put label="put action" sourceFile="${FTPPUT.sourcefile}"
            destinationFile="${FTPPUT.destinationfile}" type="${FTPPUT.datatype}"
            destinationFilesVariable="FTP_RUN.remotefilelist"
            numFilesUploadedVariable="FTPPUT.count"
            processedSourceFilesVariable="FTP_RUN.localfilelist" />
New syntax allows all the “output” variable names to be expressed using the ${} syntax.
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}" />

Support_Rick

Support Specialist
Posts: 590
Joined: Tue Jul 17, 2012 2:12 pm
Location: Phoenix, AZ

Post by Support_Rick » Wed Sep 30, 2015 1:05 pm
Chris,

This enhancement was more of a Syntax correction in allowing you to identify a variable at creation with the same Syntax as when used.

So,

SetVariable ${FileName} = 'MyFile.txt'

is the same as

SetVariable FileName = 'MyFile.txt'
Rick Elliott
Lead Solutions Consultant
(402) 944.4242
(800) 949-4696
2 posts Page 1 of 1