Jump to content

Recommended Posts

  • Moderators
Posted

grimmlock,

Two points on that code

- 1. When do you ever change the value of $PID? If it never changes than you will never exit the Do...Until loop.

- 2. Why do yo think Ping returns a PID? When I look in the Help file it talks about returning the "the roundtrip-time in milliseconds.

Have a think about those and see if you can come up with a better snippet yourself. :)

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Posted

You have to set the variable $PID every time in the loop.

Programming today is a race between software engineers striving to
build bigger and better idiot-proof programs, and the Universe
trying to produce bigger and better idiots.
So far, the Universe is winning.

Posted

Melba hello again :)

1) If I ping that I ip address and the computer is turned off it does return a 0 and if the computer is on the it returns a 1. That is why I have it set so that if the $PID returns a 0 (which equals off) to do a ping until the return value is a 1 which means the computer is online and is pinging.

2) That is why I think a ping returns a PID. And I know PID might be used for some other reason in Autoit but for me is was a simple variable I could attach to the ping. Should I be using $var instead of $PID, is it because $PID is used to define something else?

Thanks :)

Grimm

Thanks

Grimm

  • Moderators
Posted

grimmlock,

PID is more normally used as shorthand for "Process ID" - you get that returned when you start a process using Run and it is a unique number used to identify that particular process. There is no reason why you should not use $PID as your variable name - but it could lead to confusion, as evidenced above. ;)

But returning to why the snippet is not working - you never update the value of $PID (or whatever you want to call it) as you check it - so the Until condition is never met. And if you get a return value from Ping in the loop, why do you think it will be 1? I think it is much more likely to be a positive value of some kind - I told you above what the Help file says the value will be. ;)

So you need to update $PID in the loop and set the condition to be less specific - something like this perhaps (untested):

Func _local2()
    Local $PID = ping("192.168.27.172")
    If $PID = 0 Then
        ; Start the loop running until ping returns a value
        Do
            Sleep(10) ; Give the CPU a break
        ; Has ping returned a value?
        Until ping("192.168.27.172") <> 0
        ; If yes then we get here
        Msgbox(0, "", "Online")
    Else

    EndIf

EndFunc

All clear? :)

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Posted

:)

_WaitForIP("192.168.27.172")
Func _WaitForIP($sIP)
 Do
  Sleep(10) ; Give the CPU a break
 Until Ping($sIP) <> 0
 MsgBox(0, $sIP, "Online")
EndFunc   ;==>_WaitForIP

Programming today is a race between software engineers striving to
build bigger and better idiot-proof programs, and the Universe
trying to produce bigger and better idiots.
So far, the Universe is winning.

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
×
×
  • Create New...