Hi, All Anyone know how to delete a blank line in a text file from Navision Programming? I had tried to write the ASCII code of Backspace into the file to delete the blank line,but not working.Anyone tried that before? Thanks. Actually the reason I need to delete the blank line in a text file is that : I am using a dataport to write to a text file. THe dataport has four dataitem, the purch inv header with indent 0, and the GL entry with indent 1 and another group of purch. cr. memo header with G/L entry. I set the dataitemseparater to be in order to separate the 2 groups. the fields i want to export is in the 2 G/L entry. But when it finishes one purch. inv. header record,it will go back to read the next record of Purch inv header dataitem, then it give a new line,but then it will read the linked G/L entry of that purch. inv. header,it will give another new line since the dataitem is changed, which creates a balnk line between each group of G/L entry. But I dun want any blank line in between. Anyone know how to get rid of that blank line? Regards
Hi, I haven’t done much dataporting; I’m still new in navision. I tried to simulate your scenario. However, when I put the 2 indented G/L entries, a message said the FileFormat must be UPXML, sth I don’t understand. But If I include only one of the G/L entry, it goes fine. What I get from the dataport output is sth like this: [Purch. Inv. Header data 1][Purch. Inv. Header data 2] [G/L Entry data 1] [G/L Entry data 2] [Purch. Inv. Header data 3] [G/L Entry 1] … This is surely not the format I want. That’s with DataitemSeparator set to <>. But if I set the DataitemSeparator to , The blank line no longer exists. But if you really need a code that automates the deletion of blank lines in a text file, try running this function. It eliminates ALL blank lines.
RemoveFileBlankLines(FileName : Text) // TargetFile: a File variable pointing FileName // TempFile: a File variable for temporary file // LineText: a Text variable for line data TargetFile.TEXTMODE(TRUE); TempFile.TEXTMODE(TRUE); IF TargetFile.OPEN(FileName) THEN IF TempFile.CREATE(FileName + '.tmp') THEN WHILE TargetFile.POS < TargetFile.LEN DO BEGIN TargetFile.READ(LineText); IF(LineText <> '') THEN TempFile.WRITE(LineText); END; TargetFile.CLOSE; TempFile.CLOSE; IF File.ERASE(FileName) THEN IF File.RENAME(FileName + '.tmp',FileName) THEN; Regards, Hadi Lai
Hi, Can you send your dataport and sample text file, that will really be helpful ?? I shall really help you out. Paramjit
the easiest way to delete a line, is to rename the file, create a new blank file, then read the renamed file and write tot he new file. When you find the line you don’t want, just dont write it to the saved file.