sarah.reichelt at gmail.com
Wed Sep 27 23:18:01 EDT 2006
On 9/28/06, Robert Sneidar <bobs at twft.com> wrote:
> Okay I went back and checked the permissions thing. I have read and
> write to it and I copied the file to my desktop to make sure.
> Permissions are not the issue. But I am getting empty when I read
> from the file now, whereas before "it" never changed when I read from
> a file. BTW I AM running code in a button that is part of a group
> that is a background. Possible issue?? Here is the updated code:
> ON mouseUp
> answer file "Select the program file to import:" of type "F+PR"
> put it into mfilename
> IF mfilename is empty THEN exit mouseup
> put slyfilefrompath(mfilename) into mshortfile
> IF char -4 of mshortfile is "." THEN
> put char 1 to -5 of mshortfile into mmodule
> END IF
> IF there is a card (mmodule) THEN
> go card (mmodule)
> new card
> set the name of this card to tolower(mmodule)
> END IF
> -- Read from file method
> open file mfile
> put the result into mres
> -- mres is empty here indicating a successful open
> read from file mfile at 1 until eof
> -- it is empty here!!!!! AAAAAGGGGKKKKKKKK!
> put it into field code
> close file mfile
> -- URL method
> -- put "file:" & mfilename into mfile
> -- put url mfile into field code
> set the text of field "lblcode" to "Code: " & tolower
> END mouseUp
You don't define mfile anywhere in this script, so I would guess it is
reading a non-existent file and returning the contents - nothing.
Put in a check for the file first: e.g. if there is not a file mfile then ...
More information about the Use-livecode