gregorywest
22-01-2015, 23:21
I have hit an issue that should be very simple to deal with.
I have one text file from the IBM AS/400 with invoice information. Not I could download the information, but that is a lot of work, not the least of whiich is converting EBCDIC to ASCII and getting all the AS/400 ports and security correct. Instead, since I print through a windows computer it is easier to print the invoices to a TXT file.
Now all I have to do is write a quick down and dirty basic program to read in the data massage it and write out the import file I need.
My problem is getting the ThinBASIC syntax to open the two files up. I do have 100% control over the file names, "S:\Invoice_Export.exe" and "S:\Invoice_Import.txt" The Export file would be opened read only, and written out to the Import file overwriting any import file that might be there already.
Basically the program would look like this:
Open exportfile readonly
Open importfile overwrite
write importfile "Header information and formatting"
Loop: gosub process_invoice
write importfile invoice_string 'created by process invoice
if not eof(exportfile) goto Loop
close exportfile
close importfile
end
function process_invoice
this is a little complex
basically a bunch of reads from exportfile and logic to figure out what was read in.
endfn
The file itself would look something like:
S983663523
8765432
2015-01-15 23432 432423 4324232 4324224
01 8373764 A DESCRIPTION LINE 2 123.00 246.00
MORE DESCRIPTION
02 948873 AND ON WE GO FOR MULTIPLE LINES 1 123.00 123.00
I can write the code to deal with what is in the file, just looking for the syntax of how to open, read, write to the TXT files.
Thanks in advance
Greg
I have one text file from the IBM AS/400 with invoice information. Not I could download the information, but that is a lot of work, not the least of whiich is converting EBCDIC to ASCII and getting all the AS/400 ports and security correct. Instead, since I print through a windows computer it is easier to print the invoices to a TXT file.
Now all I have to do is write a quick down and dirty basic program to read in the data massage it and write out the import file I need.
My problem is getting the ThinBASIC syntax to open the two files up. I do have 100% control over the file names, "S:\Invoice_Export.exe" and "S:\Invoice_Import.txt" The Export file would be opened read only, and written out to the Import file overwriting any import file that might be there already.
Basically the program would look like this:
Open exportfile readonly
Open importfile overwrite
write importfile "Header information and formatting"
Loop: gosub process_invoice
write importfile invoice_string 'created by process invoice
if not eof(exportfile) goto Loop
close exportfile
close importfile
end
function process_invoice
this is a little complex
basically a bunch of reads from exportfile and logic to figure out what was read in.
endfn
The file itself would look something like:
S983663523
8765432
2015-01-15 23432 432423 4324232 4324224
01 8373764 A DESCRIPTION LINE 2 123.00 246.00
MORE DESCRIPTION
02 948873 AND ON WE GO FOR MULTIPLE LINES 1 123.00 123.00
I can write the code to deal with what is in the file, just looking for the syntax of how to open, read, write to the TXT files.
Thanks in advance
Greg