Jump to content
Sign in to follow this  
Jack_10

number format ( 0 or 0.0 or 0.00 etc)

Recommended Posts

Jack_10

hey !

How can i change number format (standard is without decimal point if numer is integer type)

example :

Dim $x

$x = 2.3333

$x = Int($x)

MsgBox(0, "x", "$x = " & $x) ; x = 2 , but i wanna x = 2.0000

Dim $x

$x = 2.0

$x = Int($x)

MsgBox(0, "x", "$x = " & $x) ; x = 2 , but i wanna x = 2.0

I need in my program function IsInt to round() down numbers , but also need *.000 after integer number :P

Share this post


Link to post
Share on other sites
SmOke_N

Dim $x
$iZeros = 4
$x = 2.3333
$x = Int($x)
MsgBox(0, "x", "$x = " & StringFormat('%.' & $iZeros & 'f', $x)); x = 2 , but i wanna x = 2.0000

Dim $x
$iZeros = 1
$x = 2.0
$x = Int($x)
MsgBox(0, "x", "$x = " & StringFormat('%.' & $iZeros & 'f', $x)); x = 2 , but i wanna x = 2.0

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.

Share this post


Link to post
Share on other sites
SmOke_N

Your welcome, a suggestion I might make is if you are going to use this in various places, rather than typing it out over and over since it involves some text is to just make it into a simple function:

Dim $x
$x = 2.0
$x = Int($x)
MsgBox(0, "x", "$x = " & _Convert(4, $x))

Func _Convert($iNum, $vVar)
    Return StringFormat('%.' & $iNum & 'f', $vVar)
EndFuncoÝ÷ ÛÞx-éî·«¡üÞ®Á©íiû^®Ø^"©ZÝ7ë¾*.²z)දj²0j{m¡Ú"·­Gb´êâ*.ßÚÞjÊÈ(x-¢f¤z+Z)íz«~*쵫­¢+Ù¥´ÀÌØíà(ÀÌØíàôȸÀ)5Í  ½à À°ÅÕ½ÐíàÅÕ½Ðì°ÅÕ½ÐìÀÌØíàôÅÕ½ÐìµÀì}
½¹ÙÉРаÀÌØíत()Õ¹}
½¹ÙÉÐ ÀÌØí¥9Õ´°ÀÌØíÙYȤ(%IÑÕɸMÑÉ¥¹½ÉµÐ Ìäì¸ÌäìµÀìÀÌØí¥9Õ´µÀìÌäíÌäì°%¹Ð ÀÌØíÙYȤ¤)¹Õ¹

Edited by SmOke_N

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.

Share this post


Link to post
Share on other sites
Jack_10

great !

btw

what is difrence between ( ' ) and ( " )

i have used both of them in code and both work !!! :P

1st

MsgBox(0, "x", "$x = " & StringFormat('%.' & $iZeros & 'f', $x))

2nd

MsgBox(0, "x", "$x = " & StringFormat("%." & $iZeros & "f", $x))

Edited by Jack_10

Share this post


Link to post
Share on other sites
Valuater

you can create lines with the " in it using '"'... example

MsgBox(64, "Test", 'This word has "quotes"')

8)

Edited by Valuater

NEWHeader1.png

Share this post


Link to post
Share on other sites
SmOke_N

I'm just too lazy... It's 1 less key stroke to use a single quote vs. a double :P ... But as far as syntax, nothing is different until you need to add quotes within quotes for strings. (as I think Valuater was trying to demonstrate but looks like the code tags ate it).


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.

Share this post


Link to post
Share on other sites
Valuater

yea... your right... the code tags did

will fix now

8)


NEWHeader1.png

Share this post


Link to post
Share on other sites
Jack_10

is there any difrence when i write my own function

Func xxx()

.......

EndFunc

at the begginig of the script or at the end of script ?

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  

×