File exists

JB sundown at pacifier.com
Sat Apr 2 21:33:17 EDT 2016


Thanks for the code and info, Kay.

JB



> On Apr 2, 2016, at 10:53 AM, Kay C Lan <lan.kc.macmail at gmail.com> wrote:
> 
> On Sat, Apr 2, 2016 at 4:48 PM, JB <sundown at pacifier.com> 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
> use-livecode at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode
> 





More information about the use-livecode mailing list