I wrote a piece of code that takes files with records in a particular format and it parses it out the fields; checks them for constancy and spits out some commands. Originally it worked fine with VB files that and everything was fine. Then the customer changed to FB file format and the last field seemed to get fouled against my constancy checking.
Here is the original code piece that was at issue
DO WHILE part_of_record /= 0
parse var stack data_record.count (record_delim) stack /*pop the stack*/
IF debug_flag THEN CALL BUILD_LOG "DLD1002&&Popped the following off the stack:"data_record.count
count=count+1
part_of_record=POS(record_delim,stack) /*is there another part_o f_record*/
IF debug_flag THEN CALL BUILD_LOG "DLD1003&&POS Returned the the following:"part_of_record
IF part_of_record = 0 THEN DO
data_record.count = stack /*grab what is left*/
data_record.0 = count
IF debug_flag THEN CALL BUILD_LOG "DLD1004&&Final part of the stack is:"data_record.count
END
END /*Done breaking apart record */
Now the highlighted piece above was the issue.. I changed it to the following and it fixed the issue
data_record.count = strip(stack) /*grab what is left*/
However I am trying to understand why with a VB Record Formatted file would be treated differently then a FB record format. This is an academic exercise since probably it would have been best If I always use a strip on the last field of a record like this but I really want to understand why.