The function within it can be adapted for use in any project that reads data from a website.
Code: Select all
/* Internet Check by rbytes, November 2018 Uses PING to check internet status refname$ should be a website that is always up, such as "www.apple.com" -If chk is 2, internet is live and the website name$ is active -If chk is 1, internet is live, as indicated by successful PING of website refname$, but the website name$ is not active -If chk is 0, the internet is disconnected My tests indicate that pinging an active website with "[name].com" or "www.[name].com" returns 1, but pinging it with "http://[name].com" or "https://[name].com" always returns 0 You must use the form PING([name],port), with port=80 to get a response of 1. To test this program: a. Run it with name$ and refname$ set to active websites. chk will = 2 b. Run it with name$ deliberately misspelled. chk will = 1 c. Run it with your device in Airplane mode. chk will = 0 */ chk=intchk("x-rates.com","www.apple.com") choice=chk+1 on choice goto 20,30,40 20 PRINT "You are not connected to the internet" GOTO skip 30 PRINT "Your website is not responding" GOTO skip 40 PRINT "Your website is responding" skip: end DEF intchk(name$,refname$) chk=PING(name$,80) if chk then chk+=1 goto final else chk=PING(refname$,80) endif final: return chk end def