Jump to content

Recommended Posts

Posted

Hey guys,

i use this function a lot, when performing actions on remote computers.

computers are named:

xxx-Room-01

and so forth.

at the moment, whenever i create a For Next statement, i do the following:

For $x = 8 to 11
    $add0 = StringLen($x)
    If $add0 = 1 Then $x = String("0"&$x)
MsgBox(0, "hellow World", $x)
Next

is there any way to do this, and use less code ?

  • Moderators
Posted (edited)

Hey guys,

i use this function a lot, when performing actions on remote computers.

computers are named:

xxx-Room-01

and so forth.

at the moment, whenever i create a For Next statement, i do the following:

For $x = 8 to 11
    $add0 = StringLen($x)
    If $add0 = 1 Then $x = String("0"&$x)
MsgBox(0, "hellow World", $x)
Next

Edit:

That's kind of funny... like a machine going off with answers.

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

no... we run around 200 last count.

but each is in a different lab.. an no lab is over 30.. so 2 digits is fine.

thanks for the help guys, i had worked it into one line myself just after asking, i had this:

For $x = 8 to 11
If StringLen($x) = 1 Then $x = String("0"&$x)
MsgBox(0, "hellow World", $x)
Next

so i compressed my two lines into one, bu i guess the more proffessional way to go would be the string format.

Cheers

/tAK

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
×
×
  • Create New...