A: |
There is another way to do it, which is faster, but not
as reliable (it just checks for the field name to be present on a line to parse it,
but doesn't check that the field name is in the correct position on the line):
AppendToFile True
:Archive
Set $dbname "-"
Set $dbemail "-"
ReadBody $body %message
UnquoteBody $body ">" {In case the message is forwarded}
LineCount #c3 $body
Dec #c3
Set #i 0
:LoopDB
GetLine $Line #i $body
Set $s $Line
Lowercase $s
if "e-mail address:" ^ $s then SetEmail
if "name:" ^ $s then SetName
:ContinueDB
Inc #i
if #i > #c3 then FinishDB
goto LoopDB
{ Process form fields }
:SetEmail
if $dbemail ! "-" then ContinueDB
ChopString $Line 1 15
Trim $Line
If $Line = "" then ContinueDB
Set $dbemail $Line
goto ContinueDB
:SetName
if $dbname ! "-" then ContinueDB
ChopString $Line 1 5
Trim $Line
If $Line = "" then ContinueDB
Set $dbname $Line
goto ContinueDB
:FinishDB
{ Add information to form a single }
{ line of a CSV file, then save it }
Set $db ""
AppendBody $db $dbname
AppendBody $db $dbemail
WriteCSV $dbcsv $db
SaveBody $dbcsv "C:\ pocodb.csv"
{ END }
There is some code in there to minimize errors. This can be easily expanded to support as many fields on a form as you need. |