Accessing files query

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
tasdvl9
Posts: 94
Joined: Fri Dec 06, 2013 3:55 am

Accessing files query

Post by tasdvl9 » Fri May 02, 2014 5:07 pm

Hello All,

In this code snippet I'm trying to retrieve the second word of line 1 in my text file:

set the itemdel to "/"

put the effective filename of this stack into mPath
put mPath & "/settings.txt" into mPath

answer(mPath)
put word 2 of line 1 of URL ("file:" & mPath ) into tPath
answer(tpath)

mpath gives me the correct path to my file but tPath is always showing me and empty string.
Is the syntax for this line: put word 2 of line 1 of URL ("file:" & mPath ) into tPath
correct?

Thanks!

magice
Posts: 457
Joined: Wed Mar 18, 2009 12:57 am

Re: Accessing files query

Post by magice » Fri May 02, 2014 5:11 pm

Try putting the url into a variable and then reading the second word of the variable.

tasdvl9
Posts: 94
Joined: Fri Dec 06, 2013 3:55 am

Re: Accessing files query

Post by tasdvl9 » Fri May 02, 2014 5:18 pm

Thanks, Magice.

I did some debugging and was neglecting to delete the last item in my path to where my txt file resided.

All is well now.

Thanks for the response :)

Dixie
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 1336
Joined: Sun Jul 12, 2009 10:53 am

Re: Accessing files query

Post by Dixie » Fri May 02, 2014 5:19 pm

Code: Select all

on mouseUp
   answer file ""
   if it is not empty then
      put it into theFilePath
   end if
   
   put URL ("file:" & theFilePath) into theWord
   put theFilePath & cr & word 2 of line 1 of theWord
end mouseUp

Post Reply