Problem saving files
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
> 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:
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
put fld "save list"into tFiletoSave
put tFileToSave into url ("file:" & tFileName)
exit to top
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
More information about the use-livecode