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.
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 after ReadFile in the following manner:

    if not Q[ok]
       goto script_end
    endif
  • See also File handling in InputScripts
Components GuiXT + InputAssistant