Set a Variable from File Content with Load from File
You can load a variable from a value in a file. This method can be helpful if you are unable to use a SQL table lookup to look up a value. The file can hold the value that is output from a batch job, a stored procedure, or any program that can save results to a file.
The file can be a constant name or a variable name. If the file is a variable name, you must create an eFORMz variable that is set to the correct value, as shown in this example. The file name is the order number, which eFORMz can get from a shipping label’s REF field. The file contains the customer number. For example, the file 263549.txt contains the customer number, 8675309.
- Save the text file to the /Minisoft/eFORMz_6 directory.
- Start eFORMz and open your project.
- Create a variable, OrderNum, to hold the value from the REF field on the shipping label. This value is the order number. You might need to add a Substring function to get only the number.
- Create a variable, FileName, to store the name of the file.
- Set the variable FileName to the value of OrderNum, and the concatenate .txt to create the file name. Right click FileName > Add Function > Set value. Click Variable, select OrderNum, and click OK.
- Next, right click FileName > Add Function > Concatenate, type .txt in the text field, and click OK.
- Create a variable, CustNum, to store the value from the file, which is the customer number.
- Right click the variable > Add Advanced Function > Load from File. Click Variable, select FileName, and click OK.
- The CustNum variable receives the value from the file.