Rad Posted January 21, 2006 Posted January 21, 2006 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
Moderators SmOke_N Posted January 21, 2006 Moderators Posted January 21, 2006 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! 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.
Rad Posted January 21, 2006 Author Posted January 21, 2006 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....
ACalcutt Posted January 21, 2006 Posted January 21, 2006 (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 January 21, 2006 by ACalcutt Andrew Calcutt Http://www.Vistumbler.net Http://www.TechIdiots.net Its not an error, its a undocumented feature
Rad Posted January 21, 2006 Author Posted January 21, 2006 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])))
Developers Jos Posted January 21, 2006 Developers Posted January 21, 2006 (edited) ... And the helpfile SUCKS!Positive contributions are always welcome, so looking forward to your proposed update ... Edited January 21, 2006 by JdeB SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past.
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now