ReadFile

Purpose With ReadFile you can read a record from a file into GuiXT variables. You can then use the values in an InputScript.
Example ReadFile “X:GuiXTFiles\MatDes.txt” s_matnr s_text s_unit s_price

A new record is read from the file. Using the delimiter given in the OpenFile command (Delimiter=, default delimiter is the tab), the record fields are separated from each other and the variables are filled with the field values.

For example, if you read the record

1000001;20;Screw;ST;0.02

then the variable values are

&[s_matnr]= 10000120 &[s_text]= Screw &[s_unit]= ST &[s_price]= 0.02

Additional options 
-StripQuotationMarks Removes the quotation marks around field values. 

Example:

ReadFile -StripQuotationMarks “X:GuiXTFiles\MatDes.txt” s_matnr s_text s_unit s_price

Format ReadFile “filename” var1 var2 var3 …

Up to 60 variables are possible (before GuiXT version 2009 Q1 2: 20 variables).
If you specify more variables than contained in the file record, then all remaining variables are cleared.

If there are no more records in the file (end of file), then all variables are cleared.

Tips
& Tricks
  • You can handle the “end of file” condition in an InputScript in the following manner (example):
    if not V[s_matnr]
       goto script_end
    endif
  • See “Special Topics” File handling in InputScripts for a detailed example.

ReadFile