Need help: script for local variable

I have a one page text file.
If the word GST is found anywhere on a line, I want this line to be local variable %1
If the word PST is found anywhere on a line, I want this line to be local variable %2

ex:

                                                                                   GST                        8.83$
                                                                                   PST                       17.62$

Hi @nabel1510,

A option is use the following JavaScript code in a Run Script Workflow plugin:

var fso = new ActiveXObject("Scripting.FileSystemObject");
var inputFile = fso.OpenTextFile(Watch.GetJobFilename(), 1, true);

while (!inputFile.atEndOfStream) {
	var textLine = inputFile.ReadLine();

	if (textLine.indexOf("GST") >= 0) {
		Watch.SetJobInfo(1, textLine);
	}
	if (textLine.indexOf("PST") >= 0) {
		Watch.SetJobInfo(2, textLine);
	}
}

inputFile.Close();

Source: ‘Watch.SetJobInfo() - PReS Workflow 2022.1 User Guide (link)’

thks Marten, I will try it

1 Like

Please keep in mind that – by using the above shared JavaScript code – if the job file contains multiple lines which contains the string “GST” or “PST” that the latest line will be assigned to the Job Info Variable.