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
 Character formatting
 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 - 08/31/2006 :  6:01:08 PM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
Origin Version (Select Help-->About Origin): 7.5 R6
Operating System:winXP

Hi everyone,

Can anybody tell me how to format the number "0" (ie, zero) as "0.000" in a labtalk script?

I have a loop that imports files with filenames "file_r=0.000.dat" to "file_r=1.000" where r is incremented in steps of 0.001. For r not equal to 0, I can simply use %N=file_r=$(rot,.4).dat, but when the value of my variable is "0", origin doesn't respect my formatting request. Any way to get around this?

Thanks!

Alexis

Mike Buess

USA
3037 Posts

Posted - 09/01/2006 :  09:17:07 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi Alexis,

Might be easiest to force the formatting for rot=0...

if( rot>0 ) %N=$(rot,.4).dat; // shouldn't it be .3?
else %N=0.000.dat;

Mike Buess
Origin WebRing Member

Edited by - Mike Buess on 09/01/2006 09:23:58 AM
Go to Top of Page

amorris

Canada
Posts

Posted - 09/01/2006 :  11:32:39 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi Mike,

Thanks for the reply. I figured as much, but was hoping for a better way to do this (is this a labtalk bug?). At least now I know, and won't have to waste my time looking for something else! And yes, you are right, it should be $(rot,.3), I just made a mistake when parsing my question...

Cheers,

Alexis
Go to Top of Page

Hideo Fujii

USA
1582 Posts

Posted - 09/01/2006 :  12:26:56 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi Alexis,

C format $(rot,%.3f) should work as below:

rot=0;
%k=$(rot,%.3f).dat;
%k=;
0.000.dat

rot=1;
%k=$(rot,%.3f).dat;
%k=;
1.000.dat

--Hideo
OriginLab

Go to Top of Page

amorris

Canada
Posts

Posted - 09/03/2006 :  12:55:20 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi Hideo Fujii,

Thank you a million times over for that little piece of advice! Hard coding file names with if statements isn't so bad if there is just one variable which might equal 0, but if you have 2 or more, it gets quite messy. Thanks again,

Alexis
Go to Top of Page

amorris

Canada
Posts

Posted - 09/03/2006 :  1:09:20 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
One more question: does anyone know where I can find information about the different formatting options that can be used with the substitution notation in labtalk? Searching the help files has gotten me nowhere...

Alexis

Edited by - amorris on 09/03/2006 1:09:58 PM
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