Page 1 of 1

Compare dynamic values with contents of textfile

Posted: Tue Sep 04, 2012 9:58 pm
by tkittel
Hello all,



I'm trying to compare dynamic values A with the contents of a multi-line textfile. If value A matches with one of the entries (B) in the textfile, then route incoming jobs to this (folder 1); else route them to another connection (folder 2).



I tried to create the connection which reads the 'define text with variables' on the left side of the comparison window. But how to define (at the right side) to walk through all entries/lines (until end of file) in the mutli-line textfile and compare each line separately with the value read before, if it matches or not?



It it possible to realize this challenge with switch features only or is there need of javacript?



Thomas

Compare dynamic values with contents of textfile

Posted: Tue Sep 04, 2012 11:00 pm
by dkelly
You will need to write a script that opens the text file, reads each line and compares it to the value "A".

Compare dynamic values with contents of textfile

Posted: Wed Sep 05, 2012 9:41 pm
by tkittel
Thank you, Dwight.

Compare dynamic values with contents of textfile

Posted: Wed Sep 05, 2012 11:01 pm
by dkelly
Something like this:



var textToFind = "findthis";

var textFile = new File( "myfile.txt" );

if (textFile.exists) {

textFile.open(File.ReadOnly);

do {

var line = textFile.readLine();

var matchPos = line.find(textToFind);

if (matchPos >= 0) {

job.log(cLogInfo, "Found a match! ("+line+")");

break;

}

} while (!textFile.eof);

}

textFile.close();





Learn advanced Javascript for Switch

Full day seminar during Graph Expo in Chicago, Oct 8th, 2012

http://www.brownpapertickets.com/event/264833



Dwight Kelly

Apago, Inc.

dkelly@apago.com