slow load URL

Nicolas Cueto niconiko at gmail.com
Sun May 11 23:00:37 EDT 2008


Hello,

I have a stack that requires dowloading 40 to 200 image/sound files
(about 40Kb each).  The download time is pretty long so I'm wondering
if part of the problem is my script, which I've included below.

Thank you.

-- Nicolas Cueto


on startDownloads
  set the socketTimeoutInterval to 15000
  put theUrl into tTheUrl
  /*  Clear any cached urls.    */
  repeat for each line thisURL in the cachedURLs
     unload URL thisURL
  end repeat
  repeat for each line tImgOrSndID in tImgOrSndIDs
      put tTheUrl & tImgOrSndID into tURLPath
      load URL tURLPath
      ShowInfo tDU
      wait until "showInfo" is not among the items of the
pendingMessages with messages
  end repeat
end startDownloads


-- ShowInfo is a pending message which
-- monitors download status every 10 milliseconds.
-- By Eric Chatonet.

on ShowInfo pUrl
  local tStatus,tResult
  -----
  put URLStatus(pUrl) into tStatus
  switch
  case word 1 of tStatus = "error"
    answer "Sorry: invalid URL or no connection."
    put pUrl & cr after gFailedDownloads
    break
  case tStatus = empty
    answer "Sorry: invalid URL or no connection."
    put pUrl & cr after gFailedDownloads
    break
  case word 1 of tStatus = "timeout"
    answer "Sorry: time out."
    put pUrl & cr after gFailedDownloads
    break
  case item 1 of tStatus = "loading"
      break
  case word 1 of tStatus = "cached"
    exit ShowInfo
    break
  end switch
  send "ShowInfo" && pUrl to me in 10 milliseconds
end ShowInfo



More information about the use-livecode mailing list