Jump to content

Hi, Defining Variables


Recommended Posts

If I define something like

$previous = object

$number = 1

$next = $previous & $number

$stop = 1

While $stop=1

If FileExists ($next) Then

$Previous = $next

$number = $number + 1

Else

$stop = 0

Return $previous

EndIf

My question is when the program ends will $previous be equal to $next at the time $previous was defined, or will it have the new $number?

thanks

Link to comment
Share on other sites

  • Moderators

No, but maybe sticking next = in the loop will do the trick:

$previous = object
$number = 1
$stop = 1
While $stop = 1
    $next = $previous & $number
    If FileExists($next) Then
;$Previous = $next
        $number = $number + 1
    Else
        $stop = 0
        Return $previous
    EndIf
WEnd

Edit:

I don't know if you should use $Previous = $next to be honest... Of course, I have no idea what your doing with it.

Edit2:

Run these to see what I'm saying:

;With
$previous = "Blah"
$number = 1
$stop = 1
While $stop = 1
    $next = $previous & $number
    If $previous <> '' Then;FileExists($next) Then
        $Previous = $next
        $number = $number + 1
    Else
        $stop = 0
        Return $previous
    EndIf
    MsgBox(0, '', $next)
WEnd

;Without
$previous = "Blah"
$number = 1
$stop = 1
While $stop = 1
    $next = $previous & $number
    If $previous <> '' Then;FileExists($next) Then
        $number = $number + 1
    Else
        $stop = 0
        Return $previous
    EndIf
    MsgBox(0, '', $next)
WEnd
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.

Link to comment
Share on other sites

No, but maybe sticking next = in the loop will do the trick:

$previous = objectMy intention is to actually keep the the previous at the time it was defined so I guess it works, thx
Link to comment
Share on other sites

Try this:

$name = "object"
$number = 1
$stop = 1
While $stop = 1
    $next = $name & $number
    If FileExists($next) Then
        $Previous = $next
        $number = $number + 1
    Else
        $stop = 0
    EndIf
WEnd
MsgBox(0, "", $Previous)
Link to comment
Share on other sites

  • Moderators

My intention is to actually keep the the previous at the time it was defined so I guess it works, thx

Ok, well, my suggestion is to run the examples I just edited, so you can actually get an idea of what's happening.

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.

Link to comment
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
 Share

  • Recently Browsing   0 members

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