read text file
Moderators: Dorian (MJT support), JRL
read text file
hi
I have some problem reading a txt file
I don't now how to do that.
it is very simple
it should read the contents of a text file and where the words MISREF is mentioned it should send me a email (this MISREF contains always with have a number for example MISREF132525)
it is also possible that this MISREF is mentioned twice or more so there should be a loop in it.
is this possible to do via macro scheduler?
please advise
Kisoen
I have some problem reading a txt file
I don't now how to do that.
it is very simple
it should read the contents of a text file and where the words MISREF is mentioned it should send me a email (this MISREF contains always with have a number for example MISREF132525)
it is also possible that this MISREF is mentioned twice or more so there should be a loop in it.
is this possible to do via macro scheduler?
please advise
Kisoen
Try something like this:
let>Row=0
Label>READFILE
readln>c:\myfile.txt,%Row%,TextLine
If>TextLine=##EOF##
goto>ProgramEnd
endif>
rem> now check for you MISREF string
Pos>MISREF,%TextLine%,1,FoundIt
if>FoundIt>0
SMTPSendMail>look in the help files for the settings for SMTPSendMail
endif>
goto>READFILE
Label>ProgramEnd
Let us know if you don't understand any of this code and we will help you.
let>Row=0
Label>READFILE
readln>c:\myfile.txt,%Row%,TextLine
If>TextLine=##EOF##
goto>ProgramEnd
endif>
rem> now check for you MISREF string
Pos>MISREF,%TextLine%,1,FoundIt
if>FoundIt>0
SMTPSendMail>look in the help files for the settings for SMTPSendMail
endif>
goto>READFILE
Label>ProgramEnd
Let us know if you don't understand any of this code and we will help you.
read text file
hi
when testing retrieving an error
can find label programend...
please advise
kisoen
when testing retrieving an error
can find label programend...
please advise
kisoen
read text file
this is my coding
GetDate>date
Let>CF_OVERWRITE=1
Let>msg=The Date Is :
ConCat>msg,date
year>YY
month>MM
day>dd
rem Message>%mm%%dd%
IfFileExists>n:\Receive\Logs\EDI_import_06%mm%%dd%.txt,next
goto>end
label>next
CopyFile>n:\Receive\Logs\EDI_import_06%mm%%dd%.txt,c:\temp\EDI_import_06%mm%%dd%.txt
let>Row=0
Label>READFILE
readln>c:\temp\EDI_import_06%mm%%dd%.txt,%Row%,TextLine
If>TextLine=##EOF##
goto>ProgramEnd
endif>
rem> now check for you MESREF string
Pos>MESREF,%TextLine%,1,FoundIt
if>FoundIt>0
goto>READFILE
Label>ProgramEnd
Let>SENDMAIL_STATUS=1
Let>subject=error edi message
Let>me=[email protected]
Let>myname=Mr Smith
Let>recipients=[email protected];[email protected]
rem Input>body,Enter your message:
SMTPSendMail>recipients,mailgate.klm.nl,me,myname,subject,This email contains EDI error APPZ Trips,;c:\temp\EDI_import_06%mm%%dd%.txt
rem Message>Result of SendMail: %SMTP_RESULT%
endif>
as far i can see and receive is the attachment via email
I want that the message MESREF with a number will be in the email
thx for the hint for removing trailer spaces (it works)
but... how can i only receive the mesref message?
the textfile look like this
[Import operation] started on 18/05/06 05:13:51
Process started
Loading EDI messages from file i.060518050028
[CARDIT 1] MesRef=MESREF37346, Component=Cardit1_1ReceptacleInfo, Item=SESTOCEGCAIBAEN60009001100016, Error=Invalid (Receptacle-handling-class)
[CARDIT 1] MesRef=MESREF37346, Component=Cardit1_1Info, Item=SE6015118658, Error=Invalid
*Err* The message body could not be read
Process stopped
as you can see the MesRef=MESREF37346 this is what i want via email
please advise
kisoen
GetDate>date
Let>CF_OVERWRITE=1
Let>msg=The Date Is :
ConCat>msg,date
year>YY
month>MM
day>dd
rem Message>%mm%%dd%
IfFileExists>n:\Receive\Logs\EDI_import_06%mm%%dd%.txt,next
goto>end
label>next
CopyFile>n:\Receive\Logs\EDI_import_06%mm%%dd%.txt,c:\temp\EDI_import_06%mm%%dd%.txt
let>Row=0
Label>READFILE
readln>c:\temp\EDI_import_06%mm%%dd%.txt,%Row%,TextLine
If>TextLine=##EOF##
goto>ProgramEnd
endif>
rem> now check for you MESREF string
Pos>MESREF,%TextLine%,1,FoundIt
if>FoundIt>0
goto>READFILE
Label>ProgramEnd
Let>SENDMAIL_STATUS=1
Let>subject=error edi message
Let>me=[email protected]
Let>myname=Mr Smith
Let>recipients=[email protected];[email protected]
rem Input>body,Enter your message:
SMTPSendMail>recipients,mailgate.klm.nl,me,myname,subject,This email contains EDI error APPZ Trips,;c:\temp\EDI_import_06%mm%%dd%.txt
rem Message>Result of SendMail: %SMTP_RESULT%
endif>
as far i can see and receive is the attachment via email
I want that the message MESREF with a number will be in the email
thx for the hint for removing trailer spaces (it works)
but... how can i only receive the mesref message?
the textfile look like this
[Import operation] started on 18/05/06 05:13:51
Process started
Loading EDI messages from file i.060518050028
[CARDIT 1] MesRef=MESREF37346, Component=Cardit1_1ReceptacleInfo, Item=SESTOCEGCAIBAEN60009001100016, Error=Invalid (Receptacle-handling-class)
[CARDIT 1] MesRef=MESREF37346, Component=Cardit1_1Info, Item=SE6015118658, Error=Invalid
*Err* The message body could not be read
Process stopped
as you can see the MesRef=MESREF37346 this is what i want via email
please advise
kisoen
- Marcus Tettmar
- Site Admin
- Posts: 7395
- Joined: Thu Sep 19, 2002 3:00 pm
- Location: Dorset, UK
- Contact:
Hi,
This reads the text file line by line and if it finds MesRef=MESREFnnnnnn, it will extract the MESREFnnnnnn bit. It works by looking for MesRef= and if it finds it extracts from just after MesRef= to the next comma.
Change the first line of your script to reflect the path to your input file and run the script as is and it will pop up a message for each MESREF. All you need to do is replace that with an STMPSendMail command.
Let>comma=,
Let>input=c:\temp\input.txt
Let>k=1
Label>readloop
ReadLn>input,k,line
If>line=##EOF##,doneread
Length>line,ln
Position>MesRef=,line,1,p
If>p>0
Let>p=p+7
MidStr>line,p,ln,line
Position>comma,line,1,p
Let>p=p-1
MidStr>line,1,p,line
MessageModal>line
//SMTPSendMail>.....
Endif
Let>k=k+1
Goto>readloop
Label>doneread
This reads the text file line by line and if it finds MesRef=MESREFnnnnnn, it will extract the MESREFnnnnnn bit. It works by looking for MesRef= and if it finds it extracts from just after MesRef= to the next comma.
Change the first line of your script to reflect the path to your input file and run the script as is and it will pop up a message for each MESREF. All you need to do is replace that with an STMPSendMail command.
Let>comma=,
Let>input=c:\temp\input.txt
Let>k=1
Label>readloop
ReadLn>input,k,line
If>line=##EOF##,doneread
Length>line,ln
Position>MesRef=,line,1,p
If>p>0
Let>p=p+7
MidStr>line,p,ln,line
Position>comma,line,1,p
Let>p=p-1
MidStr>line,1,p,line
MessageModal>line
//SMTPSendMail>.....
Endif
Let>k=k+1
Goto>readloop
Label>doneread
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?
read text file
hi
I get the following error
on line If>p>0
please advise what to do or to change
error - subroutine/label p>0 not found
I hope this will help me fixing the code
gr. kisoen
I get the following error
on line If>p>0
please advise what to do or to change
error - subroutine/label p>0 not found
I hope this will help me fixing the code
gr. kisoen
- Marcus Tettmar
- Site Admin
- Posts: 7395
- Joined: Thu Sep 19, 2002 3:00 pm
- Location: Dorset, UK
- Contact:
Which version of Macro Scheduler are you using? Please check under Help/About.
You must have an earlier version. In which case try this:
Let>comma=,
Let>input=c:\temp\input.txt
Let>k=1
Label>readloop
ReadLn>input,k,line
If>line=##EOF##,doneread
Length>line,ln
Position>MesRef=,line,1,p
If>p=0,noextract
Let>p=p+7
MidStr>line,p,ln,line
Position>comma,line,1,p
Let>p=p-1
MidStr>line,1,p,line
MessageModal>line
//SMTPSendMail>.....
Label>noextract
Let>k=k+1
Goto>readloop
Label>doneread
You must have an earlier version. In which case try this:
Let>comma=,
Let>input=c:\temp\input.txt
Let>k=1
Label>readloop
ReadLn>input,k,line
If>line=##EOF##,doneread
Length>line,ln
Position>MesRef=,line,1,p
If>p=0,noextract
Let>p=p+7
MidStr>line,p,ln,line
Position>comma,line,1,p
Let>p=p-1
MidStr>line,1,p,line
MessageModal>line
//SMTPSendMail>.....
Label>noextract
Let>k=k+1
Goto>readloop
Label>doneread
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?
read text file
hi,
sometime script is working perfectly
en sometimes still getting error in position command
can this be fixed??
also have so difficulties with the loop
it seems like the macro is hanging.....
please advise
kisoen
sometime script is working perfectly
en sometimes still getting error in position command
can this be fixed??
also have so difficulties with the loop
it seems like the macro is hanging.....
please advise
kisoen
- Marcus Tettmar
- Site Admin
- Posts: 7395
- Joined: Thu Sep 19, 2002 3:00 pm
- Location: Dorset, UK
- Contact:
Try this
BTW - We could do ALL your work for you but at some point it might be a good idea if you spent a bit of time understanding exactly what the above code does and try stepping through with the debugger to see exactly what causes the errors you refer to and why they happen. It will save us all a lot of time.
Code: Select all
Let>comma=,
Let>input=c:\temp\input.txt
Let>k=1
Label>readloop
ReadLn>input,k,line
If>line=##EOF##,doneread
Length>line,ln
If>ln<7,noextract
Position>MesRef=,line,1,p
If>p=0,noextract
Let>p=p+7
MidStr>line,p,ln,line
Position>comma,line,1,p
Let>p=p-1
MidStr>line,1,p,line
MessageModal>line
//SMTPSendMail>.....
Label>noextract
Let>k=k+1
Goto>readloop
Label>doneread
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?