Friends, I’m not even sure “multithreading” is the right word, but I was looking at p34 in Shane’s book and wondering if I could adapt that procedure with the progress bar to other outlets.
Specifically, this is what I’m trying to do.
I have some code, part of which looks like this:
set myTemp to do shell script "mktemp -t txt"
do shell script "curl -s http://checkip.dyndns.org &> " & myTemp & " &2> /dev/null"
delay 7
set extIP to do shell script "sed 's/[a-zA-Z/<> :]//g' " & myTemp
if extIP = "" then
set my theNetwork to "Still trying."
else if extIP contains "=" then
set my theNetwork to "Can't get IP"
else
set my theNetwork to extIP
end if
# note: if you delete the two 'my' words in the last 4 lines, this should compile and run in native AS Editor
What its meant to do is let CURL go get the external IP in the background while returning control to the user. But that is defeated by my use of delay in Line 3.
The property 'theNetwork is connected to a UI Text Field. The idea is it should be displaying the ‘Still trying.’ message until the app checks the myTemp file and finds the IP address sitting prettily waiting to be fetched. So what I want to do is find a way to tell the app to go check back on that myTemp file to see if CURL has returned the result yet, but in the meantime let the user have control.
Any thoughts on how I can achieve this?