How to evaluate value in a ReadLn ?

Technical support and scripting issues

Moderators: Dorian (MJT support), JRL

Post Reply
mydave
Junior Coder
Posts: 39
Joined: Fri Jul 22, 2005 12:42 pm

How to evaluate value in a ReadLn ?

Post by mydave » Tue Feb 28, 2006 3:45 am

Hi again,

I got to come up with a solution for tomorrow, and still not able to figure it out.
The task is to read all files (lot of) in a folder, and select files that meet a criteria.

Files have many lines. Lines are coma delimited. Both files and lines have different length.
Example:

xxxx,xxxx,xxxx,xxxx,xxxx,xxxx,xxxx,
F,xxxx,xxxx,YYYY,xxxx,xxxx,xxxx,xxxx,
xxxx,xxxx,xxxx,xxxx,xxxx,xxxx,
etc. . .

xxxx can be anything, letters or numbers, or both.
F, is the line that is searched for, and if YYYY is anything other than NONE, then the file name and the YYYY value needs be appended to a txt file. Alternately, the whole file can be copied to another directory.

I could think of how the script structure should be, but can't come up with a way to evaluate the line that begins with 'F,'.

GetFileList,
then ReadLine, from line 1 thru #EOF#.
If a line starts with F, then search for position 4th, if it contains other than NONE, writeLn file name and YYYY value to a text file.

Please help

Me_again
Automation Wizard
Posts: 1101
Joined: Fri Jan 07, 2005 5:55 pm
Location: Somewhere else on the planet

Post by Me_again » Tue Feb 28, 2006 4:06 am

Don't have much time right now but maybe this will help get you started:

Let>delimiter=,
Let>k=1
Label>start
ReadLn>c:\test\test.txt,k,line
If>line=##EOF##,finish
Separate>line,delimiter,fields
If>fields_1=F,next,jump
Label>next
If>field_4=NONE,jump
Message>do the write to file stuff
Label>jump
Let>k=k+1
Goto>start
Label>finish

mydave
Junior Coder
Posts: 39
Joined: Fri Jul 22, 2005 12:42 pm

Post by mydave » Tue Feb 28, 2006 4:14 am

That looks good, lol.
Thanks, I get started with that.
Cheers

mydave
Junior Coder
Posts: 39
Joined: Fri Jul 22, 2005 12:42 pm

Post by mydave » Tue Feb 28, 2006 10:56 pm


Let>APP_TITLE=Evaluate ECM Codes
Let>RP_WAIT=1

IfDirExists>d:\FaultCodes,CREFault
Cre>d:\FaultCodes
Label>CREFault
IfDirExists>d:\FaultCodes\Result,CREResult
Cre>d:\FaultCodes\Result
Label>CREResult
IfDirExists>d:\FaultCodes\Input,CREInput
Cre>d:\FaultCodes\Input
Label>CREInput
IfDirExists>d:\FaultCodes\NoFault,CRENoFault
Cre>d:\FaultCodes\NoFault
Label>CRENoFault
IfDirExists>d:\FaultCodes\WithFault,CREDone
Cre>d:\FaultCodes\WithFault
Label>CREDone

GetFileList>d:\FaultCodes\Input\*.*,files
Separate>files,;,file_names
MessageModal>Num Files: %file_names_count%

Let>k=0
Repeat>k
Let>k=k+1
Let>ESN=file_names_%k%
Gosub>FileRead
Until>k,file_names_count

Goto>END

SRT>FileRead
Let>delimiter=,
Let>i=1
Label>start
ReadLn>file_names_%k%,i,line
If>line=##EOF##,DoneFileRead
Separate>line,delimiter,fields
Let>FaultCode=fields_4
If>fields_1=F,next,jump
Label>next
If>field_4= NONE,jump
WriteLn>d:\FaultCodes\Result\Engine_With_ECM_Codes.txt,result,%ESN%, %fields_4%
Mov>file_names_%k%,d:\FaultCodes\WithFault\
Label>jump
Let>i=i+1
Goto>start
Label>DoneFileRead
Mov>file_names_%k%,d:\FaultCodes\NoFault\
End>FileRead

Label>END


There is something in the script that would prevent it from getting out of the loop? Help please.

User avatar
Bob Hansen
Automation Wizard
Posts: 2475
Joined: Tue Sep 24, 2002 3:47 am
Location: Salem, New Hampshire, US
Contact:

Post by Bob Hansen » Tue Feb 28, 2006 11:55 pm

Code: Select all

Let>i=i+1
Next line needs.... IF>i=?,start
Goto>Start creates never ending loop, no condition to jump out.

I am not clear on why you are looping here, but I did not do an exhaustive analysis, just looked for the obvious.

You can also single step through the macro looking at the variables.
And/or you can create a log and see why the loop is not breaking out.
Hope this was helpful..................good luck,
Bob
A humble man and PROUD of it!

mydave
Junior Coder
Posts: 39
Joined: Fri Jul 22, 2005 12:42 pm

Post by mydave » Wed Mar 01, 2006 12:57 am

I got it! LOL

Mov>file_names_%k%,d:\FaultCodes\WithFault\
Goto>Done
Label>jump
Let>i=i+1
Goto>start
Label>DoneFileRead
Mov>file_names_%k%,d:\FaultCodes\NoFault\
Label>Done
End>FileRead

Thanks

Post Reply
cron
Sign up to our newsletter for free automation tips, tricks & discounts