Digital Workshop

Welcome to the Digital Workshop Message Boards
It is currently December 22nd, 2024, 12:39 pm

All times are UTC [ DST ]




Post new topic Reply to topic  [ 8 posts ] 
Author Message
 Post subject: Number format
PostPosted: March 25th, 2019, 2:06 pm 
Offline

Joined: May 16th, 2008, 4:50 pm
Posts: 368
Location: Berghem The Netherlands
Opus: Opus Pro 9.75
OS: Windows 10
System: `HP
Hi,
Is there an easy way to display lage number by adding points.
I like to display numbers greater 1000 as 1.000 and 10000 as 10.000 an 1000000 as 1.000.000
At this moment i am working on an auction display and then it's easier to read.

Kind regards,
Ad

_________________
Opus Pro v9.75
Windows 10 on HP EliteBook i7
http://www.csnmedia.nl


For this message Ad Mulders has been thanked by : mackavi


Top
 Profile Visit website  
 
 Post subject: Re: Number format
PostPosted: March 25th, 2019, 10:15 pm 
Offline
Godlike
Godlike
User avatar

Joined: March 21st, 2007, 10:44 am
Posts: 3188
Location: UK
Opus: Evolution
Code:
Debug.trace(toCommas(1000))

function toCommas(s) {
var a = new Array();
s = s.toString();

for (var i = 0; i < s.length / 3; i++){

   a[i] = s.substring(s.length - ((i + 1)  * 3),s.length - (i  * 3));
   a[i] = a[i].toString();
};

return a.reverse().join(",");
}


The UK uses commas if that is a point character change it on the return line.

</mack>

_________________
When you have explored all avenues of possibilities, what ever remains, how ever improbable, must be the answer.

Interactive Solutions for Business & Education
Learn Anywhere. Learn Anytime.

www.interaktiv.co.uk
+44 (0) 1395 548057


Top
 Profile Visit website  
 
 Post subject: Re: Number format
PostPosted: March 26th, 2019, 4:24 pm 
Offline

Joined: May 16th, 2008, 4:50 pm
Posts: 368
Location: Berghem The Netherlands
Opus: Opus Pro 9.75
OS: Windows 10
System: `HP
Thanks Mack,
Here in the Netherlands we use points. The comma we use for cents.
Gonne implement it right away.

_________________
Opus Pro v9.75
Windows 10 on HP EliteBook i7
http://www.csnmedia.nl


For this message Ad Mulders has been thanked by : mackavi


Top
 Profile Visit website  
 
 Post subject: Re: Number format
PostPosted: March 26th, 2019, 6:50 pm 
Offline

Joined: May 16th, 2008, 4:50 pm
Posts: 368
Location: Berghem The Netherlands
Opus: Opus Pro 9.75
OS: Windows 10
System: `HP
Hi Mack,

I wanted to post a demo file how i made the functions in the auction program but it's not possible to add a file
so i put it on my server. www.csnmedia.nl/opus/demo_auction.imp
Can you please tell me where to put the script.

Kind Regards,
Ad

_________________
Opus Pro v9.75
Windows 10 on HP EliteBook i7
http://www.csnmedia.nl


For this message Ad Mulders has been thanked by : mackavi


Top
 Profile Visit website  
 
 Post subject: Re: Number format
PostPosted: March 27th, 2019, 10:25 pm 
Offline
Godlike
Godlike
User avatar

Joined: March 21st, 2007, 10:44 am
Posts: 3188
Location: UK
Opus: Evolution
Yes, the board is full.

I'll leave it here for a few days: https://sandbox.interaktiv.co.uk/tmp/demo_auction.zip

</mack>

_________________
When you have explored all avenues of possibilities, what ever remains, how ever improbable, must be the answer.

Interactive Solutions for Business & Education
Learn Anywhere. Learn Anytime.

www.interaktiv.co.uk
+44 (0) 1395 548057


Top
 Profile Visit website  
 
 Post subject: Re: Number format
PostPosted: March 28th, 2019, 6:44 am 
Offline

Joined: May 16th, 2008, 4:50 pm
Posts: 368
Location: Berghem The Netherlands
Opus: Opus Pro 9.75
OS: Windows 10
System: `HP
Thanks Mack,
Now it's clear and works great. I found one error and i hope it's only a script line thing.
When the value reaches One Milion, the output is: 1e+.006

Kind Regards, Ad

_________________
Opus Pro v9.75
Windows 10 on HP EliteBook i7
http://www.csnmedia.nl


For this message Ad Mulders has been thanked by : mackavi


Top
 Profile Visit website  
 
 Post subject: Re: Number format
PostPosted: March 28th, 2019, 10:48 am 
Offline
Godlike
Godlike
User avatar

Joined: March 21st, 2007, 10:44 am
Posts: 3188
Location: UK
Opus: Evolution
It's not an error. Opus is using exponential notation and not converting it back to a string in base ten format.

You should be able to replace the line:

Code:
s = s.toString();


with

Code:
s = String.string(s);


Please be aware that this change will fail in HTML5 publications.

</mack>

_________________
When you have explored all avenues of possibilities, what ever remains, how ever improbable, must be the answer.

Interactive Solutions for Business & Education
Learn Anywhere. Learn Anytime.

www.interaktiv.co.uk
+44 (0) 1395 548057


Top
 Profile Visit website  
 
 Post subject: Re: Number format
PostPosted: March 28th, 2019, 12:37 pm 
Offline

Joined: May 16th, 2008, 4:50 pm
Posts: 368
Location: Berghem The Netherlands
Opus: Opus Pro 9.75
OS: Windows 10
System: `HP
Thanks Mack,
This problem is solved. I am making a stand alone application so HTML5 is irrelevant.
Now let's make the different currencies. I made it for Dollar and Pound the old way
but now i have to implement the script.... :?

Kind Regards, Ad

_________________
Opus Pro v9.75
Windows 10 on HP EliteBook i7
http://www.csnmedia.nl


For this message Ad Mulders has been thanked by : mackavi


Top
 Profile Visit website  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 8 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: No registered users and 25 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group