| T O P I C R E V I E W |
| amorris |
Posted - 04/19/2006 : 02:05:01 AM Origin Version (Select Help-->About Origin): 7.5 SR6 Operating System: winXP
Hi everyone,
I'm trying to write a labtalk script where I'm opening a file that has a name like "N=XX.dat", where N is an integer between 00 and 99. The problem is that for 0<XX<10, the files are like XX=01.dat, XX=02.dat,..., XX=09.dat, while for 10 <= XX < 100, they are like XX=10.dat, XX=11.dat, ..., XX=99.dat.
Say that %P is the path, and %N is the filename, I would like to force something like
%N=$(XX,2).dat
where XX would be an integer with 2 digits, so that if XX < 10, I get something like
%N=05.dat (for example).
This would save me a lot of if statements! I tried searching for this in the help files, but could not find anything about format options when writing to a string, or character variable.
Thanks,
Alexis
|
| 2 L A T E S T R E P L I E S (Newest First) |
| amorris |
Posted - 04/19/2006 : 3:10:31 PM Thanks Mike, it worked like a charm :) . |
| Mike Buess |
Posted - 04/19/2006 : 09:24:21 AM Hi Alexis,
Much easier to do in Origin C. Add the following function to CodeBuilder's workspace as described here. Use it in a LabTalk script like this... %N=get_file_name(XX)$;.
string get_file_name(int i) { string str; str.Format("%02d.dat",i); return str; }
Mike Buess Origin WebRing Member |
|
|