VfpNameLookup
For my network checks I want to ping some computers to see if they’re still active on my network. But before that, I have to lookup the IP numbers for the network names. Found this TekTips article on NSlookup from VFP6 and built my own function around the example.
* Lookup an IP number connected to a netwerk name * (C)2011 Jasper de Graaf for J.A. Software * Source: https://degraafonline.com * Inspiration from http://www.tek-tips.com/viewthread.cfm?qid=891380&page=338 LPARAMETERS tcLookup && name to lookup * No parameter, wrong type or empty IF PCOUNT()=0 OR !VARTYPE(tcLookup)=[C] OR EMPTY(tcLookup) ? [nslookup needs character parameter lookup network name or ip number] 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 lookup and get results loScriptExec = loShell.Exec("nslookup -debug "+tcLookup) lcNsLookup = loScriptExec.StdOut.ReadAll() IF AT([ANSWERS],lcNsLookup,2)>0 && we got a valid answer! lnIPpos = AT([Address:],lcNsLookup,2)+8 lcNsIp = ALLTRIM(SUBSTR(lcNsLookup,lnIPpos)) ELSE lcNsIp = [] && could not resolve network name ENDIF loScriptExec = null loShell = null RETURN lcNsIp