swdave, I modified your code just a little bit, mainly, so that it can be used by non-english coders.
See the comments inside:
if file exist("getmyip.bat") then delete file "getmyip.bat"
`You could also use clear the existing MyIP.txt file with
`if file exist("MyIP.txt") then delete file "MyIP.txt"
open to write 1, "getmyip.bat"
write string 1, "ipconfig.exe > MyIP.txt"
close file 1
`It's important to wait for the command to finish,
`otherwise either the new "MyIp.txt" file could be
`created as an empty file or the "open to read"
`command could find no file to open ...
execute file "getmyip.bat", "", "",1
delete file "getmyip.bat"
open to read 1,"MyIP.txt"
while not file end(1)
read string 1,Line$
for y=1 to len(Line$)
Word$=Midstr$(Line$,y,2)
if Word$ = "IP"
for x = 1 to len(Line$)
if mid$(Line$,x) = ":"
IP$ = Right$(Line$,(len(Line$)-(x+1)))
endif
next x
endif
next y
endwhile
close file 1
set cursor 1,1
print "IP Address: ",IP$
wait key
end
`The way the main line is written depends of the language
`of the OS, so it`s better to only search for the "IP" term
`(I don't remember his nickname, but thx to the guy who post
`among other functions, the one below)
function Midstr$(source$,pos,length)
t$ = left$(right$(source$,len(source$)-(pos-1)),length)
endfunction t$
`One more thing, by default this code looks for the last IP address
`in the file. In my case, the last adapter is the one which connects my
`computer to the Internet, but I'm not sure whether this is a general rule ...