Jump to content
UBot Underground

How To Exit Loop While Immediately When The 'while' Condition Fails


Recommended Posts

In my script, I have a Loop While command that executes so long as an element exists on the page. After completing a Google search, the script scrapes an element from the page and adds it to a table.

 

The problem I'm running into is that the Loop does not stop immediately when the 'While' condition fails. For example:

 

set(#smoothSailing,$true,"Global")
loop while(#smoothSailing) {
    type text(<username field>,"Smooth Sailing is True","Standard")
    set(#smoothSailing,$false,"Local")
    type text(<about me textarea>,"This should not be entered since smoothSailing was set to false.","Standard")
}

 

It appears the Loop While command only does the 'While' check at the beginning of the loop, it does not do the check while the loop is running. Is there any way to stop a loop immediately when a condition is no longer true? I tried using the 'return' command, however that will not only stop the current loop but it also stops the parent loop, which is not what I want.

 

Any help or direction on how to stop a loop immediately would be very much appreciated!

Link to post
Share on other sites

Be difficult
Unless you kill Thread (using plugins).

Likewise, there is a simple solution, but it may take several lines of code.
Is the division of work.

set(#smoothSailing,$true,"Global")
loop while(#smoothSailing) {
    if(#smoothSailing) {
        then {
            type text(<username field>,"Smooth Sailing is True","Standard")
        }
        else {
        }
    }
    set(#smoothSailing,$false,"Local")
    if(#smoothSailing) {
        then {
            type text(<about me textarea>,"This should not be entered since smoothSailing was set to false.","Standard")
        }
        else {
        }
    }
}
  • Like 1
Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...