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

Mark Schonewille m.schonewille at
Wed Feb 27 08:31:53 EST 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
     -- 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  

Best regards,

Mark Schonewille


Economy-x-Talk Consulting and Software Engineering

Convert colours between different colour spaces with Color Converter.  
Download at

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