Complete Newbie: Retrieving text inside non-local text files

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
Malteser
Posts: 7
Joined: Fri Dec 10, 2010 11:11 pm

Complete Newbie: Retrieving text inside non-local text files

Post by Malteser » Fri Dec 10, 2010 11:16 pm

Hi there,

Almost completely new to RunRev, but liking it so far. However, I've been scrolling through the tutorials and there doesn't seem to be one that relates to my issue.

I have a .txt file hosted at "http://dl.dropbox.com/u/15530379/newspost.txt" and would like to retrieve the text inside it and place it in a scrolling field (or, alternatively, into a Label).

I assumed something like this would suffice, but as I'm a -complete- novice, I'm probably way off. :)

on mouseUp
set the contents of lbltest to URL "http://dl.dropbox.com/u/15530379/newspost.txt"
end mouseUp
Last edited by Malteser on Sat Dec 11, 2010 12:34 am, edited 1 time in total.

bn
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 4172
Joined: Sun Jan 07, 2007 9:12 pm

Re: Complete Newbie: Retrieving text inside non-local text files

Post by bn » Sat Dec 11, 2010 12:27 am

Hi Malteser,
welcome to the Forum.

try:

Code: Select all

on mouseUp 
   put URL "http://dl.dropbox.com/u/15530379/Uprising/Launcher/newspost.txt" into field "NameOfMyField"
end mouseUp
Kind regards

Bernd

Malteser
Posts: 7
Joined: Fri Dec 10, 2010 11:11 pm

Re: Complete Newbie: Retrieving text inside non-local text files

Post by Malteser » Sat Dec 11, 2010 12:34 am

Just realised I posted two different links. I'm sure that helped. :D

Thanks a lot for that, managed to edit it to work for the other labels and fields too. :P

Malteser
Posts: 7
Joined: Fri Dec 10, 2010 11:11 pm

Re: Complete Newbie: Retrieving text inside non-local text files

Post by Malteser » Sat Dec 11, 2010 8:47 am

Hi again,

The code works perfectly when running from a MouseDown event on a test button, but when moving it to the Startup event for the main card (and the only card that isn't used for icon/image/video storage) it seems to cease functioning. I thought it was an issue with the entire script, but it seems like the OS print works fine. It's not exactly the most complicated script in the world which just confuses me further, because there's not a whole lot to go wrong (unless I'm mistaking how the on startup event works for cards)?

Code: Select all

on startup

/* 
+Get newspost.txt and output to newspost field
+Get latestver.txt and output to latestver field
-Get currentver.txt from $curfolder$, output to currentver field
*/

put URL "http://dl.dropbox.com/u/15530379/Uprising/Launcher/newspost.txt" into field "newspost"
put URL "http://dl.dropbox.com/u/15530397/Uprising/Launcher/latestver.txt" into field "latestver"
/* put _ into field "currentver"*/

set the loc of this stack to the screenLoc

/* Check OS and output to Label for installer reference folders, just in case installer check fails.*/

if the platform is "MacOS"\
then put "Macintosh" into field "ostype"
else if the platform is "Win32"\
then put "Windows" into field "ostype"
else if the platform is "Linux"\
       then put "Linux" into field "ostype"

end startup

bn
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 4172
Joined: Sun Jan 07, 2007 9:12 pm

Re: Complete Newbie: Retrieving text inside non-local text files

Post by bn » Sat Dec 11, 2010 12:01 pm

Hi Malteser,
try to put your code into a on openstack handler and provide a full path to the fields. Like "put something into field "newsPost" of card "news"
StartUp might be a little early in the chain of events.
regards
Bernd

Post Reply