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
 Number format
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

couturier

France
291 Posts

Posted - 07/28/2017 :  3:51:43 PM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
Origin Ver. and Service Release (Select Help-->About Origin): 2017SR2
Operating System:win 10

Hi,

I have an issue formating a number into time format.
For example:
double d1=0.010816342592593;
string str$=$(d1, T10);
str$=; // returns 00:15:34.532, which is the value expected

The thing is I have the time formating saved into a string, such as:
double d1=0.010816342592593;
string format$=T10;
string str$=$(d1, %(format$));
str$=; // returns (format$), which not the value expacted

How to do this ?

Thanks

Hideo Fujii

USA
1582 Posts

Posted - 07/28/2017 :  6:21:39 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi Antoine,

It may be a bug. Or, there may be a possible way, but I don't know. For now, as there are limited number of
built-in time formats, you can make a custom function to convert such as:
function string convertT(double dVal, string TFormat) {
  %B=TFormat$;
  string str$;
  switch (%B) {
    CASE "T1": str$=$(dVal,T1); break;
    CASE "T2": str$=$(dVal,T2); break;
    CASE "T3": str$=$(dVal,T3); break;
    CASE "T4": str$=$(dVal,T4); break;
    CASE "T5": str$=$(dVal,T5); break;
    CASE "T6": str$=$(dVal,T6); break;
    CASE "T7": str$=$(dVal,T7); break;
    CASE "T8": str$=$(dVal,T8); break;
    CASE "T9": str$=$(dVal,T90); break;
    CASE "T10": str$=$(dVal,T10); break;
    CASE "T11": str$=$(dVal,T11); break;
    CASE "T12": str$=$(dVal,T12); break;
    CASE "T13": str$=$(dVal,T13); break;
    CASE "T14": str$=$(dVal,T14); break;
    CASE "T15": str$=$(dVal,T15); break;
    CASE "T16": str$=$(dVal,T16); break;
    CASE "T17": str$=$(dVal,T17); break;
    default: str$="NA"; break;
  }
  return str$;
}

double d1=0.010816342592593;
string format$="T10";
string str$=convertT(d1, format$)$;
str$=;
00:15:34.532
Sorry for a crude work-around...

--Hideo Fujii
OriginLab
Go to Top of Page

couturier

France
291 Posts

Posted - 07/29/2017 :  1:44:21 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Thanks for your quick answer.
Go to Top of Page

cpyang

USA
1406 Posts

Posted - 07/29/2017 :  9:53:11 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
$ substitution bug I have added

https://originlab.jira.com/browse/ORG-16771

but we do have Text()$ string function since 9.1 that is more up to date, so do this instead


double d1=0.010816342592593;
string strFmt$="T10";
string str$=Text(d1, strFmt$)$;
str$=; 



Unfortunately this function is not documented and we will fix that shortly. There is another function Format()$ that will do similar thing.


CP
Go to Top of Page

couturier

France
291 Posts

Posted - 08/02/2017 :  06:59:03 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Thanks
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