Jump to content
Sign in to follow this  
sebsabul

Goto command

Recommended Posts

sebsabul

Hello guys, need some help please.

Here is my script:

#include <array.au3>

#NoTrayIcon

Opt("TrayMenuMode",1)

$exititem = TrayCreateItem("Exit")

TraySetIcon("Shell32.dll",166)

AdlibEnable("myadlib", 1)

$var = IniRead("C:\Windows\System\status.ini", "section2", "key", "NotFound")

sleep(20000)

While 1

sleep (20000)

Ping("192.168.0.3", 20000)

If @error = 0 Then

RunWait(@ComSpec & " /c arp.exe -a > " & @TempDir & "\arplog.txt", "", @SW_HIDE)

$fic = FileOpen(@TempDir & "\arplog.txt", 0)

If $fic = -1 Then Exit

$index = 4

$tab_mac = ""

While 1

$line = FileReadLine($fic, $index)

If @error = -1 Then ExitLoop

$mac = StringMid($line, 25, 17)

$tab_mac = $tab_mac & $mac & ";"

$index = $index + 1

WEnd

$tab_mac = StringSplit($tab_mac, ";")

For $x = 1 to $tab_mac[0]

if $tab_mac[$x] = "00-50-8d-52-35-87" then

else

Call ( "myfunc" )

EndIf

Next

Else

EndIf

Wend

While 1

sleep (20000)

Ping("192.168.0.3", 20000)

If @error = 0 Then

RunWait(@ComSpec & " /c arp.exe -a > " & @TempDir & "\arplog.txt", "", @SW_HIDE)

$fic = FileOpen(@TempDir & "\arplog.txt", 0)

If $fic = -1 Then Exit

$index = 4

$tab_mac = ""

While 1

$line = FileReadLine($fic, $index)

If @error = -1 Then ExitLoop

$mac = StringMid($line, 25, 17)

$tab_mac = $tab_mac & $mac & ";"

$index = $index + 1

WEnd

$tab_mac = StringSplit($tab_mac, ";")

For $x = 1 to $tab_mac[0]

if $tab_mac[$x] = "00-50-8d-52-35-87" then

Call("myfunc3")

;goto loop 1/beginn the programm from start ------------------------> HERE

else

EndIf

Next

Else

EndIf

Wend

Func myfunc()

$var = IniRead("C:\Windows\System\status.ini", "section2", "key", "NotFound")

Sleep(5000)

Ping("192.168.0.3", 20000)

If @error = 0 Then

RunWait(@ComSpec & " /c arp.exe -a > " & @TempDir & "\arplog.txt", "", @SW_HIDE)

$fic = FileOpen(@TempDir & "\arplog.txt", 0)

If $fic = -1 Then Exit

$index = 4

$tab_mac = ""

While 1

$line = FileReadLine($fic, $index)

If @error = -1 Then ExitLoop

$mac = StringMid($line, 25, 17)

$tab_mac = $tab_mac & $mac & ";"

$index = $index + 1

WEnd

$tab_mac = StringSplit($tab_mac, ";")

For $x = 1 to $tab_mac[0]

if $tab_mac[$x] = "00-50-8d-52-35-87" then

else

call("myfunc2")

EndIf

Next

Else

EndIf

EndFunc

Func myfunc2()

If $var = "disabled" Then

ProcessClose ( "status.exe" )

Runwait("C:\Windows\System\enabled.exe")

Endif

EndFunc

Func myfunc3()

If $var = "enabled" Then

Runwait("C:\Windows\System\status.exe")

Endfunc

Func myadlib()

$msg2 = TrayGetMsg()

If $msg2 = $exititem Then Exit

EndFunc

On the marked point, i will go back to the loop1 /the start; but how without a "goto" command Thank you for help!

Share this post


Link to post
Share on other sites
Jos

just put a While 1 .. Wend loop around it and do an exitloop ..

You are missing an endif in the myfunc3 function.. see below errors generated with Tidy...

#include <array.au3>
#NoTrayIcon
opt("TrayMenuMode", 1)
$exititem = TrayCreateItem ("Exit")
TraySetIcon ("Shell32.dll", 166)
AdlibEnable("myadlib", 1)
$var = IniRead("C:\Windows\System\status.ini", "section2", "key", "NotFound")
Sleep(20000)
While 1
    While 1
        Sleep(20000)
        Ping("192.168.0.3", 20000)
        If @error = 0 Then
            RunWait(@ComSpec & " /c arp.exe -a > " & @TempDir & "\arplog.txt", "", @SW_HIDE)
            $fic = FileOpen(@TempDir & "\arplog.txt", 0)
            If $fic = -1 Then Exit
            $index = 4
            $tab_mac = ""
            While 1
                $line = FileReadLine($fic, $index)
                If @error = -1 Then ExitLoop
                $mac = StringMid($line, 25, 17)
                $tab_mac = $tab_mac & $mac & ";"
                $index = $index + 1
            WEnd
            $tab_mac = StringSplit($tab_mac, ";")
            For $x = 1 To $tab_mac[0]
                If $tab_mac[$x] = "00-50-8d-52-35-87" Then
                Else
                    Call("myfunc")
                EndIf
            Next
        Else
        EndIf
    WEnd
    While 1
        Sleep(20000)
        Ping("192.168.0.3", 20000)
        If @error = 0 Then
            RunWait(@ComSpec & " /c arp.exe -a > " & @TempDir & "\arplog.txt", "", @SW_HIDE)
            $fic = FileOpen(@TempDir & "\arplog.txt", 0)
            If $fic = -1 Then Exit
            $index = 4
            $tab_mac = ""
            While 1
                $line = FileReadLine($fic, $index)
                If @error = -1 Then ExitLoop
                $mac = StringMid($line, 25, 17)
                $tab_mac = $tab_mac & $mac & ";"
                $index = $index + 1
            WEnd
            $tab_mac = StringSplit($tab_mac, ";")
            For $x = 1 To $tab_mac[0]
                If $tab_mac[$x] = "00-50-8d-52-35-87" Then
                    Call("myfunc3")
                    ExitLoop;goto loop 1/beginn the programm from start ------------------------> HERE
                Else
                EndIf
            Next
        Else
        EndIf
    WEnd
WEnd
Func myfunc()
    $var = IniRead("C:\Windows\System\status.ini", "section2", "key", "NotFound")
    Sleep(5000)
    Ping("192.168.0.3", 20000)
    If @error = 0 Then
        RunWait(@ComSpec & " /c arp.exe -a > " & @TempDir & "\arplog.txt", "", @SW_HIDE)
        $fic = FileOpen(@TempDir & "\arplog.txt", 0)
        If $fic = -1 Then Exit
        $index = 4
        $tab_mac = ""
        While 1
            $line = FileReadLine($fic, $index)
            If @error = -1 Then ExitLoop
            $mac = StringMid($line, 25, 17)
            $tab_mac = $tab_mac & $mac & ";"
            $index = $index + 1
        WEnd
        $tab_mac = StringSplit($tab_mac, ";")
        For $x = 1 To $tab_mac[0]
            If $tab_mac[$x] = "00-50-8d-52-35-87" Then
            Else
                Call("myfunc2")
            EndIf
        Next
    Else
    EndIf
EndFunc  ;==>myfunc
Func myfunc2()
    If $var = "disabled" Then
        ProcessClose("status.exe")
        RunWait("C:\Windows\System\enabled.exe")
    EndIf
EndFunc  ;==>myfunc2
Func myfunc3()
    If $var = "enabled" Then
        RunWait("C:\Windows\System\status.exe")
;### Tidy Error: Level error -> EndFunc is closing previous If
    EndFunc  ;==>myfunc3
;### Tidy Error: Level error -> "Func" Not closed before Func statement.
;### Tidy Error: Level error -> "Func" cannot be inside any IF/Do/While/For/Case/Func statement.
    Func myadlib()
        $msg2 = TrayGetMsg ()
        If $msg2 = $exititem Then Exit
    EndFunc  ;==>myadlib

Visit the SciTE4AutoIt3 Download page for the latest versions  - Beta files                                How to post scriptsource        Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

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  

×