Sign in to follow this  
Followers 0
jang

Hi, Defining Variables

6 posts in this topic

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

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

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

[center]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.[/center]

Share this post


Link to post
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

Share this post


Link to post
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)

Share this post


Link to post
Share on other sites

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.

[center]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.[/center]

Share this post


Link to post
Share on other sites

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

Thanks it's fully working.

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  
Followers 0