Problem saving files

David C. davidocoker at gmail.com
Tue Jul 6 19:07:51 CDT 2010


> A minor correction: the last item of tFileName in this snippet will be
> something like "ext" -- not ".ext". So you should do something like the
> following:
>
> put "ext" into tExtension -- use yours
> -- note the absence of the dot
> set the itemDelimiter to "."
> if the number of items of tFileName = 1 then
>   -- no extension provided by user
>   put "." & tExtension after tFilename
> else -- extension provided
>   if item -1 of tFileName <> tExtension then
>      -- wrong extension
>      put tExtension into item -1 of tFilename
>   end if
> end if
>
> -- Peter

Okay folks, finally had a chance to try this, but it still doesn't
seem to be quite right.
Here's my new adjusted code:

on SaveTheFile
   ask file "Save project as:" with filter "MYFL file,*.myfl"
   if it <> "" then
      put it into tFileName
      put "myfl" into tExtension -- use yours
      -- note the absence of the dot
      set the itemDelimiter to "."
      if the number of items of tFileName = 1 then
         -- no extension provided by user
         put "." & tExtension after tFilename
      else -- extension provided
         if item -1 of tFileName <> tExtension then
            -- wrong extension
            put tExtension into item -1 of tFilename
         end if
      end if
      put fld "save list"into tFiletoSave
      put tFileToSave into url ("file:" &  tFileName)

   else
      exit to top
   end if

end SaveTheFile

I verified that it works as intended when typing in a new file name.
It does in fact save the data correctly. Good to go!

Next, when selecting an existing file with the mouse, it *does* give
me the "replace file" prompt, but *appears* to not overwrite the file
at all. (Checking the time-stamp on the file that should have been
overwritten, before and after shows that it does not change.)

Yet when I open the file to read the content, the changes were in fact
made!  How weird is that?

Does my implementation of the code that Jacque and Peter supplied look
okay or maybe I should be looking for something else? Maybe I
shouldn't be concerned since it is working sans the time stamp on the
file. ?????

Best regards,
David C.



More information about the use-livecode mailing list