Jump to content

Recommended Posts

Posted

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

  • Moderators
Posted

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.

  • Moderators
Posted (edited)

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.

Posted (edited)

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
  • Moderators
Posted

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.

Posted

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 ?

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
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...