Display image from Url into image field or area

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
catalinanesia
Posts: 83
Joined: Sun Feb 16, 2014 10:08 pm

Display image from Url into image field or area

Post by catalinanesia » Sat May 16, 2015 8:04 pm

Hi everyone,
I am learning a bit of getting data from Internet in a CSV format for a weather app following Cyril Pruszko
guide from here: https://sites.google.com/a/pgcps.org/li ... me/mashups but I am a bit lost ...
I can not manage to load an image from a URL into an image field or area, here is my code:
"the code is on the button script"

Code: Select all

on mouseUp
   put url "http://api.worldweatheronline.com/free/v2/weather.ashx?q=Montreal&format=csv&num_of_days=5&date=2015-05-16&key=XXXXXKey" into  field "weather"
   //XXXXXKey is my API key
   put item 2 of line 12 of field "weather" into field "temp"
   put item 6 of line 12 of field "weather" into field "sky"
   put item 5 of line 12 of field "weather" into field "imgURL"
   put item 1 of line 1 of field "imgURL" into image "Skyimg"
end mouseUp
The script has no error but the image is not displayed on the image field, any hint or help please ...
I tried using URL like this: put URL of field "imgURL" into image "Skyimg" but nothing

Thanks!

catalinanesia
Posts: 83
Joined: Sun Feb 16, 2014 10:08 pm

Re: Display image from Url into image field or area

Post by catalinanesia » Sat May 16, 2015 8:29 pm

Well,
thanks to the forum community here is the solution:

Code: Select all

on mouseUp
   put url "http://api.worldweatheronline.com/free/v2/weather.ashx?q=Bucuresti&format=csv&num_of_days=5&date=2015-05-16&key=XXXXXXKey" into  field "weather"
   put item 2 of line 12 of field "weather" into field "temp"
   put item 6 of line 12 of field "weather" into field "sky"
   put item 5 of line 12 of field "weather" into field "imgURL"
   
   put field "imgURL" into tUrl
   set the filename of image "Skyimg" to tUrl
end mouseUp
Jean-Mark answered on a similar topic
http://forums.livecode.com/viewtopic.ph ... ge#p122389

Regards,
Catalin

Post Reply