Page 1 of 1

How to check is variable exist

Posted: Thu Feb 18, 2016 6:45 am
by JamesLSEG
How do I check if variable doesn’t/does exist on a project.

e.g. If variable exist do something else continue.

James

Re: How to check is variable exist

Posted: Thu Feb 18, 2016 9:15 am
by Support_Rick
James,

It's unusual to utilize a variable that doesn't exist. But, depending on the situation, you could trap for the existence of the variable.

For example:
Code: Select all
SetVar DNE=0
SetVar MyNewVar = ${VarThatDoesnotExist}.csv (OnError setVar DNE=1)
If DNE gt 0
   ** Correct Missing Variable issue here **
EndIF

Re: How to check is variable exist

Posted: Thu Feb 18, 2016 11:09 am
by JamesLSEG
Thanks for the information.

We are trying to make monitor project able to be rerun.

When the project is run by monitor it logs the files it is meant to get to the database and removes them once downloaded successfully. If it the project fails when you rerun the project if ${files} variable is not found it populates a rowset from database log and then runs the steps to get and and remove from db log.

The issue we have is if the monitor job fails it is hard to rerun and will never kick off again.

James

Re: How to check is variable exist

Posted: Thu Feb 25, 2016 9:29 am
by Support_Rick
James,

This would be handled pretty much the same way...

Monitor generates filelist -> MyMonFileList

Project uses MyMonFileList to process files identified when monitor executes.

Inside Project, do something like:

variable MyMonFileList = "" (as a parameter)
(Note: Any value passed in from Monitor would override this)
...
If isEmpty(MyMonFileList) -> CreateFileList (MyMonFileList) with (blah blah blah)
...
ForEach ${MyMonFileList}
(etc...)

==========
What this accomplishes is .. if the project is kicked off by the Monitor, it passes the FileList var in as needed (thus MyMonFileList would not be empty)

If you execute the project from Project access ... then, MyMonFileList is empty (Thus triggering the If statement to generate the MyMonFileList before continuing)
==========

Hopefully, this will help you along ...