Visual Foxpro: Ping an IP number and return weither it has responded. Uses Windows scripting shell.
* Ping function * (C)2011 Jasper de Graaf for J.A. Software * Source: https://degraafonline.com LPARAMETERS tcIpNumber && IP number to ping * No parameter, wrong type or empty IF PCOUNT()=0 OR !VARTYPE(tcIpNumber)=[C] OR EMPTY(tcIpNumber) ? [ping needs character parameter ip number (ie: "192.168.1.254")] RETURN [] ENDIF * create scripting shell object and test loShell = CreateObject("WScript.Shell") IF VARTYPE(loShell)<>[O] ? [did not succeed in creating Wscript.Shell object] RETURN [] ENDIF * perform short single ping and get results loScriptExec = loShell.Exec("ping -n 1 -w 2 "+tcIpNumber) lcPing = loScriptExec.StdOut.ReadAll() llPing = ![time-out]$LOWER(lcPing) loScriptExec = null loShell = null RETURN llPing