Tab in a string wave
mssmtrainee
I'm trying to create a text file with the following display:
dat.001 (no TAB)
1,IRERUN (TAB)
dat.002 (no TAB)
1,IRERUN (TAB)
etc...
My issue is when I use "1, IRERUN (TAB)", it displays "1,IRERUN /t" instead.
I tried a few things such as "1, IRERUN: \r\(TAB)" but it did not work either, it displayed "1, IRERUN: \r\\t" instead.
Here is the code.
...
make/T/N = (j*2) sWave
variable jjs
variable titi=1
for(jjs=0;jjs<(j*2);jjs+=2)
String wname //= "dat."+ num2str(titi)
Sprintf wname,"dat.%03d", titi
sWave[jjs] = wname
sWave[jjs+1] = "1,IRERUN "
titi +=1
Save/P=$pathName /J /O/M="\r\n" sWave as "BATCHLIST.dat" // Delete "/P=$pathName" if you want to specify the path yourself
killwaves/A
return fileNameList
...
Thanks!
make/T/N = (j*2) sWave
variable jjs
variable titi=1
for(jjs=0;jjs<(j*2);jjs+=2)
String wname //= "dat."+ num2str(titi)
Sprintf wname,"dat.%03d", titi
sWave[jjs] = wname
sWave[jjs+1] = "1,IRERUN "
titi +=1
Save/P=$pathName /J /O/M="\r\n" sWave as "BATCHLIST.dat" // Delete "/P=$pathName" if you want to specify the path yourself
killwaves/A
return fileNameList
...
Thanks!
To produce a tab character in a literal string use backslash followed by t. For example:
Function Demo()
Make/O/T/N=1 textWave0 = {"jack\tjill"}
Save /P=TestPath /J /E=0 /O textWave0 as "TestFile.txt"
End
Here backslash t is an escape sequence that represents a tab character. This is more clear than using a literal tab character since an actual tab is not visually distinct from a space or multiple spaces.
For more information execute:
December 5, 2012 at 09:15 pm - Permalink