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
 Number format

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
couturier Posted - 07/28/2017 : 3:51:43 PM
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
4   L A T E S T    R E P L I E S    (Newest First)
couturier Posted - 08/02/2017 : 06:59:03 AM
Thanks
cpyang Posted - 07/29/2017 : 9:53:11 PM
$ 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
couturier Posted - 07/29/2017 : 1:44:21 PM
Thanks for your quick answer.
Hideo Fujii Posted - 07/28/2017 : 6:21:39 PM
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

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