The Origin Forum
File Exchange
Try Origin for Free
The Origin Forum
Home | Profile | Register | Active Topics | Members | Search | FAQ | Send File to Tech support
Username:
Password:
Save Password
Forgot your Password? | Admin Options

 All Forums
 Origin Forum for Programming
 LabTalk Forum
 Formatting question
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

amorris

Canada
Posts

Posted - 04/19/2006 :  02:05:01 AM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
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



Mike Buess

USA
3037 Posts

Posted - 04/19/2006 :  09:24:21 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
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
Go to Top of Page

amorris

Canada
Posts

Posted - 04/19/2006 :  3:10:31 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Thanks Mike, it worked like a charm :) .
Go to Top of Page
  Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
The Origin Forum © 2020 Originlab Corporation Go To Top Of Page
Snitz Forums 2000