"endline" symbol in wave generated .txt

Hello everyone,

I want to generate a .txt from a text wave. It works well, but the generated txt file is formatted in one single line with "endline" symbol (an empty square) instead of multiple lines. The device in which I need to load the .txt doesn't seem to understand the file, whereas it understands the same .txt manually typed. Is there a way to get rid of those "endline" symbol ?

here's a part of my code :

Make/T/O/N=2000 Prgm
[...]
Do
        prgm[3+i]="SetSync 2"
        prgm[4+i]="Slewxy "+num2str(Xfin)+" "+num2str(posy)+" "+num2str(t0)
        prgm[5+i]="UnSetSync 2"
        prgm[6+i]="Slewxy "+num2str(Xfin)+" "+num2str(posy+step)+" "+num2str(t0/10)
        prgm[7+i]="SetSync 2"
        prgm[8+i]="Slewxy "+num2str(posx)+" "+num2str(posy+step)+" "+num2str(t0)
        prgm[9+i]="UnSetSync 2"
        prgm[10+i]="Slewxy "+num2str(posx)+" "+num2str(posy+2*step)+" "+num2str(t0/10)
        posy=posy+2*step
        i+=8
    While (i<lignes*4)
[...]
Save/G Prgm as "Prgm.txt"  
KillWaves Prgm



cheers,
Gautier


I suppose you are working on windows. The Save operation uses the macintosh EOL convention.
Add the /M="\r\n" flag to the Save command:
Save/G/M="\r\n" Prgm as "Prgm.txt"
neogin wrote:
I want to generate a .txt from a text wave. ... but the generated txt file is formatted in one single line with "endline" symbol (an empty square) instead of multiple lines.


A cleaner option may be to use the sprintf command with the inbuilt formatting that you want for the numbers and an included a "carriage return" at the end of each line ...

do
     sprintf prgm[3+i], "SetSync 2\r"
     sprintf prgm[4+i], "Slewxy %g %g %g\r", Xfin, posy, t0
     ....
while(...)


Since you are writing line-by-line, as needed, you can also avoid having to generate a text wave by dumping everything directly to a string.

string strprgrm

...
do
     sprintf strprgm, "SetSync 2\r"
     sprintf strprgm, "Slewxy %g %g %g\r", Xfin, posy, t0
     ....
while(...)


Finally, if you do not need the intermediate text, you might write the strings directly to a file on a line-by-line basis.

open refNum as filenameStr

...
do
     fprintf refnum, "SetSync 2\r"
     fprintf refnum, "Slewxy %g %g %g\r", Xfin, posy, t0
     ....
while(...)
close refNum



--
J. J. Weimer
Chemistry / Chemical & Materials Engineering, UAHuntsville
jjweimer wrote:

sprintf prgm[3+i], "SetSync 2\r"

This does not work for me, it is throwing the error "expected string variable name". I think one has to use an intermediate string:
string str
sprintf str, "SetSync 2\r"
prgm[3]=str


Another interesting thing in this context: It doesn't seem to be possible to save text waves containing NUL byte strings with the /G, /J or /T flag.
make/o/t prgm=num2char(p)
save/g prgm

gives an "out of memory" error, make/o/t prgm=num2char(p+1) can be saved.
I used the first solution, it works well. I'll keep the other solutions in mind for next time.

Thanks guys,
G.