Sign in to follow this  
Followers 0
turbox

Help with an if statement

12 posts in this topic

#1 ·  Posted (edited)

i have an if statement. How i can write the resumefromline 7 with code?

1. if x=0 then

2.resumefromline 7

3.else

4.endif

5.

6.

7.

Edited by vakis

Share this post


Link to post
Share on other sites



you could place a nested if ... endif statement or, which is probably not possible, move the endif to line 7(which should be the solution for this oversimplified example)


In the beginning there was nothing and then even that exploded - anonymous

Share this post


Link to post
Share on other sites

if $checkstring = 0 Then
Else
    EndIf
Next
$aIE = _IENavigate($aIE, $link.href)
_IELoadWait($aIE)
$bIE = _IECreate("http://xxx")
_IELoadWait($bIE)
WinClose($aIE)
WinSetState ( "xxx", "", @sw_maximize)
For $itab = 9 to 20 step 1
    $frame2 = _IEFrameGetCollection($bIE, "main")
    $tableget2 = _IETableGetCollection($frame2, $itab)
    $array = _IETableWriteToArray($tableget2)
    $arrsearch = _ArraySearch($array, "xxx")
    IF @error Then
    Else
        ExitLoop
    EndIf
    Next
    MsgBox(0, "", $itab)
_FileCreate(@TempDir & "\a.cmd")
$Fileopen = FileOpen(@TempDir & "\a.cmd", 1)
FileWrite($Fileopen, "at " & $finishtime & " /interactive " & @ScriptFullPath)
FileClose($Fileopen)
run(@TempDir & "\a.cmd")
sleep(444)
FileDelete(@TempDir & "\a.cmd")

From the first if i want then to go to the _Filecreate

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

while 1
    if $checkstring = 0 Then
        ExitLoop
    Else
    
    EndIf
    Next
    $aIE = _IENavigate($aIE, $link.href)
    _IELoadWait($aIE)
    $bIE = _IECreate("http://xxx")
    _IELoadWait($bIE)
    WinClose($aIE)
    WinSetState ( "xxx", "", @sw_maximize)
    For $itab = 9 to 20 step 1
        $frame2 = _IEFrameGetCollection($bIE, "main")
        $tableget2 = _IETableGetCollection($frame2, $itab)
        $array = _IETableWriteToArray($tableget2)
        $arrsearch = _ArraySearch($array, "xxx")
        IF @error Then
        Else
            ExitLoop
        EndIf
    Next
    MsgBox(0, "", $itab)
    ExitLoop
Wend
_FileCreate(@TempDir & "\a.cmd")
$Fileopen = FileOpen(@TempDir & "\a.cmd", 1)
FileWrite($Fileopen, "at " & $finishtime & " /interactive " & @ScriptFullPath)
FileClose($Fileopen)
run(@TempDir & "\a.cmd")
sleep(444)
FileDelete(@TempDir & "\a.cmd")

Be careful with the exitloop as I guess that you have additional loops, so maybe you have to give the level of the loop you want to exit

edit: layout

Edited by DMEE

In the beginning there was nothing and then even that exploded - anonymous

Share this post


Link to post
Share on other sites

can you tell me what 1 after while means?

Share this post


Link to post
Share on other sites

It needs wend according to syntax check

Share this post


Link to post
Share on other sites

with

for $a=1 to 1 step 1
    if $checkstring = 0 Then
        ExitLoop
    Else
   
    EndIf
    Next
    $aIE = _IENavigate($aIE, $link.href)
    _IELoadWait($aIE)
    $bIE = _IECreate("http://xxx")
    _IELoadWait($bIE)
    WinClose($aIE)
    WinSetState ( "xxx", "", @sw_maximize)
    For $itab = 9 to 20 step 1
        $frame2 = _IEFrameGetCollection($bIE, "main")
        $tableget2 = _IETableGetCollection($frame2, $itab)
        $array = _IETableWriteToArray($tableget2)
        $arrsearch = _ArraySearch($array, "xxx")
        IF @error Then
        Else
            ExitLoop
        EndIf
    Next
    MsgBox(0, "", $itab)
    ExitLoop
next
_FileCreate(@TempDir & "\a.cmd")
$Fileopen = FileOpen(@TempDir & "\a.cmd", 1)
FileWrite($Fileopen, "at " & $finishtime & " /interactive " & @ScriptFullPath)
FileClose($Fileopen)
run(@TempDir & "\a.cmd")
sleep(444)
FileDelete(@TempDir & "\a.cmd")

i think works

Share this post


Link to post
Share on other sites

to answer your questions:

- the 1 means an infinite loop, which you should always exit with an exitloop or return or..

- the wend is indeed needed, but I did provide that.

- you have a next in your own code at line 7. This should not interfere with the loop that I wrapped around the if statement.


In the beginning there was nothing and then even that exploded - anonymous

Share this post


Link to post
Share on other sites

#9 ·  Posted (edited)

to answer your questions:

- the 1 means an infinite loop, which you should always exit with an exitloop or return or..

- the wend is indeed needed, but I did provide that.

- you have a next in your own code at line 7. This should not interfere with the loop that I wrapped around the if statement.

Your "code" is terrible.

You have put in a Next keyword without a for loop.

Just before the "infinite loop" is about to start over you use ExitLoop, and since I don't see any ContinueLoop anywhere that means that the loop will only be executed once thus making it useless.

And why are you using WinClose on a internet explorer object?

I would suggest you test code before posting it so the OP doesn't get anymore confused than he already is.

Just a few tips :P

Edited by monoceres

Broken link? PM me and I'll send you the file!

Share this post


Link to post
Share on other sites

I agree that the code is terrible, but it is the posted snippet that I used, the solution is just a usual way how to code if you don't use the "goto" statement that was asked for.

In general the need for a goto means need for a better program design. That is something we cannot answer to when no intentions nor a complete function is given.

Actually I didn't look through the rest of the code, just to the statements that I offered as a solution. But I agree that just a few additional tips would be very helpful.

@Vakis: If you tell what you want to do with a program, you can get more help than you will ask for. You can gain knowledge for "free".


In the beginning there was nothing and then even that exploded - anonymous

Share this post


Link to post
Share on other sites

It's tough to tell what you're trying to do from your pseudocode, but if you really want to perform "#7" when the loop does not encouter an error, and then perform it one more time once the loop is exited, you might want to make the portion you'll be repeating into a user-defined function, such as:

Func Process_File()
    _FileCreate(@TempDir & "\a.cmd")
    $Fileopen = FileOpen(@TempDir & "\a.cmd", 1)
    FileWrite($Fileopen, "at " & $finishtime & " /interactive " & @ScriptFullPath)
    FileClose($Fileopen)
EndFunc

Then your pseudocode would look something like:

1) First loop

1a) For...

1b) Next

2) Second Loop

2a) For...

2b) If Not @error Then Process_File()

2c) Next

3) Process_File()

4) Exit

Share this post


Link to post
Share on other sites

it is a bot for tribal wars

if jobs are full then schedule when the program run again to have one free job

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