Sign in to follow this  
Followers 0
NeuroToxic

redefine loop parameters

8 posts in this topic

#1 ·  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

Share this post


Link to post
Share on other sites



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

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

:) 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

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

#8 ·  Posted (edited)

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
Thank you, its work :) Edited by NeuroToxic

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