s-Context Variables
¢¢¢¢¢¢¢¢¢¢¢¢¢¢¢¢¢¢¢
1. Introduction
2. Switches
2a. General Display
Variables: s.AUTOEVALUATE
s.AUTORESPACE
s.AUTOTITLEDEFINE
2b. Input
Variables: s.AUTOCOPY
s.AUTOEDITSPACE
s.AUTOEXECUTE
2c. Containers
Variables: s.AUTOBUILD
s.AUTONEWSHOW
s.AUTOPOSITION
2d. Multiple Windows
Variables s.AUTOREPARENT
s.AUTORESHOW
s.AUTOWS
2e. Saving
Variable: s.AUTOSCRIPT
3. Parameters
3a. General Display
Variables: s.AUTOBLANK
s.BEEP
s.DATASPACE
s.WP
s.WSNAME
3b. Input
Variables: s.EDITSPACE
s.NA
3c. Graphs
Variables: s.FILLCOLORS
s.LINECOLORS
s.LINESTYLES
s.TRACESYMBOLS
3d. Multiple Windows
Variables: s.SHELL
s.WS
3e. System Response
Variables: s.ABORT
s.BUSY
s.CLOCK
s.CONNECTED
s.ERROR
s.EXIT
s.GRAY
s.MSG
s.QUIET
s.VERIFY
3f. Miscellaneous
Variables: s.AUTODOC
s.SCREEN
4. Attribute Default Variables
Variables: s.BLACK
s.BLUE
s.GREEN
s.GRAY
s.ORANGE
s.PURPLE
s.RED
s.WHITE
s.YELLOW
s.FONT
5. Data Variables
Variables: s.COLOR_NAMES
s.COLOR_NUMBERS
s.FONT_NAMES
---------------------------------------------------
1. Introduction
There are some fifty global variables that are defined in the s context to
provide defaults, parameters, system control, and so on. They fall into four
categories: boolean switches, general parameters, system attribute default
variables, and informational data variables.
2. Switches
The s-context boolean switches correspond to attributes in a way that is
obvious from their names: the name of the corresponding attribute is the
string following s.AUTO, changed to lower case. Thus s.AUTORESPACE
corresponds to respace. These switches provide defaults for their attributes.
When an attribute that has a corresponding global switch is set to Null for an
object or has an initial default value of Null, the value of that attribute
for the object is set to the value of the corresponding switch. That value
will be shown and used as the value of the attribute, but the fact that the
attribute was Null is remembered, and if the switch is changed later the
attribute value will be changed likewise.
The switches are grouped here by function to help you survey what is
available. The meaning of each of them is briefly described; more details can
be found by looking up the corresponding attribute in an earlier tutorial or
the reference manual. The examples given here not only show the operation of
the switches but also reinforce the discussions of the attributes in the other
tutorials.
2a. General Display
Variables: s.AUTOEVALUATE
s.AUTORESPACE
s.AUTOTITLEDEFINE
These switches are the defaults for attributes that dictate whether:
- a variable is evaluated in order to determine appropriate attributes for
its display (evaluate is effectively 1) or is not evaluated (evaluate is 0);
- an object's space attribute is increased when exceeded by the result of
the default out function (respace is 1) or is not (respace is 0);
- a dependent object's default title (to be used when the title is set to
Null) is its definition (titledefine is 1) or its name (titledefine is 0).
The default for s.AUTOEVALUATE is 1; for the other two, the default is 0. As
for the attributes, the default for evaluate, respace, and titledefine is
Null. Thus they all take their values from the corresponding s-context
variables.
Let's take the last one as an easily visible example. (The shelltitle changes
also, although you might not expect it to. The titledefine attribute is to be
eliminated in Version 3.)
$load s
scrûs.SCREEN-34 12
br{w;m}:{w has (`yx;scr-m+Ø`yxs of w);}
aûÉ4 4; bûô1+a;
c:aßb
show `c; br{`c;0};
s.AUTOTITLEDEFINE
`titledefine `title of `c
Because titledefine has the default value Null, s sets it to the value of
s.AUTOTITLEDEFINE. If we change that value, then s remembers that titledefine
was Null, and changes its value accordingly, as shown by the result of setting
the title attribute to Null and by the result of the of function for
`titledefine:
s.AUTOTITLEDEFINEû1
`c has (`title;);
`titledefine `title of `c
2b. Input
Variables: s.AUTOCOPY
s.AUTOEDITSPACE
s.AUTOEXECUTE
These switches give the defaults for attributes that specify whether:
- when a row is inserted above or below an existing row the values in the
new row are na's (copy is effectively 0) or are copies of the values in
the existing row (copy is 1);
- the space for editing in a cell is the value of s.AUTOEDITSPACE (editspace
is 1) or the value of the space attribute (editspace is 0);
- input expression are executed (as A+ expressions) to obtain a value
(execute is 1) or not (editspace is 0).
The default for s.AUTOCOPY is 0; for the other two, the default is 1. As for
the attributes, the default for copy and execute is Null and for editspace 1.
Thus, for a given variable, editspace has to be set to Null for s.AUTOEDIT-
SPACE to be effective, whereas s.AUTOCOPY and s.AUTOEXECUTE are effective by
default.
To reinforce the point about the distinction between the value of an
attribute, which you can see, and the source of the value, which you can't
necessarily see, consider the following sequence. Recall that the execute
attribute governs whether an entry in a cell is executed or not, that is,
whether it can be an A+ expression, as opposed to, say, just a number.
_ex >free `c;
show¡ `a`b; br{`a;0,10+>`xs of `b}; br{`b;0};
>Ø `execute of¡ `a`b
s.AUTOEXECUTEû0
>Ø `execute of¡ `a`b
`a has (`execute;1); s.AUTOEXECUTEû1;
>Ø `execute of¡ `a`b ã Same value,
s.AUTOEXECUTEû0 ã but not same source,
>Ø `execute of¡ `a`b ã as you can see.
When an attribute name is preceded by a period in a "has" statement, what is
associated with the attribute is not the present value of the variable that is
named but the variable itself.
The function s.usedBy reports such explicit "electrical" connections: it lists
the variables (if any) that were specified for the attributes named in its
left argument and the object named in its right argument. As shown in the
following statements, it does not report any variables whose use was initiated
implicitly by setting the attribute to Null (because that information is in
the toolkit and is not available to the s processor).
The first line below connects the execute attribute for both a and b to the
variable s.AUTOEXECUTE, but in different ways:
`a has (`execute;); `b has (`.execute;`s.AUTOEXECUTE);
`execute s.usedBy¡ `a`b
_ex¡ Øfree¡ `a`b;
2c. Containers
Variables: s.AUTOBUILD
s.AUTONEWSHOW
s.AUTOPOSITION
These switches provide the default values for attributes that control whether:
- in a layout defined by a simple vector of symbols, the objects are placed:
- in a single column (build is 0), or
- in the relative positions in which they are already shown, any objects
that are not on the screen being put in a pile at the top left (build
is 1);
- when an object is newly placed in a container, it is shown:
- always (newshow is 1), or
- only if the object was already shown elsewhere (newshow is 0);
- in a layout whose build attribute is 0 (perhaps from s.AUTOBUILD) and which
is defined by a simple vector of symbols, the objects are placed:
- vertically, in a column (position is 1), or
- on top of each other (position is 0).
The default value for s.AUTOBUILD is 0, for s.AUTONEWSHOW 0, and for
s.AUTOPOSITION 1. The default value for the build attribute is Null, for
newshow 0, and for position 1. Therefore, of the three, only build will take
its value from the s-context variable by default; the others must be set to
Null to make the switch effective.
To illustrate:
aûbûcûdûeûÉ6 8
lû`a`b`c`d`e
show `l is `layout; br{`l;0}
free `l;
s.AUTOBUILDû1 ã Reflected in build, because default for build is Null.
show¡ `a`b`c; br{`a;40+Ø`yxs of `c}; br{`b;(40+Ø`ys of `c),0}; br{`c;0}
show `l is `layout; br{`l;0}
`a has (`raise;1); ã a is under d and e; raise it (title changes from e to a).
s.AUTOBUILDû0; free `l; _ex `l;
lû`a`b`c; `l is `layout;
`l has (`newshow;); ã Needed to make newshow reflect s.AUTONEWSHOW.
show `l; `l br 0
lû`a`b`c`d`e; `l br 0 ã d and e were not shown, so they are not shown in l.
s.AUTONEWSHOWû1; `l br 0
lû`a`b`c
lû`a`b`c`d`e; `l br 0 ã Now d and e are shown, since newshow is 1 for l.
free `l; _ex `l;
lû`a`b`c; `l is `layout;
`l has (`position;); ã Make s.AUTOPOSITION effective.
show `l; `l br 0 ã Vertically aligned.
s.AUTOPOSITIONû0
lû() ã Notice that a, b, and c are reparented and become top-level.
lû`a`b`c; `l br 0 ã Make the three arrays be placed in the layout afresh.
`a has (`raise;1); ã a is at the bottom. b is under there, too; you can check.
2d. Multiple windows
Variables: s.AUTOREPARENT
s.AUTORESHOW
s.AUTOWS
These switches provide the default values for attributes that determine
whether:
- an orphaned child is reparented to be a top-level object (reparent is 1)
or freed (reparent is 0);
- a reparented child is shown if it was shown in its former parent (reshow
is 1) or not shown (reshow is 0); and
- an object being shown initially can be the screen workspace (ws is 1) or
not (ws is 0).
The default for all three variables is 1 and for all three attributes is Null.
See the effect of setting them to 0, being sure to read what appears in the A+
session log after each respecification of l:
s.AUTOPOSITIONû1; free `l;
show `l is `layout; `l br 0
s.AUTORESHOWû0
lû`b`c; `l br 0 ã a is reparented but not reshown: top-level but hidden.
show `a; ã And here is a.
s.AUTOREPARENTû0
lû`c; `l br 0 ã b is freed, not reparented.
s.AUTOWSû0
free¡ `l`a; show `l is `layout; `l br 0
Notice that this time, unlike previous times,l was created as a popup, as you
can see from its pin.
2e. Saving
Variable: s.AUTOSCRIPT
This switch provides the default for the attribute that governs whether a
definition appears for the object in the result of s.script{} (1) or not (0).
The default is 1 and the default for the script attribute is Null. See the
Buttons tutorial.
3. Parameters
The s-context parameters are global variables that give default values for
attributes, control certain aspects of system behavior, and so on.
3a. General Display
Variables: s.AUTOBLANK
s.BEEP
s.DATASPACE
s.WP
s.WSNAME
s.AUTOBLANK contains the default value to be displayed for a na -- i.e., a
conventional value being used to indicate a missing value -- in an object for
which the value of the blank attribute is the Null.
The default value of s.AUTOBLANK is the Null, which causes na's to be
displayed as is. The default value of the blank attribute is 1 0Ò(), which
also causes na values to be displayed as is and causes s.AUTOBLANK to be
ignored. To have the current value of s.AUTOBLANK be used by an object, set
its blank attribute to Null.
s.AUTOWSûs.AUTORESHOWûs.AUTOREPARENTû1
free `l; show `c; `c br 0
`c has ( `insertbelow;1; `space;10; `row;0);
Now move the mouse pointer into the display of c, press Meta-Insert
(Alt-Insert on IBM keyboards), and move the pointer back into the Emacs
window. The first statement demonstrates that the default values of the
attribute and the default variable have the same effect on the display. The
remaining statements of this set show that s.AUTOBLANK is not electrically
connected.
`c has (`blank;);
s.AUTOBLANKû' '
`c has (`blank;);
s.AUTOBLANKû'Fill in'
`c has (`blank;);
s.AUTOBLANKû()
Setting s.BEEP to any value causes the display to beep. Don't think of it as
a free variable to keep a value in, however:
s.BEEPû1
10 do s.BEEPû100
s.BEEP
s.DATASPACE provides the default value for the space attribute, used when the
value of space is the Null.
s.DATASPACE
When a variable for which default formatting is in effect is bound, s.WP is
used to calculate a tentative value for its space attribute:
- if s.WP is 0, the result is the value of s.DATASPACE;
- if it is -1, the result is the minimum width required for any cell in the
entire object;
- otherwise, the result is the minimum width required for any cell in just
the first s.WP rows or (for a vector) cells, to save computation.
The value of the space attribute is then set to the maximum of its existing
value, the value just calculated, and, if the object is a vector, the width of
its title.
Because space is a persistent attribute, we expunge the variable before each
redisplay in this example:
s.WP
s.WPû1
_ex free `c; cûÉ6 8; c[2]û8Ù1234567890; show `c is `array; `c br 0
s.WPû0
_ex free `c; cûÉ6 8; c[2]û8Ù1234567890; show `c is `array; `c br 0
s.WPû¢1
_ex free `c; cûÉ6 8; c[2]û8Ù1234567890; show `c is `array; `c br 0
s.WSNAME holds the default value of the shelltitle attribute for the object
named in s.WS. The default value for s.WSNAME itself is 0Ø1Ù_argv if _argv is
not the Null, and 'A+' otherwise. Clearly, an application name is a good
value for this variable. Its value is used when the object's shelltitle
attribute is set to Null or the object is first shown (with a shelltitle
attribute of Null):
s.WSNAMEû'A+ Tutorial' ã No visible effect.
`c has (`shelltitle;); ã Aha!
s.WSNAMEû'A+ s Tutorial' ã No visible effect.
free `c; show `c; `c br 0 ã Yes!
s.WSNAMEû'A+'; _ex free `c;
3b. Input
Variables: s.EDITSPACE
s.NA
The space available for editing in a cell is given by one of two values: the
space attribute or, when the editspace attribute is effectively 1,
s.EDITSPACE, whose default value is 256. If the editing space exceeds the
value of the space attribute, scrolling is performed automatically.
The na attribute gives a conventional value to be used to indicate missing
data. When a row is inserted and the copy attribute is not effectively 1, the
na value is used for each inserted element of the variable.
If na is Null (its default value), its value comes from s.NA, which is a
slotfiller whose symbolic indices are the type symbols. The na value used for
a variable x with null na is (©x)Øs.NA. The na values can be seen in the
following example because the blank attribute and s.AUTOBLANK are null until
the last statement, when the current na values are shown as "Fill in":
s.NA
cûÉ6 5; `c is `array;
`c has (`insertbelow;1; `space;10; `cols;2);
show `c; `c br 0
ã Click on the first row of c and press Meta-Insert (Alt-Insert on
ã IBM keyboards). Inserted elements have the value ¢999999999.
(`intØs.NA)û¢888888
ã Move pointer into c; press Meta-Insert. Inserted values: ¢888888.
`c has (`na;0);
ã Insert another row. Inserted values: 0.
(`intØs.NA)û¢777
ã Insert another row. Inserted values: still 0.
`c has (`na;);
ã Insert another row. Now inserted values are ¢777.
`c has (`blank;'Fill in');
We could have specified `c has (`na;5Ò0). For numeric matrices, scalar and
vector na specifications have the same effect on the variable and the display.
For character matrices, the situation is somewhat different. Scalar and
vector na attributes have the same effect on the variable, but for the blank
attribute the contents of each cell is checked against the value of the na
attribute. Each cell contains an entire row of the variable, so only the
vector form will be found:
cûÎ`character`matrix
`c has (`na;'-'; `blank;' ');
ã Move the pointer into c and press Meta-Insert.
ã Notice that the na's are not found and replaced in the display.
`c has (`na;9Ò'-'); `c has `refresh;
Now the cells with na's have been found and the replacement made. The blank
attribute can have a vector value, which is given to the entire cell. In
fact, the na attribute can be given a vector value, and the elements of that
value will be assigned to the elements of the row of the matrix:
`c has (`blank;'New text:');
`c has (`na;'Insertion');
Insert another row. Its value is "insertion", its display is "New text:", and
the previously inserted row no longer is na.
c[1;1+É7]
_ex free `c;
Notice that the blank attribute is used in the display of only those elements
of the variable that are equal to the current value of the na attribute.
3c. Graphs
Variables: s.FILLCOLORS
s.LINECOLORS
s.LINESTYLES
s.TRACESYMBOLS
These variables provide the default values for the fillcolor, linecolor,
linestyle, and symbol attributes.
s.FILLCOLORS
s.LINECOLORS
s.LINESTYLES
s.TRACESYMBOLS
The default for style is line. With one trace set, the default is to
distinguish the traces by color and to use the same line style for all of
them. You can, of course, change the default line colors, with a refresh to
make the change effective:
t1û2 4Ò1 1.25 1.5 1.75 2 2.25 2.5 2.75
gû`t1; `g is `graph;
show `g; `g has (`legend;`xy; `xlegend;53); `g br 0
s.LINECOLORSû`deepskyblue `yellow;
`g has `refresh;
s.LINECOLORSûs.FILLCOLORS; `g has `refresh;
You can also detach the attributes from the default variables by giving them
non-null values. For example, you can distinguish traces within a trace set
by line style instead of color:
`t1 has (`linecolor;`black);
`t1 has (`linestyle;`dotdash`dot`solid);
For a single trace set in the scatter style, the default is to distinguish the
traces by both fill color and symbol:
`t1 has (`style;`scatter);
The fillcolor and symbol attributes can be set directly, and their default
values can be changed:
`t1 has (`fillcolor;`yellow);
`t1 has (`symbol;`xsym);
`t1 has (`symbol;`diamond`xsym`diamondfilled);
s.TRACESYMBOLSû÷s.TRACESYMBOLS
`t1 has (`symbol;);
When there is more than one trace set, color is used to distinguish among the
sets and line style and symbol are used to distinguish among the traces within
each set. Start by restoring the defaults and adding a second trace set; try
reversing the default order of the line style:
`t1 has (`linecolor`linestyle`fillcolor;3Ò());
t2ût1; t2[;0]û3 4;
gû`t1`t2; `t1 has (`style;`line);
s.LINESTYLESû÷s.LINESTYLES; `g has `refresh;
When there are several trace sets and the scatter style is used, both fill
color and symbol are used to distinguish among sets. If you want to
differentiate traces presently within the same set, either change their
attributes directly, as in the following example, or put them in different
trace sets.
`t1 has (`style;`scatter);
`t2 has (`style;`scatter);
`t1 has (`fillcolor;`blue`yellow`orange);
s.FILLCOLORSû÷,>`fillcolor of `t1; `t1 has (`fillcolor;);
_ex¡ free `g;
3d. Multiple Windows
Variables: s.SHELL
s.WS
s.SHELL specifies whether the default window type is pop-up (-1) or top-level
(0). That is, when an object is created and its window type is not specified
in some other manner, it will be determined by s.SHELL:
s.SHELL
s.SHELLû0
aûbûcûdûeûÉ6 8
show¡ `a`b`c`d; `a`b`c`d br¡ (90 0;60 0;30 0;0);
Because we changed s.SHELL from its default value of -1 to 0, all four objects
were created as top-level windows. There is a way to reverse this effect for
individual variables. If an underscore is inserted immediately following the
backquote in the name of the class to which the object is being bound, then
the window type will be the opposite of the default established by s.SHELL:
free `d;
show `d is `_array; `d br 0
Now we will repeat the process with the opposite default. Notice that one
exception occurs:
free¡ `a`b`c`d;
s.SHELLû¢1
show¡ `a`b`c`d; `a`b`c`d br¡ (90 0;60 0;30 0;0);
free `d;
show `d is `_array; `d br 0
Why is a top-level despite the default window type of pop-up? When it was
created, there was no screen workspace, and so it was made the workspace,
which requires that it be top-level. s.WS names the screen workspace and its
value verifies the fact that a is it. Setting s.WS to Null makes the
current screen workspace no longer the workspace; the next object created
will become the screen workspace. The object that is no longer the screen
workspace is given the default window type. Both it and the next object
created are raised above the other windows, being newer, so we have to raise
the existing windows each time in this example to maintain visibility:
s.WS
s.WSû(); `b`c`d has¡ `raise;
show `e; `e br 120 0; `a`b`c`d has¡ `raise;
s.WS
_ex¡ Øfree¡ `a`b`c`d`e;
3e. System response
Variables: s.ABORT
s.BUSY
s.CLOCK
s.CONNECTED
s.ERROR
s.EXIT
s.GRAY
s.MSG
s.QUIET
s.VERIFY
Five of these variables have to do with error responses and messages: s.ABORT,
s.ERROR, s.MSG, s.QUIET, and s.VERIFY.
Errors are classified by s as either moderate or severe. When an s function
encounters a severe error, s.ABORT controls what happens: if it is 1 (the
default), execution of the s function and the functions in its calling chain
is aborted, whereas if it is 0, execution of the function is suspended.
When an s function encounters a moderate error, s.ERROR controls what happens:
if it is 1, whatever action s.ABORT dictates is taken, whereas if it is 0 (the
default), execution is continued despite the error. First we make sure the
defaults are in effect:
s.ABORTû1; s.ERRORûs.QUIETû0;
show `a Ý aûÉ6 8; `a br 0
f{}:`a is `layout
f{}
$si
s.ABORTû0
f{}
$si
ý
f{}:{`a has (`xlegend;3); '*** Continued ***'}
f{}
s.ERRORû1
f{}
$si
ý
s.ABORTû1
f{}
$si
s.ERRORû0
There are three categories of s messages: for severe errors, for moderate
errors, and as warnings or information. As you have just seen, exclamation
points -- two, one, or none -- indicate the category of a message, which is
syntactically in the form of a comment. s.QUIET controls which messages are
displayed: all (0), errors only (1), severe errors only (2), or none (-1).
Try the following example and see the messages gradually disappear:
ã s.QUIET is 0
free `a; show `a; `a br 0; `a has (`xlegend;3); `a is `layout;
s.QUIETû1
free `a; show `a; `a br 0; `a has (`xlegend;3); `a is `layout;
s.QUIETû2
free `a; show `a; `a br 0; `a has (`xlegend;3); `a is `layout;
s.QUIETû¢1
free `a; show `a; `a br 0; `a has (`xlegend;3); `a is `layout;
s.QUIETû0
The messages from s do not have to be routed to the session log. They can be
routed to a variable instead, in which case the comment symbol and space at
the beginning will be omitted. The messages are overwritten; the variable
will contain only the last message. If the variable is a displayed object,
the last message will be shown in its display. Explicit results and messages
that are not from s will continue to be shown in the A+ session log.
You specify the destination for the messages from s in the variable s.MSG, by
giving a name in symbol form or else the Null. The name must be a valid name
for a variable, but the variable need not exist. The Null is used to specify
the session log:
()½s.MSG
aû3 50Ò' '; `a is `label; `a has `naturalsize; `a br 0
s.MSGû`a
`a has (`xlegend;3); `a is `layout;
`a has (`xlegend;3);
`a has (`bg;white) ã Non-s error messages appear in the A+ session log.
ý
`a has (`bg;`white) ã Explicit results always go to the log, also.
s.MSGû`m ã No such variable yet.
`a has (`xlegend;3); `a is `layout;
m
Òm
_ex >free `a;
m
Òm
s.MSGû()
aûÉ6 8; show `a; `a br 0; `a has (`xlegend;3); `a is `layout;
A variable must satisfy certain type and rank restrictions in order to be
bound to a given display class. When its verify attribute is effectively 0
(the default value), verification takes place in the A+ interpreter; when it
is 1, verification takes place within the s-context functions and a more
meaningful message is emitted. The default value for verify is actually Null,
which means that the value of s.VERIFY is to be used. (s.AUTOVERIFY might be
a name more consistent with the conventions for naming s-context variables.)
The default value of s.VERIFY is 0.
The following example shows the two verifications and, in the latter case, by
directing the message from s away from the session log, shows where the parts
of the message come from (as you would expect from their form):
aû2 3 4 5Ò1
ý
s.VERIFYû1; `verify of `a ã The effective value is shown, not the actual.
aû2 3 4 5Ò1
ý
s.MSGû`m
aû2 3 4 5Ò1
ý
m
s.MSGû(); s.VERIFYû0; _ex `m;
Three of the variables discussed in this section have to do with indications
that the system is busy: s.BUSY, s.CLOCK, and s.GRAY.
We will say that the pointer is "busy" -- or that the busy pointer is on --
during periods in which it is required to appear as a small clock whenever it
is in an s window.
The first of these variables provides a semi-automatic control for the busy
pointer. It allows a function to turn the busy pointer on and, so far as that
function is concerned, off. Specifically, when s.BUSY is set to 1, an
internal "busy count" is incremented by 1, and when it is set to 0 the count
is decremented by 1 (but not below 0). Whenever the count is non-zero, the
pointer appears busy:
f{}:{s.BUSYû1; g{}; sys.sleep 5; s.BUSYû0}
g{}:{s.BUSYû1; sys.sleep 5; s.BUSYû0}
bûÉ6 8; show `b; `b br 0,10+>`xs of `a
$dbg func 1
$dbg +cxt .
Now press F2 on the following statement and move the pointer into the display
of a or b during its execution:
f{}
$dbg func 0
s.CLOCK provides an independent automatic control for the busy pointer. If
s.CLOCK is 1, the pointer appears busy whenever it is in any s window during
callbacks for displayed objects and during assignments to variables being
displayed on the screen. If it is 0, such events do not cause the pointer to
appear busy, thus avoiding flicker in, e.g., applications with fast real-time
update rates.
After executing the first three statements, move the pointer in the display of
a and press F1; you will see the pointer go busy for two seconds. Then move
the pointer back into the Emacs window, press F2 on the statement executing
f{}, and move the pointer into the display of a or b. After three seconds,
you will see it flash to busy and back. Notice that the shelltitle area is
"grayed" each time the pointer is busy:
g{}:{sys.sleep 2; Õ'g done'}
`a has (`f1;(g;));
f{}:{sys.sleep 3; .aû.a; 'f done'}
f{}
s.GRAY, which has a default value of 1, controls whether the shelltitle
areas of the s windows are grayed whenever the pointer is busy. It is thus
dependent upon s.BUSY and s.CLOCK. Press F1 in the display of a after
executing each of the following two statements. You will see the busy pointer
without graying and then neither a busy pointer nor graying:
s.GRAYû0
s.CLOCKû0; s.GRAYû1;
s.CLOCKû1
3f. Miscellaneous
Variables: s.AUTODOC
s.SCREEN
The doc attribute allows you to provide documentation for objects. The
default value for doc is s.AUTODOC. By setting it to the name of the
application and perhaps your name, for example, you can provide minimal
generic documentation for those objects for which you don't want to provide
specific documentation.
s.SCREEN is a dependency that gives the height and width of the current
screens in pixels. You may have noticed that we used it for the br function,
to find out where the bottom right corner was in the screen you are using to
run this tutorial.
s.SCREEN
4. Attribute Default Variables
Variables: s.BLACK
s.BLUE
s.GREEN
s.GREY
s.ORANGE
s.PURPLE
s.RED
s.WHITE
s.YELLOW
s.FONT
An attribute default variable can supply an attribute value for all s objects,
for objects bound to a certain class or classes, or for an individual object
or objects. We will consider attribute default variables for the bg
attribute, in the order of comprehensiveness just given.
The s-context system attribute default variables each provide defaults for
certain attributes for objects bound to all classes, except that s.FONT does
not apply to the graph class. The attributes they apply to are listed in
Table 56-3 of the A+ Reference Manual.
Although the value of the bg attribute for the object a is given below by
the of function as `grey, it is in fact Null. It gets its effective value
from the system attribute default variable s.GREY, as its responsiveness to
changes in that variable shows. The object b, also of the array class, sheds
further light on the effect of the default variables:
`bg of `a
s.GREY
s.GREYû`purple
s.GREYû`grey
What if we set the value of bg of a ourselves? Then we have temporarily
disconnected it from s.GREY -- broken the electrical connection. Changing the
variable does not in general change the background color. If, however, we
make them coincide again, by changing the value of either bg or s.GREY, then
we reconnect them, and when we change the variable the background changes:
`a has `bg `rosybrown
s.GREYû`purple
s.GREYû`rosybrown
s.GREYû`grey
We can change the default variable for bg for the entire array class. When we
establish the new default variable in the example below, nothing happens,
because its value is not the same as the bg value for a. Just as for the
system default, we can establish the connection by making the values coincide.
Changing s.GREY now has no effect on the bg of a, because s.GREY has been
displaced by arrayGREY for bg for array objects. (We could, to be sure, make
arrayGREY also be the default variable for other attributes and for other
classes.)
arrayGREYû`mediumseagreen
`array s.Has `.bg `arrayGREY
arrayGREYû`grey
arrayGREYû`mediumseagreen
s.GREYû`mediumseagreen
s.GREYû`grey
We can specify a bg variable just for a. As soon as has is executed, the
new variable clr is used for the background color, because we are no longer
in a situation where there may be many objects and some of them may be
exceptions to the general rule embodied in the default variable. Response is
immediate not only to direct settings of bg but also to settings of clr:
clrû`rosybrown
`a has `.bg `clr;
clrûs.BLUE
`a has `bg `grey;
clrû`cyan
So here are the present values of the attribute for a, the default variable
for it for a, the default variable for it for this class, and the default
variable for all other classes, typified by table, namely the system default
variable:
`bg of `a
`.bg of `a
`.bg s.Of `array
`.bg s.Of `table
We can remove the default variable for bg for this object by specifying it to
be the Null. We thereby remove the shadow from the default variable for the
array class and it acts as it did before:
`a has (`.bg;);
arrayGREYû`cyan
arrayGREYû`rosybrown
Removing the default variable for bg for the entire array class does not have
a similar effect, because it displaced, not shadowed, the system default
variable:
`array s.Has (`.bg;);
arrayGREYû`grey
s.GREYû`rosybrown
s.GREYû`grey
`.bg s.Of `array
Explicitly setting the default variable for bg for array restores its effect.
We must, of course, make the default variable for the class agree with the
actual value of the attribute of the object to restore the connection. If
this doesn't work now, it will work soon, in another release:
`array s.Has (`.bg;`s.GREY);
s.GREYû`rosybrown
s.GREYû`grey
`.bg s.Of `array
The default for the font, labelfont, and titlefont attributes for all classes
except graph is obtained from s.FONT, whose default value is "kaplgallant".
(The dynamic attribute governs whether the window is resized when the font is
changed.) Watch the fonts change in a when you execute these statements:
s.FONTû'helvetica'
s.FONTû'helvetica-14'
s.FONTû'kaplgallant'
5. Data Variables
Variables: s.COLOR_NAMES
s.COLOR_NUMBERS
s.FONT_NAMES
These variables give information about the colors and fonts that are
available. The values of the two names variables are long lists of symbols;
using Unpack and show is a good way to display them:
_ex¡`a`b,Øfree¡`a`b; show Îs.FONT_NAMES; `a br 0
The color variables can be shown together:
(cn1;cn2;cn3)û<@1ôs.COLOR_NUMBERS
cnmsûÎs.COLOR_NAMES
tû`cn1`cn2`cn3`cnms
`t has (`class;`table; `cols;4; `title;'Color numbers and names');
`cn1`cn2`cn3`cnms has¡ (<`title),¡<¡(`R;`G;`B;'Color names');
`cn1`cn2`cn3 has¡ <(`space;4);
show `t; `t br 0
_ex¡`f`g`l`arrayGREY`clr,Øs.reset{};