i am reading an email file in linux server.i am reading the file line by line and extracting the data which i need from the file.i am using an state machine to process these files.My current desing is based on a particular orde of the data.
code snippet.
This state machine works only when the "Date" line comes first and "Thread-Topic" comes next.
if the order changes like "Thread-Topic" comes first and "Date" comes next then it fails.
please help me to work it for any order in the email file.
Based on email client the order of data gets changed.
I have attached an sample file.
code snippet.
Code:
input from value(v-File).
vState = "Undefined".
doparse:
repeat while vState <> "Uncompliant":
import unformatted vRow.
case vState:
when "Undefined" then
do:
if entry(1,vRow,":") = "Date" then
do:
run GetDateInfo( input vRow,
output v-ComplianceDate,
output v-ComplianceTime,
output vState
).
end.
end.
when "HaveDate" then
do:
if entry(1,vRow," ") = "Thread-topic:" and
entry(2,vRow," ") = "COMPLAINT:" then
do:
run GetSubject( input vRow,
output v-ProductID,
output v-DispatchID,
output vState
).
end.
else if entry(1,vRow," ") = "Thread-topic:" and
entry(2,vRow," ") <> "COMPLAINT:" then
vState = "UnCompliant".
end.
when "HaveSubject" then
do:
if vRow = "Comply" then vState = "Compliant".
end.
when "Compliant" then do:
v-ComplianceRemarks = trim(vRow).
leave doparse.
end.
end. /* end case */
end.
input close.
This state machine works only when the "Date" line comes first and "Thread-Topic" comes next.
if the order changes like "Thread-Topic" comes first and "Date" comes next then it fails.
please help me to work it for any order in the email file.
Based on email client the order of data gets changed.
I have attached an sample file.
Attachments
Last edited by a moderator: