* --- Pinger.prg - Coded as a function to return true, or false * --- if name passed exists on the network. * --- Programmer : Pete Sass * --- Date : 2003.09.27 * --- Modified code : from Foxhound at Foxite web site FUNCTION Pinger LPARAMETERS cServerName LOCAL cFile,cString,cFile2,fHandle,nAt1,nAt2 cFile=RIGHT(SYS(2015),8 ) IF STRTOFILE("ping "+ALLTRIM(cServerName)+" -n 1 > "+cFile+".dat",cFile+".bat",0 )>0 cFile2=cFile+".bat" RUN /n2 &cFile2 cFile2=cFile+".dat" fHandle=-1 ON KEY LABEL 'ESC' exit DO WHILE fHandle < 0 fHandle=FOPEN(cFile2,2) ENDDO IF fHandle < 0 RETURN .F. * --- RETURN .null. ENDIF FCLOSE(fHandle) ON KEY LABEL 'ESC' cString=FILETOSTR(cFile2) SET SAFETY OFF DELETE FILE (cFile+".*" ) cString=MLINE(cString,ATLINE("Reply from",cString)) IF EMPTY(cString) RETURN .F. * --- RETURN '' ELSE RETURN .T. * --- RETURN SUBSTR(cString,12,AT(':',cString)-12) ENDIF ELSE RETURN .F. * --- RETURN .null. ENDIF ENDFUNC