Line by line, here is what is happening.
on CheckColor
This tells Director that what follows is a handler definition. Note there are no parentheses.
if the colorDepth <> 8 then
This is checking the computer. In essence it's asking the system how
many colors can be displayed. 8-bit color (or grey) returns a colorDepth
value of 8; this means that the system is capable of displaying 256
colors or shades of grey. A lower number indicates fewer colors can be
displayed; for example, 4-bit color is only 16 shades; 2-bit color is 4
shades, and 1-bit color is pure black-and-white. If the value is higher
, say 16 or 24, there are even more colors accessible; we'll go into
why this can be a problem later.
Since, in general, you will want your users to
have machines capable of displaying at least 256 colors (especially if
you use a lot of graphics in your programs), you need to have a way to
test for 8-bit minimum color depth and warn the user if the system is
not displaying enough colors. That is what the next line does:
ALERT "Caution: This
computer is set to something other than 256-color (8-bit) color mode."
& RETURN & RETURN & "Some colors in this program may not be
displayed correctly."
This command makes
the system beep and then displays a dialog box containing the text in
quotes and a button labeled OK. The & RETURN & RETURN &
tells Director to put two RETURNs between the two quoted lines — a
double-space that makes the message easier to read and understand.
Try it for yourself -- copy the ALERT line (but
only the ALERT line), paste it into the Message window, and hit RETURN.
You'll see a sample of what the ALERT command does.
end if
This terminates the if...then test. Without an end if,
Director will return an error when you try to close the Script window.
It's telling the program that it's time to finish testing a condition.
You must insert an end if (or its equivalent) for every if...then statement you make.
END CheckColor
This tells Director that you have finished the definition of this handler. Note, again, that there are no parentheses.
|
|