Gadget formet

Just starting out? Need help? Post your questions and find answers here.
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by OlliB.

Hi!

Is it possible, to format numbers in a Gadget List...

e.g.

2341 4567 Time Date
23 125 ... ....
123 2345 ... ....


I hope, somebody could help me...

Olli
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by PB.

> Is it possible, to format numbers in a Gadget List...

Yes. Download Mr Skunk's "String2" library from here:

http://www.skunknet.fr.st/

Then, install the file to the PureBasic "PureLibaries/UserLibraries" folder and
then restart PureBasic. Then, when you want to format a string, do this:

Code: Select all

 Function 1 : a$=Using("#0-+",number)
 -----------
 Definition : Format a number as a string.
   # : Digit or space
   0 : Digit or 0
   + : Sign of the number (print '+' if positive, '-' if negative)
   - : Sign of the number (print space if positive instead of '+', and '-' if negative)

 Attention : - If the format string if shorter than the total of digits in Number,
             number will not be printed totally.
             - A negative number will not be show with his "-" unless you specify it.

 Examples :
     Using("### ###",12325)          = " 12 325"
     Using("000 ### $",12325)        = "012 325 $"
     Using("###-,12)                 = " 12 "
     Using("0##+,-12)                 = "012-"
     Using("I'm ## Years Old",31)    = "I'm 31 Years Old"

 This function is not finished. For the moment it only handle INTEGER,
 (as PB doesn't handle Floats for the moment... Will be completed as soon as possible)

PB - Registered PureBasic Coder
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by OlliB.

That's great!

Thank you,

Olli
Post Reply