Checking for valid URL

Klaus Major klaus at major-k.de
Mon Mar 1 10:51:36 EST 2004


Hi Devin,

> Hi, all.
>
> Does anyone have a favorite way of ascertaining whether the data 
> requested from a URL is actually successfully downloaded? I have tried 
> simply checking the status of the container that receives the data, 
> usually a field for text or an image object for image data. This works 
> fine for text; i.e.,
>
> put url "http://www.domain.com/mytext.txt" into fld "myfield"
> if fld "myfield" is empty then answer "Bad URL."
>
> But the same technique does not seem to work for image data; i.e.,
> image "myimage" is empty -- always seems to return true
>
> I've shied away from the load command because I'm typically loading 
> lots of image or html data and don't want to bloat my application with 
> cached data. But if I were to do load all URLs before displaying the 
> data I'd have access to the URLStatus function, and could check for 
> "error" or "timeout" or empty results.
>
> For those of you who use the Internet library stuff: Is there a "best 
> practices" approach to checking for successful data download. I'm 
> interested in your experience and recommendations.

You can check "the result" directly after using the url.
It is empty if the operation was succesfull...

put url "http://www.domain.com/mytext.txt" into fld "myfield"
if the result <> empty then
    ### problems accessing that url...
end if
...

Hope that helps...

> Thanks,
>
> Devin Asay
> Humanities Technology and Research Support Center
> Brigham Young University

Regards

Klaus Major
klaus at major-k.de
www.major-k.de



More information about the use-livecode mailing list