Page 1 of 1

Loading Variable and values from file and saving file

Posted: Wed Dec 08, 2010 4:48 pm
by Frank_CMRG
How do I load a file with Variable Definitions into my project?

We have 3 systems, TEST, DEVelopment, and PRODuction. When testing new projects, they are connecting to Test / dev servers, after migrating the project to the production Machine, we would have to edit all the connections. To avoid this, I want to create a file of Variables that have the production or test connections to use based on the Go Anywhere instance being run on.

I tried the import XML file task at the start of the project, but it returned a malformed file error.
I believe it was missing a header line, so what should the header line look like?

For example:

Here is the connection variable for our TEST hp300 FTP Server:

<variable name="HP_HOST" value="" valueIsEncrypted="false" />

the same for our Production hp3000:

<variable name="HP_HOST" value="" valueIsEncrypted="false" />

Re: Loading Variable and values from file and saving file

Posted: Tue Dec 14, 2010 11:03 am
by Frank_CMRG
to clarify:
I want to load a two column file.
Column 1 is the variable Name
Column 2 is the data value for the variable named.

I can make the file any format to fit:
CSV, Excel, Flat File Fixed.

I am not getting anywhere with the following project code when loading Excel:

<project name="Load Excell" mainModule="Main" version="1.0" logLevel="verbose">

<module name="Main">

<readExcel version="2.0" inputFile="D:\GoAnywhere\userdata\documents\fgirard\HP_VARS\GO_ANYWHERE_VARIABLE_TABLE.xls" outputRowSetVariable="Xcel_vars" dataStartRowNumber="5" headingsRowNumber="1" sheetNames="TEST" numColumns="3" skipEmptyRows="true">
<data trim="both">
<column index="1" name="Var_name" type="VARCHAR" size="40" trim="both" />
<column index="3" name="Var_value" type="VARCHAR" size="40" trim="both" />

<forEachLoop itemsVariable="${Xcel_vars}" currentItemVariable="row">

<setVariable version="2.0" name="variable_name" value="${Xcel_vars:Var_name}" />

<print version="1.0">
Row Variables: ${row}
variable_name : ${variable_name}]]>



Re: Loading Variable and values from file and saving file

Posted: Tue Dec 14, 2010 6:45 pm
by Support_Duane
There are two problems here.
1. When retrieving a value from a rowset, you must reference the current row, and then in brackets reference either a column number or column name. So in the example you provided, since the "currentItemVariable" in the loop is "row", instead of:
Code: Select all
  <setVariable version="2.0" name="variable_name" value="${Xcel_vars:Var_name}" />
you should use:
Code: Select all
<setVariable version="2.0" name="variable_name" value="${row[Var_name]}" />
Code: Select all
<setVariable version="2.0" name="variable_name" value="${row[1]}" />
2. You cannot specify a variable as the left element of a set variable task. Check out the following:
Code: Select all
<setVariable version="2.0" name="${var1Name}" value="${var1Value}" />
valid :
Code: Select all
<setVariable version="2.0" name="var1Name" value="${var1Value}" />
The valid line above will assign the value of the "var1Value" variable to the "var1Name" variable.

Re: Loading Variable and values from file and saving file

Posted: Mon Dec 20, 2010 2:48 pm
by Frank_CMRG
Our E-mail is down at the moment, so did not know you posted another way to do this.
I was checking back to say that I figured out how to load the Variable declarations and values. You sent something to Jim about 'snippets' searching on that got me the information I needed to load all the variables from a file:

<module name="variables">
<variable name="HP_HOST" value="" valueIsEncrypted="false" />
<variable name="HP_USER" value="jobs.bttest" valueIsEncrypted="false" />
<variable name="HP_PW" value="y3sY4Wys16A=" valueIsEncrypted="true" />

I was not putting the variables in a <module> tag grouping, once I did this, they loaded fine. So I now have 2 ways to load the variables - I was able to get the 'call project' version working, and now this one.

I am going to look at the new example and get that working, and then I can present the 3 version to the group, and then finalize the standard we are going to use going forward between us.

thanks for you help on this.