Is there a text formating command like USING() in PB. I've not been able to locate it.
Here's how it works: P = USING("###.#", value.f)
so if value = 4.3452 then P will be 4.3.
This gives you a nice column when you print too.
Also, is there a Round() command that allows you to specify the number of decimals to round to?
Print Using() / Round()
-
PB&J Lover
- Enthusiast

- Posts: 212
- Joined: Fri Apr 22, 2005 2:07 pm
- Location: U.S.A.
- Contact:
Print Using() / Round()
-- DB
Any intelligent fool can make things bigger, more complex, and more violent. It takes a touch of genius — and a lot of courage — to move in the opposite direction.
Albert Einstein
Any intelligent fool can make things bigger, more complex, and more violent. It takes a touch of genius — and a lot of courage — to move in the opposite direction.
Albert Einstein
There is a userlib called PrintUsing which should do the job :
http://www.purearea.net/pb/download/use ... tUsing.zip
[edit]
Alternately, there is an updated version by Danilo of the SkunkLib which
also includes a PrintUsing :
http://www.purearea.net/pb/download/use ... unklib.zip
[/edit]
http://www.purearea.net/pb/download/use ... tUsing.zip
[edit]
Alternately, there is an updated version by Danilo of the SkunkLib which
also includes a PrintUsing :
http://www.purearea.net/pb/download/use ... unklib.zip
[/edit]
regards,
benny!
-
pe0ple ar3 str4nge!!!
benny!
-
pe0ple ar3 str4nge!!!
-
PB&J Lover
- Enthusiast

- Posts: 212
- Joined: Fri Apr 22, 2005 2:07 pm
- Location: U.S.A.
- Contact:
libraries
Thanks.
How do you use a library?
Is there something for rounding numbers to a specific decimal?
What's all in the SkunkLib?
How do you use a library?
Is there something for rounding numbers to a specific decimal?
What's all in the SkunkLib?
-- DB
Any intelligent fool can make things bigger, more complex, and more violent. It takes a touch of genius — and a lot of courage — to move in the opposite direction.
Albert Einstein
Any intelligent fool can make things bigger, more complex, and more violent. It takes a touch of genius — and a lot of courage — to move in the opposite direction.
Albert Einstein
Re: libraries
You are welcomedbwisc wrote:Thanks.
Just copy the Lib (the file with no suffix) in your:dbwisc wrote:How do you use a library?
[...]/PureBasic/PureLibraries/Userlibraries/
Folder. Important is that you have to restart the compiler before
you want to use the new commands
Try Num3's trick.dbwisc wrote:Is there something for rounding numbers to a specific decimal?
In this version there are just the two commandsdbwisc wrote:What's all in the SkunkLib?
- StripAll(chain$ , search$ ) - Delete all the occurences of a string on
another string
-Using( "#0-+" , number ) - Format a number as a string
Generally, every lib has a .chm-Help file included which gives a detailed
description of every command.
You can find numerous userlibs on PureArea.net :
http://www.purearea.net
regards,
benny!
-
pe0ple ar3 str4nge!!!
benny!
-
pe0ple ar3 str4nge!!!
-
PB&J Lover
- Enthusiast

- Posts: 212
- Joined: Fri Apr 22, 2005 2:07 pm
- Location: U.S.A.
- Contact:
Skunk Using() ERROR
There are no examples in the Skunklib for using decimals. When I tried them I got strange results.
This:
Should not return this: " . 3"
The other one gave me all kinds of linking errors, so I'm 0 to 2.
But thanks.
This:
Code: Select all
Debug Using("#.##",3.456)The other one gave me all kinds of linking errors, so I'm 0 to 2.
But thanks.
-- DB
Any intelligent fool can make things bigger, more complex, and more violent. It takes a touch of genius — and a lot of courage — to move in the opposite direction.
Albert Einstein
Any intelligent fool can make things bigger, more complex, and more violent. It takes a touch of genius — and a lot of courage — to move in the opposite direction.
Albert Einstein
@dbwisc:
You are right ... I never used those libs - I just know of their existence.
However they do not seem to support floats. I am sorry for any inconveniences.
Hmm ... guess someone has to write a proper routine for this case. Like
parsing the pattern and apply the float-string to it ...
A did a quick try - it contains a lot of bugs and unchecked exceptions :
You are right ... I never used those libs - I just know of their existence.
However they do not seem to support floats. I am sorry for any inconveniences.
Hmm ... guess someone has to write a proper routine for this case. Like
parsing the pattern and apply the float-string to it ...
A did a quick try - it contains a lot of bugs and unchecked exceptions :
Code: Select all
; Print Using work-around
; May 2oo5 by benny!
;
; Note:
; Just a quick test!
; No syntax checking and so on ...
Procedure.s UsingF( fvalue.f, p$)
a$ = StrF( fvalue.f )
vMid.l = FindString( a$, ".", 1 )
pMid.l = FindString( p$, ".", 1 )
;prefix part
frA$ = Mid( a$, 1, vMid.l - 1 )
frP$ = Mid( p$, 1, pMid.l - 1 )
frA$ = Using( frP$, Val( frA$ ) )
;suffix part
suA$ = Mid( a$, vMid.l + 1, Len(a$) - vMid.l )
suP$ = Mid( p$, pMid.l + 1, Len(p$) - pMid.l )
If Len( suA$ ) = Len( suP$ )
ProcedureReturn frA$+"."+suA$
ElseIf Len( suA$ ) > Len( suP$ )
ProcedureReturn frA$+"."+Left(suA$, Len( suP$ ) )
Else
ProcedureReturn frA$+"."+Using ( suA$, Val ( suP$ ) )
EndIf
EndProcedure
Debug UsingF(201.13, "0000.000")
Debug UsingF(20012.3012, "0000000000.0")regards,
benny!
-
pe0ple ar3 str4nge!!!
benny!
-
pe0ple ar3 str4nge!!!
