Matthias Röttger · Jan 26

Line Separator

Hello all, 
I am facing a little issue with line separators.  I export classes with $SYSTEM.OBJ.Export to the file system, but I'm on a Linux (docker) environment and he uses LF. 

Is it somehow possible to change the line separator for the export or in general?

Thanks in advance!

Bests, Matthias

$ZV: IRIS for UNIX (Ubuntu Server LTS for x86-64 Containers) 2021.1.2 (Build 338U) Tue Apr 12 2022 12:05:33 EDT
0 160
Discussion (6)3
Log in or sign up to continue

Hi there,

Are you using VSCode?

If so, you can convert the EOL for new files you create and ones you edit. On VSCode you can use LF on WIndows too without issues.

Otherwise, after exporting the classes, do the following in terminal

Set tOldFile = ##class(%Stream.FileCharacter).%New()
w tOldFile.LinkToFile("C:\whereever\code-with-crlf.xml")
Set tNewFile = ##class(%Stream.FileCharacter).%New()
w tNewFile.LinkToFile("C:\whereever\code-with-lf.xml")
Do tOldFile.Rewind()
While ('tOldFile.AtEnd) {  set tTempStr = tOldFile.ReadLine()  Do tNewFile.Write($ZSTRIP(tTempStr,"*",""_$CHAR(13)) _ $CHAR(10))  }
w tNewFile.%Save()
do tOldFile.%Close()
do tNewFile.%Close()

Then import that file and see if this solution broke your code. :)

Hi Stefan, 
thanks for your reply. I use VSCode but not my colleagues. wink

Your solution seems to work, except from one thing. 
I use the %Stream.FileBinary class for the destination file. 

%Stream.FileCharacter change on linux (!) the line terminator to LF even when I use write instead of writeLine.

Bests, Matthias

What is the actual problem with it? 

All export import for the code should work the same no matter of OS.

Hi Dmitry,
I agree with you, but when you export on Windows and Linux (Iris docker) you have different files because of the line terminator. 

In fact we use different OS for development/staging, which makes it difficult to compare. 

The global "LineTerminator" seem to control it for some Streaming-Classes, but it has no effect to the export.