On Sat, Apr 2, 2016 at 4:48 PM, JB <[email protected]> wrote:
> If I open a file for read or write and the file does
> not exist it will be created.
Just to clarify, that statement is incorrect.
If you open a file for 'write' and the file does not exist, it will be created.
if you open a file for 'read' and the file does not exist 'the result'
will be "can't open that file" and NO file is created.
on mouseUp
set the defaultFolder to specialFolderPath("documents")
open file "this is a test.lcdoc" for read
if (the result is "can't open that file") then
--check if a file was created
if (there is a file "this is a test.lcdoc") then
answer "A file was created!"
else
answer "The file was NOT created."
end if
else
answer "You can read from it now!"
end if
end mouseUp
Please also note that Richmond's example is misleading. If you use
'read from file' without first using 'open file' then regardless of
whether the file exists or not, 'it' will always be empty.
_______________________________________________
use-livecode mailing list
[email protected]
Please visit this url to subscribe, unsubscribe and manage your subscription
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode