Page 1 of 1

Accessing files query

Posted: Fri May 02, 2014 5:07 pm
by tasdvl9
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!

Re: Accessing files query

Posted: Fri May 02, 2014 5:11 pm
by magice
Try putting the url into a variable and then reading the second word of the variable.

Re: Accessing files query

Posted: Fri May 02, 2014 5:18 pm
by tasdvl9
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 :)

Re: Accessing files query

Posted: Fri May 02, 2014 5:19 pm
by Dixie

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