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
 All Forums
 Origin Forum for Programming
 LabTalk Forum
 Formatting question

Note: You must be registered in order to post a reply.
To register, click here. Registration is FREE!

Screensize:
UserName:
Password:
Anti-Spam Code:
Format Mode:
Format: BoldItalicizedUnderlineStrikethrough Align LeftCenteredAlign Right Horizontal Rule Insert HyperlinkUpload FileInsert Image Insert CodeInsert QuoteInsert List
   
Message:

* HTML is OFF
* Forum Code is ON
Smilies
Smile [:)] Big Smile [:D] Cool [8D] Blush [:I]
Tongue [:P] Evil [):] Wink [;)] Clown [:o)]
Black Eye [B)] Eight Ball [8] Frown [:(] Shy [8)]
Shocked [:0] Angry [:(!] Dead [xx(] Sleepy [|)]
Kisses [:X] Approve [^] Disapprove [V] Question [?]

 
Check here to subscribe to this topic.
   

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

The Origin Forum © 2020 Originlab Corporation Go To Top Of Page
Snitz Forums 2000