# How to delete a blank line in a text file by CAL?

**URL:** <https://www.dynamicsuser.net/t/how-to-delete-a-blank-line-in-a-text-file-by-cal/10011>\
**Category:** Developers Forum\
**Created:** [June 1, 2005, 11:24am UTC](https://www.dynamicsuser.net/t/how-to-delete-a-blank-line-in-a-text-file-by-cal/10011 "2005-06-01T11:24:34Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![phoenixlu](https://avatars.discourse-cdn.com/v4/letter/p/b5ac83/32.png) [@phoenixlu](https://www.dynamicsuser.net/u/phoenixlu)\
**Post date:** [June 1, 2005, 11:24am UTC](https://www.dynamicsuser.net/t/how-to-delete-a-blank-line-in-a-text-file-by-cal/10011/1 "2005-06-01T11:24:34Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![innersome](https://avatars.discourse-cdn.com/v4/letter/i/ea5d25/32.png) [@innersome](https://www.dynamicsuser.net/u/innersome)\
**Post date:** [June 1, 2005, 1:59pm UTC](https://www.dynamicsuser.net/t/how-to-delete-a-blank-line-in-a-text-file-by-cal/10011/2 "2005-06-01T13:59:38Z")

</div>

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[250]) // TargetFile: a File variable pointing FileName // TempFile: a File variable for temporary file // LineText: a Text[250] 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

---

<div class="post-metadata">

**Author:** ![paramjit\_pummi](https://avatars.discourse-cdn.com/v4/letter/p/a3d4f5/32.png) [@paramjit\_pummi](https://www.dynamicsuser.net/u/paramjit_pummi)\
**Post date:** [June 2, 2005, 6:07am UTC](https://www.dynamicsuser.net/t/how-to-delete-a-blank-line-in-a-text-file-by-cal/10011/3 "2005-06-02T06:07:56Z")

</div>

Hi, Can you send your dataport and sample text file, that will really be helpful ?? I shall really help you out. Paramjit

---

<div class="post-metadata">

**Author:** ![David\_Singleton](https://sea1.discourse-cdn.com/flex023/user_avatar/www.dynamicsuser.net/david_singleton/32/7471_2.png) [@David\_Singleton](https://www.dynamicsuser.net/u/David_Singleton)\
**Post date:** [June 6, 2005, 7:46pm UTC](https://www.dynamicsuser.net/t/how-to-delete-a-blank-line-in-a-text-file-by-cal/10011/4 "2005-06-06T19:46:15Z")

</div>

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.
