![]() | Bray Script: Keywords | ![]() |
![]() | ||
![]() | ||
Mule Resources
The Mule is a trademark of Altek Instruments Ltd Support Services
|
Bray KeywordsGeneral
Keyword List:DEFINE, DEFDefine or redefine a Braced PacketDEFINE and DEF are synonymous - either form can be used. DescriptionDEFINE Creates a Braced Packet param1 with the Scancode String value param2. If a Braced Packet of the same name already exists it will be redefined with the new Scancode String value. The Braced Packet 'key' can consist of any alphanumeric character plus the 3 characters: dot hyphen underscore. The Braced Packet 'key' is not case sensitive so {EXAMPLE} {Example} and {example} all refer to the same Packet. Param2 represents a Scancode String. Param2 follows all the normal rules of embedding and concatenation but param2 must resolve entirely into Scancodes and therefore ASCII strings cannot be included. If a Braced Packet is defined in terms of a second (already defined) packet the value of the second packet is passed by value, not by reference. This means that any redefinition of a packet never affects any other packet. Examples:In this example we assign the Scancodes for the keystroke k to the packet {key.k}. Notice that the Scancode String must be surrounded by single quotes. Scancodes can be found by using our web tool - The Keyboard Emulator.
Here we use the packet {key.k} to define {alt.k}. The {altdn} and {altup} packets are already defined in Bray. Notice that single quotes are not needed. The example demonstates auto concatenation of the three pre defined packets
{alt.k} could equally well have been defined in a single step with either of these 3 alternatives. Alternative syntax 1: Define in terms of raw scancode primitives. Notice the use of white space to assist readability.
Alternative syntax 2: Demonstrates the use of packets embedded in the Scancode String.
Alternative syntax 3: Similar to 2 except the predefined packets are outside the Scancode String and auto concatenated.
National KeyboardsDEFINE provides a useful mechanism to handle the way some national keyboard layouts deviate from the conventional USA layout. For example the UK keyboard has the Pound currency symbol located above the Numeric 3 key. It has an extra key (keynumber 42) for the hash and tilda characters. The Double Quote and the '@' are also relocated. Here are the 5 defines needed for the UK keyboard:
PAUSEWait for a period before continuingDescriptionWhere number is a value representing seconds in the range 0 - 3600. Number must be positive. The maximum pause period is 1 hour. Number used will be rounded to the maximum precision available from a single precision floating point value. Do not expect timing accuracy to be better than about 0.05 seconds. Examples:Pause for 1.5 seconds...
Pause for 7 seconds...
Pause for 1 minute...
PORTSet the port to use for the Forward Channel[Command available since Bray v1.5]DescriptionThe PORT command tells the Forward Channel which port to use when sending the Action Stream to the Mule for future operations. The PORT request is logged but no further action to initialize or verify the PORT it taken until Bray needs to output data to the Forward Channel. This allows a subsequent SWITCH command to disable port initialization if the port is not available on the current machine. The corollary is that any error resulting from port initialization is not reported until real output is attempted. The valid PORT range is COM1 thru COM99 (depending on the availability of suitable hardware). Notice there is no trailing colon on the comport ID. All PORT opening/closing operations and RS232 settings like baud rate, handshake, buffering, start/stop/parity bits are set up to match The Mule defaults and handled automatically. Issuing a PORT command for non existent hardware or for ports allocated to other running applications can result in computer hangs and latch up. Phantom COM PORTS like those emulated by special purpose hardware (example USB to RS232 adaptors) should operate correctly but this is dependant on the driver provided by the hardware manufacturer. Examples:Use COM1 for future Forward Channel communications...
Use COM12 for future Forward Channel communications...
SOUNDSound an alert tone from the Primary Computer
DescriptionThis keyword does not take a parameter SOUND plays the default Windows waveform sound, typically a ¼ second tone, through either the built-in speaker or a sound card if installed (in which case the Windows "Default Beep" sound is played). The Default Beep can be configured in the Sounds section of Control Panel. If sounds are disabled in Windows Control Panel the SOUND keyword will be ignored. Examples:Sound a tone if sounds are enabled in Windows Control Panel... SWITCHControls Channels and StreamsSyntax 1: Set individual flags where flag value can be are 0 1 or -
Syntax 2:Reset channel to default state. If channel is null then both channels are reset.
Syntax 3:Report state of flags for channel. If channel is null then both channels are reported.
DescriptionThe SWITCH keyword controls how the Bray interpreter communicates with the outside world by routing the Bray Communications Streams. More on Channels and Streams here. The parameter to address the Forward Channel is 0. To address the Backward Channel use 1. Bray uses a set of internal flags to decide how to route each stream. Each stream can be optionally routed to either channel. By default the Action stream is routed to the Forward Channel, the other streams are routed to the Backward Channel. The SWITCH command acts directly on the internal flags. The default behaviour is usually suitable for normal running but there are a number of situations when you may need to change things. For example...
Syntax 1: DetailsBray uses a set of internal flags to route each stream. The SWITCH command acts directly on the internal flags. Each Channel has six flags identified by a single capital letter. Flags can be set (have value 1) or cleared (have value 0) or left unchanged (have value -). The six flags are as follows...
When flags are specified in a SWITCH command parameter data must be in the order KAECSN. Data for ALL the switches must be provided. Data for each flag must be one of these:
Notes on the Numbering flag 1: The Numbering flag affects whether source lines are transmitted. If the N flag is cleared then only non-blank source lines are transmitted. If set then all lines (including blank lines) will be prepended with a line number and transmitted. This is the default. 2: A line of Bray entered into the Immediate Mode box will be numbered 1: because it is treated exactly as a 1 line script. Syntax 2: DetailsIf the Channel Number is provided but the Flags parameter is not supplied then SWITCH resets the flags for the channel to default. If neither the Channel Number nor the Flags are given (empty parentheses) then SWITCH resets the flags for both channels to default.
Default values for channel 0 (Forward Channel)
Default values for channel 1 (Backward Channel)
Syntax 3: DetailsTo learn the current state of the SWITCH flags use a '?' character before the Channel number. Bray ALWAYS returns the state using the Commentary stream by the Backward Channel. This stream/channel is ALWAYS used for this particular purpose regardless of the current SWITCH flags configuration. If the channel number is not given the flag status of both channels is reported Examples:Kill all output to the Forward Channel...
Restore channel 0 to default
Report the current status of Forward Channel...
Report the current status of both channels...
Send only Errors to the Backward Channel...
Send only Errors and the Source Line to the Backward Channel...
Send the Action stream and the Source Line to the Backward Channel...
|
![]() | |
![]() | |
| Top Home | © Altek Instruments Ltd, 2008 |