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
-
- TOP CONTRIBUTOR
- Posts: 628
- Joined: Mon Nov 29, 2010 8:45 pm
- Location: Alpharetta GA USA
- Contact:
Compare dynamic values with contents of textfile
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
Thank you, Dwight.
-
- TOP CONTRIBUTOR
- Posts: 628
- Joined: Mon Nov 29, 2010 8:45 pm
- Location: Alpharetta GA USA
- Contact:
Compare dynamic values with contents of textfile
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
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