This has to be easy! Tell a program not to open a file

Mark Schonewille m.schonewille at economy-x-talk.com
Wed Feb 27 07:31:53 CST 2008


Hi Art,

You could hide all windows of your application on startup or  
preOpenStack, check the file, and quit silently if the file is  
invalid, but I believe that showing an error message is the right  
thing to do.

With regard to your other question, you don't need to read the entire  
file at once. For example, assuming you have a command readSomeFile $1:

on readSomeFile theFile
   open file theFile for binary read
   read for 10 -- bytes
   if it is "specialtag" then
     put it into myData
     read from file theFile until EOF
     put it after myData
     -- now you can do something with myData
   else
     -- show an error message
   end if
   close file theFile
end readSomeFile

Additionally, you can check the file extension, and on the Mac the  
creator and file type, even before reading the first 10 bytes of the  
file.

Best regards,

Mark Schonewille

--

Economy-x-Talk Consulting and Software Engineering
http://economy-x-talk.com
http://www.salery.biz

Convert colours between different colour spaces with Color Converter.  
Download at http://economy-x-talk.com/cc.html



On 27 feb 2008, at 14:03, Arthur Rann wrote:

> Hi Mark,
> We took your advice, but we were unable to figure out how to not  
> load the
> file if it's in $1. If $1 contains something we don't want, what do  
> we do
> then? Right now we just show an error message and quit. Obviously,  
> this is
> not ideal. What do we do next?
>
> Thank you!!!
> Art
>




More information about the use-livecode mailing list