(Obsolescent - Use ⎕NEW and dot notation instead)
The older-style of interface from APL to the object-based programming environment (System Classes) is built around the system function ⎕WI. This takes a left argument which is the name of the object, and a right argument which names the property or method you wish to access, and if appropriate the value you wish to assign to the property or pass to the method. When you create an object, you can optionally set properties at creation time, otherwise the system chooses defaults. The following examples show how this works:
Create a top-level object called Example, in this case a window with the standard Dialog border and appearance:
'Example' ⎕WI 'New' 'Dialog'
Create an object called Lst1, of class List Box, on the window Example (the system chooses defaults for things like size and position):
'Example.Lst1' ⎕WI 'New' 'List'
Set the size property of the list you just created to be 5 standard rows high and 30 columns wide (the object will immediately be re-sized):
'Example.Lst1' ⎕WI 'size' 5 30
Create an object called Lst1, as above, but this time set the size property at the time you create it:
'Example.Lst1' ⎕WI 'New' 'List' ('size' 5 30)
Put a set of choices (contained in the variable NAMES) into the list box by setting its list property:
'Example.Lst1' ⎕WI 'list' NAMES
Read back the selection which the user has made by reading the value property of the list box:
'Example.Lst1' ⎕WI 'value'
2
Syntax of ⎕WI
The exact syntax of ⎕WI for the three possible cases is as follows:
Setting a property:
ObjectName ⎕WI PropertyName Value
ObjectName and PropertyName are character vectors, and Value can be any APL array valid for the particular property in question. The right argument to ⎕WI is thus a two-element nested vector. However, as a convenience ⎕WI accepts any length of nested array vector and treats the first element as the property name and the rest of the argument as the property value, so that the following two statements are both valid and do exactly the same thing:
'Win1.But' ⎕WI 'where' (12 20 3 8) ⍝ Two-element vector
'Win1.But' ⎕WI 'where' 12 20 3 8 ⍝ Five-element vector
Reading a property:
Value ← ObjectName ⎕WI PropertyName
ObjectName and PropertyName are character vectors as before, and the current value for the property is returned as the explicit result of ⎕WI. For example:
'Win1.But' ⎕WI 'where'
12 20 3 8
'Win1.But' ⎕WI 'caption'
Cancel
Invoking a method:
ObjectName ⎕WI MethodName {Argument}
ObjectName and MethodName are character vectors, and Argument is an optional argument to the method. It can be any APL array valid for the particular method in question. Again, ⎕WI accepts any length of nested array vector and treats the first element as the method name and the rest as the argument to the method.
'Win1.Movie' ⎕WI 'Rewind' ⍝ Method with no argument
'Win1.But' ⎕WI 'New' 'Button' ⍝ Argument is 'Button'
See the separate documentation on System Classes and User-Interface Programming for full details.
Console and Server versions of APLX
In Console versions of APLX, there is no GUI interface and therefore nearly all of ⎕WI is not implemented. Only the Socket object, and a subset of the System object, are currently available. In Client-Server edititions of APLX, ⎕WI is fully implemented, and runs on the Client machine.
|