Sign in to follow this  
Followers 0
Rad

String Format(help)

6 posts in this topic

Im trying to make this program calculate the total cost of a bunch of prices after you click on them, but when you have a price as 12.00 it will result 12. So I tried using stringformat but its to complicated... And the helpfile SUCKS!

$s =StringFormat ( "var1=%s var2=%.2f, var3=%d" ,$string, $float, $int )
$msgbox(0, "Result", $s)
; will output        "var1=string var2=12.30 var3=345"

Thats the helpfile, what the hell is it talking about? Thats not formatting string thats doing to many different things at once!

If $msg=$price[0] OR $msg=$price[1] OR $msg=$price[2] OR $msg=$price[3] Then
            $ib=0
            For $i=0 To 3 Step +1
                    $ib=$ib+StringFormat("%.2f",GUICtrlRead($price[$i])*GUICtrlRead($quantity[$i]))
            Next
            GUICtrlSetData($total,$ib)
    Endif

Thats what I have right now, I dont really get what how to use it. I dont see how "var1=%s.." has ANYTHING to do with formatting a string :lmao:

Share this post


Link to post
Share on other sites



Im trying to make this program calculate the total cost of a bunch of prices after you click on them, but when you have a price as 12.00 it will result 12. So I tried using stringformat but its to complicated... And the helpfile SUCKS!

Actually the helpfile is quite useful, and probably the best there is for languages in it's simplicity. It's probably your interpretation that 'SUCKS'!

These guys didn't need to take their time and explain things in detail like they do, but they do it anyway. Show some respect!


[center]Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.[/center]

Share this post


Link to post
Share on other sites

Well I mean that example sucks, the helpfile is useful yes but it has to much information and doesnt explain alot... The example shows "var1=%.2f",$var,var and it doesnt explain whats going on....

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

$float = 12.3

$s = StringFormat ( "%.2f", $float)

msgbox(0, "Result", $s) ;returns 12.30

and just to say...i really didn't understand the help for that function either...it look me a few minutes...and a trial to understand it

here is what i "think" is right

$s =StringFormat ( "var1=%s var2=%.2f, var3=%d" ,$string, $float, $int )

the var1= , var2=, var3= are just lables it adds into the sting, each % uses a new variable and what comes after is the format of that variable (ex, %s is $string formated as string, %.2f is $float formatted as a float with 2 places after the decimal, and %d is $int formatted as a decimal)

and based on this

StringFormat ( "format control", var1 [, ... var32] )

it looks like you can have 32 seperate variables

Edited by ACalcutt

Andrew Calcutt

Http://www.Vistumbler.net

Http://www.TechIdiots.net

Its not an error, its a undocumented feature

Share this post


Link to post
Share on other sites

FINALLY I figured it out, and no I only needed a single variable if I needed multiple I could simply loop with For...To...Step......Next, lol

You do it like:

GUICtrlSetData($price[$i],StringFormat("%.2f",GUICtrlRead($price[$i])))

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

... And the helpfile SUCKS!

Positive contributions are always welcome, so looking forward to your proposed update ... :lmao:

Edited by JdeB

Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0