This script resemble the first one, especially the beginning.
The part that parse the input file should be easier to follow as it use just a few lines within a loop.
This script can even parse the info.txt-file correctly, and leave out the comments and the part with the correct result.
/*
* Filename: raiko62.cmd
* Author: Jan-Erik
* Created: Tue Sep 6 2016
* Purpose:
* Changes:
*/
IF ARG(1) <> '' THEN
DO
PARSE UPPER VALUE ARG(1) WITH f_name'.TXT' o_name
f_name = f_name'.TXT'
END
IF LENGTH( STRIP( o_name ) ) = 0 THEN
DO
CALL CHAROUT 'STDOUT', 'Spara fil som:'
PARSE PULL o_name
END
IF LENGTH( STRIP( f_name ) ) = 0 THEN RETURN 1
IF LENGTH( STRIP( o_name ) ) = 0 THEN RETURN 2
IF STREAM( f_name, 'C', 'QUERY EXISTS' ) = '' THEN RETURN 3
f_size = STREAM( f_name, 'C', 'QUERY SIZE' )
IF f_size < 100 THEN RETURN 4
input = CHARIN( f_name, 1, f_size )
CALL STREAM f_name, 'C', 'CLOSE'
crlf = D2C(13)D2C(10)
output = ''
DO WHILE LENGTH( input ) > 0
IF DATATYPE( SPACE( TRANSLATE( SUBWORD( input, 1, 1 ), , '-,' ), 0 ), 'N' ) THEN
DO
PARSE VALUE input WITH val 20 acnt 26 dat 35 ben 56 lbl 59 cust(crlf)input
output = output||SPACE( TRANSLATE( val,, '.' ), 0 )';'STRIP( acnt )';'STRIP( dat )';'STRIP( ben )';'STRIP( lbl )';'STRIP( cust )';'crlf
END
ELSE PARSE VALUE input WITH . (crlf)input
END
CALL CHAROUT STRIP( o_name ), output
CALL STREAM STRIP( o_name ), 'C', 'CLOSE'
Regards,
//Jan-Erik