Sign in to follow this  
Followers 0
mentosan

"select ...case" instead of "goto"

2 posts in this topic

I'm having this code :

#include <file.au3>

Dim $ipfile="host.txt"
Dim $ipaddress

_FileReadToArray ($ipfile, $ipaddress)

$handle=fileopen(@ScriptDir & "\host.txt",0)
$MyLine=filereadline($handle) 
fileclose($handle)
$SplitArr=StringSplit($MyLine," ")
$IP=$SplitArr[1]

Select
Case Ping ($IP)
Run ("telnet -f log_telnet.txt")

WinActivate("system32")
WinWaitActive("system32")

Send ("open " & $ipaddress[1] & "{Enter}")
Send ("{Enter}")

While 1
Sleep (2000)
ControlSend ("Telnet","","","x" & "{Enter}")
Wend

Case Else
MsgBox(0,"Info -" & $IP, "No ping", 3)
EndSelect

The script will connect to a telnet session and will execute a command in a loop, every 2 secs. But first it will check if ping is OK, otherwise it will return an error message for 3 seconds and then it will exit. The problem is, in this case, I don't want the script to exit. I want to restart the pinging (beginning of the script). I'm using "Select...Case" but unsuccesful. Please help

Share this post


Link to post
Share on other sites



I'm having this code :

#include <file.au3>

Dim $ipfile="host.txt"
Dim $ipaddress

_FileReadToArray ($ipfile, $ipaddress)

$handle=fileopen(@ScriptDir & "\host.txt",0)
$MyLine=filereadline($handle) 
fileclose($handle)
$SplitArr=StringSplit($MyLine," ")
$IP=$SplitArr[1]

Select
Case Ping ($IP)
Run ("telnet -f log_telnet.txt")
WWinActivate("system32")
WinWaitActive("system32")

Send ("open " & $ipaddress[1] & "{Enter}")
Send ("{Enter}")

While 1
Sleep (2000)
ControlSend ("Telnet","","","x" & "{Enter}")
Wend

Case Else
MsgBox(0,"Info -" & $IP, "No ping", 3)
EndSelect

The script will connect to a telnet session and will execute a command in a loop, every 2 secs. But first it will check if ping is OK, otherwise it will return an error message for 3 seconds and then it will exit. The problem is, in this case, I don't want the script to exit. I want to restart the pinging (beginning of the script). I'm using "Select...Case" but unsuccesful. Please help

You could just have

while 1
   Select
.
.
   EndSelect
Wend

Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.

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