Page 1 of 1

Using substring function to set new variable

Posted: Thu May 15, 2014 10:35 am
by gmoisant
When I try to use substring to set a value for a variable I receive the following:

ERROR Variable not found: Substring('Images_For_Export',15,19)

Ideally, I would like to use on substring on one variable to set another varaible.

Re: Using substring function to set new variable

Posted: Thu May 15, 2014 10:59 am
by Support_Rick
Can you post the full task and how you're using the Substring Function so that I can get an idea of what it is you're trying to do?

Thanks...

Re: Using substring function to set new variable

Posted: Fri May 16, 2014 9:28 am
by gmoisant
Rick Here is the XML. My intent is to pull a claim number from the file name that is in a file list. I am using that to distribute the images received. I can do it using CL and RTVDIRINF, but thought it would be easier within GOANYWHERE. also wanted to test SUBTRING.
Code: Select all
<project name="PMSI Pharmacy Card Transfer" mainModule="Main" version="1.0" logLevel="verbose" onError="continue">
	<description>Transfer copy of Pharmacy Cards for processing</description>

	<module name="Main">

		<timestamp label="System Timestamp" version="1.0">
			<format outputVariable="Gray_timestamp" />
		</timestamp>


		<setVariable label="Email Recipients" name="Email_Recipients" value="[email protected], [email protected]" version="2.0" />


		<sftp label="PMSI Connect" resourceId="PMSI" version="1.0" disabled="false" onError="call:Transfer Error">
			<list label="PMSI Pharmacy Cards" fileListVariable="Gray_Pharmacy_Cards" numFilesFoundVariable="Gray_PC_Number">
				<fileset dir="/users/grayins/outbound" recursive="false">
					<wildcardFilter>
						<include pattern="Gray_PC_*.ZIP" caseSensitive="false" />
					</wildcardFilter>
				</fileset>
			</list>
			<cd label="Go To Pharmacy Card Directory" dir="/users/grayins/outbound" />
			<get label="Get Pharmacy Card File" sourceFilesVariable="${Gray_Pharmacy_Cards}" destinationDir="/PMSIT/Pharmacy Cards/" whenFileExists="overwrite" destinationFilesVariable="Destination_File_Name" numFilesDownloadedVariable="Destination_Files_Downloaded" processedSourceFilesVariable="Processed_File_Name" />
		</sftp>


		<createFileList label="Files to Unzip" fileListVariable="Files_To_Unzip" numFilesFoundVariable="No_Of_Files_To_Unzip" version="1.0" onError="call:Unzip Error">
			<fileset dir="/pmsit/Pharmacy Cards/" recursive="false">
				<wildcardFilter>
					<include pattern="Gray_PC_*.Zip" caseSensitive="false" />
				</wildcardFilter>
			</fileset>
		</createFileList>

		<forEachLoop label="Unzip Retrieved Files" itemsVariable="${Files_To_Unzip}" currentItemVariable="Destination_File_Current">

			<unzip label="Unzip Data and Image Zip File" inputFilesVariable="${Destination_File_Current}" outputDir="/PMSIT/Pharmacy Cards/Work Images" whenFileExists="overwrite" outputFilesVariable="File_Created" processedInputFilesVariable="Processed_File" numFilesExtractedVariable="Number_Of_Files" version="1.0" executeOnlyIf="${No_Of_Files_To_Unzip} gt 0" onError="call:Unzip Data Error" />


			<createFileList label="PMSI Pharmacy Card Images Found" fileListVariable="Image_Found_List" numFilesFoundVariable="Image_Found_Count" version="1.0" executeOnlyIf="${No_Of_Files_To_Unzip} gt 0">
				<fileset dir="/PMSIT/Pharmacy Cards/Work Images" recursive="true">
					<wildcardFilter>
						<include pattern="*.pdf" caseSensitive="false" />
					</wildcardFilter>
				</fileset>
			</createFileList>


			<move label="Move Zip Files To Archive" sourceFilesVariable="${Destination_File_Current}" destDir="/PMSIT/Pharmacy Cards/Archive" whenFileExists="overwrite" version="1.0" executeOnlyIf="${No_Of_Files_To_Unzip} gt 0" disabled="true" />


			<createFileList label="PMSI Text Index File List" fileListVariable="Text_Found_List" version="1.0" disabled="true">
				<fileset dir="/PMSIT/Pharmacy Cards/Work Images" recursive="false">
					<wildcardFilter>
						<include pattern="*.txt" caseSensitive="false" />
					</wildcardFilter>
				</fileset>
			</createFileList>


			<exec400 label="Export Images to Imageright" resourceId="Gray_Metairie_System_i" version="1.0" disabled="true">
				<command>
					<![CDATA[call graypgms/pmsebilixc parm('${Text_Found_List}')]]>
				</command>
			</exec400>

		</forEachLoop>

		<setVariable label="Test" name="Test_Variable" value="${Substring(&apos;text&apos;, 3)} " version="2.0" />


		<sendEmail label="Pharmacy Card Retrieval Successful Email" resourceId="Gray Mail Server" toList="${Email_Recipients}" version="2.0">
			<from address="[email protected]" name="PMSI Pharmacy Card Successful Transfer" />
			<subject>
				<![CDATA[${system.project.name}]]>
			</subject>
			<message>
				<![CDATA[The following files were successfully retrieved:


${Test_Variable}

${Files_To_Unzip}]]>
			</message>
		</sendEmail>

		<forEachLoop itemsVariable="${Gray_EBill}" currentItemVariable="Gray_EBill_Current" disabled="true">

			<sftp label="Delete Zip Files Retrieved" resourceId="PMSI" version="1.0" disabled="false" onError="continue">
				<delete label="Delete Files Retrieved" inputFilesVariable="${Gray_EBill_Current}" />
			</sftp>

		</forEachLoop>
	</module>


	<module name="Unzip Data Error" description="Error unzipping EOR data from Stratacare ">

		<sendEmail label="Unzip Data Error" resourceId="Gray Mail Server" toList="${Email_Recipients}" version="2.0">
			<from address="[email protected]" name="PMSI EBill Unzip Error" />
			<subject>
				<![CDATA[EBill Data Unzip Error ${system.project.name}]]>
			</subject>
			<message>
				<![CDATA[An attempt  to unzip the following file caused an error.




${Destination_File_Current}]]>
			</message>
			<attachment file="${system.job.log}" />
		</sendEmail>

	</module>


	<module name="Update Error" description="Send email when error occurs updating files">

		<sendEmail label="Update Error" resourceId="Gray Mail Server" toList="${Email_Recipients}" version="2.0">
			<from address="[email protected]" name="PMSI EBill Update Error" />
			<subject>
				<![CDATA[${system.project.name}]]>
			</subject>
			<message>
				<![CDATA[${system.project.name} ended in error during the update process.


]]>
			</message>
			<attachment file="${system.job.log}" />
		</sendEmail>

	</module>


	<module name="Data Move Error" description="Error occurred moving data to Archive directory">

		<sendEmail label="Data Move Error" resourceId="Gray Mail Server" toList="${Email_Recipients}" version="2.0">
			<from address="[email protected]" name="PMSI EBill Move Error" />
			<subject>
				<![CDATA[${system.project.name}]]>
			</subject>
			<message>
				<![CDATA[An error occurred when attempting to archive the following EOR zip file:

${Destination_File_Current}

]]>
			</message>
			<attachment file="${system.job.log}" />
		</sendEmail>

	</module>


	<module name="Transfer Error" description="Send email when transfer error.">

		<sendEmail label="Error retrieve files" resourceId="Gray Mail Server" toList="${Email_Recipients}" version="2.0">
			<from address="[email protected]" name="PMSI EBill File Retrieval Error" />
			<subject>
				<![CDATA[${system.project.name}]]>
			</subject>
			<message>
				<![CDATA[An error occurred when attempting to retrieve EBILL information from PMSI.

This was a connection error.

See attached log.


]]>
			</message>
			<attachment file="${system.job.log}" />
		</sendEmail>

	</module>

</project>

Re: Using substring function to set new variable

Posted: Fri May 16, 2014 9:55 am
by Support_Rick
To utilize the SubString (and all the updated functions) you will need to upgrade your project from version 1.0 to 2.0.

This can be accomplished by editing your project and clicking on the "Upgrade Project" in the menu. This will give you access to the newer System Variables/System Functions .. (including the Substring)

Try this and see if it doesn't help correct the issues.

If you still have more questions, please let us know!

Re: Using substring function to set new variable

Posted: Fri May 16, 2014 2:49 pm
by gmoisant
Rick,

That worked for a literal. Still having issues coding a variable as the text of the substring:

${Substring('(${Image_Found_List})'}



Image_Found_List is part of a fileset.

Re: Using substring function to set new variable

Posted: Fri May 16, 2014 3:18 pm
by Support_Rick
On Page 146 of the GAD 4.5 User Guide, there is a section on Expressions. This is how the variables and functions that are associated to version 2.0 of the project are used. Please review that section for further information...

Since you are familiar with Version 1.0 variables, this will give you a heads-up on how to use them under Version 2.0.

In a nutshell, you only need one set of ${ ... } to process variable expressions. In the case of what you're trying to do, you would perform the Substring like this:

Setvariable "MyVariable" = "ThisIsMyValue"

${ Substring( MyVariable, 5, 4 ) }

would return "IsMy"

Or, for concatenation, like this:

${ Concat( Substring( MyVariable, 5, 4 ), '.', CurrentDate( 'yyyyMMdd' ), '.txt' ) }

would return "IsMy.20140516.txt"


Hope this helps!

Re: Using substring function to set new variable

Posted: Tue May 20, 2014 11:15 am
by gmoisant
Thanks , Rick. Looks like this took care of all my problems.