How do I set and increment / decrement a variable

Post any question you may have in regards to GoAnywhere Director and let our talented support staff and other users assist you.

How do I set and increment / decrement a variable

Postby Frank_CMRG » Wed Dec 08, 2010 4:37 pm

once I define a variable and set it to a numeric value, how do I increment or decrement the value?

It looks like all variables are text and not numeric. When I try to add +1 to a variable, I get the equation as the variable:

${counter} = ${counter} + 1

Posts: 8
Joined: Wed Dec 08, 2010 1:49 pm

Re: How do I set and increment / decrement a variable

Postby Support_Duane » Thu Dec 09, 2010 6:38 pm

GoAnywhere Director will not currently do math using variable values.
However, you can use SQL to increment or decrement (or apply any other math function) to a variable value.

for example:
Code: Select all
      <sql label="SQL" version="1.0" resourceId="Resource Name">
         <query label="create table">
            <statement>create table qtemp.filecount (files NUM(3))</statement>
         <query label="insert count value" whenNoDataFound="continue">
            <statement>INSERT INTO qtemp.filecount(files) values(${filesFound} + 1)</statement>
         <query label="Get File_Count" outputVariable="File_Count">
            <statement>SELECT  files from qtemp.filecount</statement>

      <setVariable version="1.0" name="FileCount" value="${File_Count[1]}" />

If desired the above code could be placed in a loop and either add a drop table query or use a permanent library/schema and create the table before entering the loop and drop it when the process is complete.

The ${filesFound} variable would have to be initialized before the above code is executed.
Support Specialist
Posts: 65
Joined: Thu Mar 05, 2009 3:49 pm

Return to Community Forum

Who is online

Users browsing this forum: Yahoo [Bot] and 3 guests