Jump to content

Recommended Posts

Posted (edited)

Hi all,

Sorry for my bad english, I'm french.

I have a problem with a loop "For", I try to change the end parameter during the loop, but it does not work.

It's possible to change the end parameter during the loop ? If yes can you help me ?

This is my code (Normally, it should make an infinite loop):

It takes as a end parameter, the array size. Each loop, increment the array size, so the end parameter too.

Global $array[2]
Global $loop = 0

$end = UBound($array)

For $i = 1 To $end
    $loop += 1
    ConsoleWrite("loop : " & $loop & @CRLF)
    ReDim $array[UBound($array) + 1]
    $end = UBound($array)
Next
Edited by NeuroToxic
Posted

Try with a 'custom made' For loop using While Wend.

Global $array[2]
Global $loop = 0

$end = UBound($array)
$i=1
While $i <= $end
    $loop += 1
    ConsoleWrite("loop : " & $loop & @CRLF)
    ReDim $array[UBound($array) + 1]
    $end = UBound($array)
    $i+=1
WEnd
How is either that or the OP's loop not infinite...?

:)

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Posted

How is either that or the OP's loop not infinite...?

:P

:) I'm confused... he wanted to modify the value of $end inside the loop, which is what I did. He said Normally, it should make an infinite loop, so I thought he wanted an infinite loop...

Posted

:) I'm confused... he wanted to modify the value of $end inside the loop, which is what I did. He said Normally, it should make an infinite loop, so I thought he wanted an infinite loop...

I figured that meant until a conditional statement did ExitLoop, or some such. Otherwise the script "Normally" crashes eventually with subscript out of bounds error.

:P

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Posted

I figured that meant until a conditional statement did ExitLoop, or some such. Otherwise the script "Normally" crashes eventually with subscript out of bounds error.

:)

His loop isn't infinite... it ends after two loops.

Anyway, I just thought he wanted to figure out a way of modifying the conditional variable in a loop... so I gave him an idea :P

Posted

His loop isn't infinite... it ends after two loops.

Doh! :)

I missed that in the help file:

If stepVal or stop is a variable, its value is only read the first time the loop executes.

You were right.

:P

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

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...