(First Letter) Not Appropriate

Hints, tips and tricks for newbies

Moderators: Dorian (MJT support), JRL

Post Reply
winstein
Pro Scripter
Posts: 84
Joined: Mon Nov 26, 2012 3:44 pm

(First Letter) Not Appropriate

Post by winstein » Mon Mar 24, 2014 3:30 am

When I use the ReadLn function to read each line in a file, I would get an error saying "Line: (Line No) (First letter after quotation mark) not appropriate". To illustrate, I will use an example. Use this in a .txt or .csv file:
"Dunnow"|"DESREC DDDF"|1324|222222|True
"FDEXxxx"|"ASDFEW DSXEX"|123|897|False
"Gelex"|"JENCPOEIR"|123958|172364|False
I will use this code below:

Code: Select all

Let>FileName=C:\Users\e-Machine\Desktop\Filex.csv

Let>LinePos=1
Let>CurrLine=
Let>EndOfFile=##EOF##
While>CurrLine<EndOfFile>FileName,LinePos,CurrLine
    If>CurrLine<EndOfFile>%CurrLine%
    EndIf
    Let>LinePos=LinePos+1
EndWhile
If I run the above code, I will get an error if I looped back to the beginning, meaning when CurrLine is equal to one of the lines in the text file, like this (one line at a time):

Line: 18 D not appropriate
Line: 18 F not appropriate
Line: 18 G not appropriate

What should I do to prevent this problem from happening?

Thanks for reading.
PPQ

User avatar
Marcus Tettmar
Site Admin
Posts: 7395
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Post by Marcus Tettmar » Mon Mar 24, 2014 12:52 pm

Your code is garbled.

I would do:

Code: Select all

Let>FileName=C:\Users\e-Machine\Desktop\Filex.csv
ReadFile>FileName,FileData
Separate>FileData,CRLF,lines
If>lines_count>0
  Let>k=0
  Repeat>k
     Let>k=k+1
     Let>this_line=lines_%k%
     Separate>this_line,|,fields
     //you now have fields_1, fields_2 ... fields_5 (each bit separated by |)
  Until>k=lines_count
Endif
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

davedavydave
Newbie
Posts: 16
Joined: Mon Dec 01, 2008 3:56 pm

Re: (First Letter) Not Appropriate

Post by davedavydave » Thu Jun 25, 2015 10:49 am

This code helped me thanks Marcus
Cheers,
Dave

Hill Running...... Beats work!

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