Programmer Guide/Command Reference/MESSAGE: Difference between revisions
m (1 revision: Initial import) |
No edit summary |
||
(40 intermediate revisions by 5 users not shown) | |||
Line 1: | Line 1: | ||
{{DISPLAYTITLE:{{SUBPAGENAME}}}} | {{DISPLAYTITLE:{{SUBPAGENAME}}}}__NOTOC__ | ||
The <code>MESSAGE</code> command is a low-level means for processing shell messages in {{STX}}. There are a number of different sub-commands you may pass to the command (see below). Many of the sub-commands use the variable <var>#msg</var> to return values. The <code>MESSAGE</code> command may be abbreviated to <code>MSG</code>. | |||
If you want to use macro message handlers in an application, you need to call the macro <code>[[Programmer_Guide/Macro_Library#GetMessage|GETMESSAGE]]</code> to retrieve messages, instead of directly using the <code>MESSAGE</code> command. In conjunction with the macros <code>[[Programmer_Guide/Macro_Library#SetMsgHandler|SETMSGHANDLER]]</code> | |||
and <code>[[Programmer_Guide/Macro_Library#DispatchMsg|DISPATCHMSG]]</code>, the <code>[[Programmer_Guide/Macro_Library#GetMessage|GETMESSAGE]]</code> macro implements the standard {{STX}} message handling system. | |||
'''Note:''' For message handling in ''classes'', you may use the member functions <code>[[Programmer_Guide/Macro_Library/COBJ#AttachItem_.2F_AttachShell|AttachItem]]</code>, <code>[[Programmer_Guide/Macro_Library/COBJ#DetachItem_.2F_DetachShell|DetachItem]]</code> and <code>[[Programmer_Guide/Macro_Library/COBJ#MsgHandler|MsgHandler]]</code> as an alternative better suited to the object-oriented use-case. | |||
;Sub-commands: [[#MESSAGE BEEP|BEEP]], [[#MESSAGE DEBUG|DEBUG]], [[#MESSAGE DESKTOP|DESKTOP]], [[#MESSAGE EXIT|EXIT]], [[#MESSAGE LOGFILE|LOGFILE]], [[#MESSAGE LOOP|LOOP]], [[#MESSAGE MAIN|MAIN]], [[#MESSAGE MENU|MENU]], [[#MESSAGE NOMAIN|NOMAIN]], [[#MESSAGE RUN|RUN]], [[#MESSAGE QUEUE|QUEUE]] | |||
The complete set of | The complete set of {{STX}} messages is listed under [[Messages/Communication Messages]].<!-- where's the link? XXX --> | ||
== | == Sub-commands == | ||
<code>MESSAGE BEEP | === <code>MESSAGE BEEP</code> === | ||
MESSAGE BEEP /Speaker|Asterisk|Exclamation|Hand|Question|Okay | |||
MESSAGE BEEP <var>frequency</var> <var>duration</var> | |||
Play a tone via the PC loudspeaker. A standard windows sound (selected with an option) or a <var>frequency</var> (Hz) and <var>duration</var> (ms) | Play a tone via the PC loudspeaker. A standard windows sound (selected with an option) or a <var>frequency</var> ([http://en.wikipedia.org/wiki/Hertz Hz]) and <var>duration</var> ([http://en.wikipedia.org/wiki/Millisecond ms]) may be specified. No commands are processed while the sound is being played. | ||
=== | === <code>MESSAGE DEBUG</code> === | ||
The <code>MSG DEBUG</code> command has the following general syntax: | The <code>MSG DEBUG</code> command interacts with the {{STX}} interactive debugging tool. The command has the following general syntax: | ||
MSG DEBUG <var>cmd</var> [ <var>par</var> ] [ option ] | |||
There are a number of different sub-commands which are described below. | There are a number of different sub-sub-commands which are described below. | ||
MSG DEBUG INIT [ <var>shell</var> ] [ /Step ] | |||
Initialize the debugger. This must be called exactly ''once'', and it must be called ''first'', i.e., before any other <code>MSG DEBUG</code> commands. | |||
;<var>shell</var> | ;<var>shell</var> | ||
:The shell in which to start the debugger (i.e., whose script to debug). If you omit this information, the caller's shell will be debugged. | |||
;<var>/Step</var> | |||
:If specified, the debugger interrupts execution (like calling <code>MSG DEBUG STEP</code>). It will wait for an interactive command to resume. | |||
MSG DEBUG STEP [ <var>text</var> ] | |||
Open the debugger and interrupt execution. That's just the same like <code>MSG DEBUG INIT /Step</code>. | |||
MSG DEBUG ON [ <var>macroName</var> ] | |||
Open the debugger. If a macro is specified, the debugger will stop execution as soon as the control flow enters the respective macro. | |||
MSG DEBUG OFF | |||
Close the debugger. | |||
MSG DEBUG NO | |||
Close the debugger and disable debugging. If you wish to re-enable the debugger, you must restart {{STX}} altogether. | |||
=== <code>MESSAGE DESKTOP</code> === | |||
MESSAGE DESKTOP | |||
The <code>MESSAGE DESKTOP</code> command retrieves the origin, the height and the width of the whole desktop (all monitors), as well as the number of monitors connected to the computer. Furthermore, for each monitor, it will return its virtual coordinates (left, top, right, and bottom, in this order). It returns this information in the <var>#MSG</var> variable in the following format: | |||
<var>desktopWidth</var> <var>desktopHeight</var> <var>desktopXOrigin</var> <var>desktopYOrigin</var> <var>numberOfMonitors</var> | |||
<var>left<sub>1</sub></var> <var>top<sub>1</sub></var> <var>right<sub>1</sub></var> <var>bottom<sub>1</sub></var>… <var>left<sub>N</sub></var> <var>top<sub>N</sub></var> <var>right<sub>N</sub></var> <var>bottom<sub>N</sub></var> | |||
< | Note that the primary monitor always has an origin of 0/0 (x/y). Therefore, if you have three monitors, and the middle one is the primary monitor, the value <var>desktopXOrigin</var> will be negative. | ||
Code example: | |||
msg desktop | |||
readvar #msg #width #height #x0 #y0 #screencount # | |||
=== | === <code>MESSAGE EXIT</code> === | ||
< | MESSAGE EXIT <var>shellid</var> | ||
Terminate a shell <var>shellid</var> immediately. This message is processed by the internal message loop and not by the macros. It can be used to abort shells which are not responding. | |||
<code> | === <code>MESSAGE LOGFILE</code> === | ||
MESSAGE LOGFILE <var>logfilename</var> | |||
MESSAGE LOGFILE * | |||
< | Redirect all log window output to the specified file. Set <var>logfilename</var> to <code>*</code> to turn redirection off. | ||
=== <code>MESSAGE LOOP</code> === | |||
MESSAGE LOOP [ /Nowait ] | |||
<code>MESSAGE | Get the next message from the message queue of the shell. If the message queue is empty, the <code>MESSAGE LOOP</code> command will normally block until there is a message available. For non-blocking operation, use the <code>/Nowait</code> option: With <code>/Nowait</code> supplied, the command will return immediately should the message queue be empty. | ||
The return values of the <code>MESSAGE LOOP</code> command are stored in the <var>#MSG</var> variable in the following format: | |||
<var>sendertype</var> <var>sendername</var> <var>msgid</var> <var>msgparameter<sub>1</sub></var>…<var>msgparameter<sub>n</sub></var> | |||
Code example: | |||
msg loop | |||
readvar #msg #sendertype #sendername #msgid #parms | |||
=== <code>MESSAGE MAIN</code> === | |||
< | MESSAGE MAIN <var>mode</var> [<var>style</var> <var>xpos</var> <var>ypos</var> <var>width</var> <var>height </var> <var>title</var>] | ||
Set and/or get the mode of the log window (one out of <code>HIDDEN</code>, <code>VISIBLE</code>, <code>ENABLED</code>, <code>*</code>), its style (one out of <code>MINIMIZED</code>, <code>RESTORED</code>, <code>MAXIMIZED</code>, <code>*</code>), and its position, size and/or caption. The current settings are stored in the message variable <code>#MSG</code> in the following format: | |||
< | <var>mode</var> <var>style</var> <var>xpos</var> <var>ypos</var> <var>width</var> <var>height</var> <var>title</var> | ||
=== <code>MESSAGE MENU</code> === | |||
< | MESSAGE MENU /Addpopup <var>name</var> <var>item<sub>1</sub></var> <var>item<sub>2</sub></var>… | ||
MESSAGE MENU /Addpopup <var>name</var> <var>table</var> /Table | |||
MESSAGE MENU /Show | |||
MESSAGE MENU /Delete | |||
The <code>MESSAGE MENU</code> command is for handling log window popup menus. Its sub-commands are similar to the corresponding [[Programmer_Guide/Shell_Items/Dialog/SET_DIALOG#Dialog_Context_Menus|dialog item commands]] for handling popup menus, <code>[[Programmer_Guide/Shell_Items/Dialog/SET_DIALOG#ADDPOPUP|ADDPOPUP]]</code> and <code>[[Programmer_Guide/Shell_Items/Dialog/SET_DIALOG#DELPOPUP|DELPOPUP]]</code> (see there). | |||
<code>MESSAGE | === <code>MESSAGE NOMAIN</code> === | ||
MESSAGE NOMAIN | |||
This will hide the log window and all other {{STX}} windows. | |||
<code>MESSAGE | === <code>MESSAGE RUN</code> === | ||
MESSAGE RUN <var>shellid</var> <var>messageid</var> <var>messegaparameters</var> | |||
The <code>MESSAGE RUN</code> command will send a message to the shell <var>shellid</var>. ''Do not'' use this command directly! Instead, always call the macro <code>POSTMESSAGE</code>. | |||
<code> | If you supply an asterisk, <code>*</code> for the <var>shellid</var> argument (which you won't because you never call this command directly), the message will be sent to ''all'' shells except the sending shell. If you supply the character "<code>=</code>" (which you won't either, because you never call this command directly), the message will be sent to the sending shell itself. | ||
Messages sent using the <code>MESSAGE RUN</code> command are pre-processed by the macro <code>GETMESSAGE</code>. | |||
=== | === <code>MESSAGE QUEUE</code> === | ||
MESSAGE QUEUE [ <var>qtable</var> ] | |||
Empty the internal message queue. If the argument <var>qtable</var> is a simple table, a copy of the internal message queue is stored in the table before actually clearing the message queue. |
Latest revision as of 13:39, 6 August 2019
The MESSAGE
command is a low-level means for processing shell messages in STx. There are a number of different sub-commands you may pass to the command (see below). Many of the sub-commands use the variable #msg to return values. The MESSAGE
command may be abbreviated to MSG
.
If you want to use macro message handlers in an application, you need to call the macro GETMESSAGE
to retrieve messages, instead of directly using the MESSAGE
command. In conjunction with the macros SETMSGHANDLER
and DISPATCHMSG
, the GETMESSAGE
macro implements the standard STx message handling system.
Note: For message handling in classes, you may use the member functions AttachItem
, DetachItem
and MsgHandler
as an alternative better suited to the object-oriented use-case.
The complete set of STx messages is listed under Messages/Communication Messages.
Sub-commands
MESSAGE BEEP
MESSAGE BEEP /Speaker|Asterisk|Exclamation|Hand|Question|Okay MESSAGE BEEP frequency duration
Play a tone via the PC loudspeaker. A standard windows sound (selected with an option) or a frequency (Hz) and duration (ms) may be specified. No commands are processed while the sound is being played.
MESSAGE DEBUG
The MSG DEBUG
command interacts with the STx interactive debugging tool. The command has the following general syntax:
MSG DEBUG cmd [ par ] [ option ]
There are a number of different sub-sub-commands which are described below.
MSG DEBUG INIT [ shell ] [ /Step ]
Initialize the debugger. This must be called exactly once, and it must be called first, i.e., before any other MSG DEBUG
commands.
- shell
- The shell in which to start the debugger (i.e., whose script to debug). If you omit this information, the caller's shell will be debugged.
- /Step
- If specified, the debugger interrupts execution (like calling
MSG DEBUG STEP
). It will wait for an interactive command to resume.
MSG DEBUG STEP [ text ]
Open the debugger and interrupt execution. That's just the same like MSG DEBUG INIT /Step
.
MSG DEBUG ON [ macroName ]
Open the debugger. If a macro is specified, the debugger will stop execution as soon as the control flow enters the respective macro.
MSG DEBUG OFF
Close the debugger.
MSG DEBUG NO
Close the debugger and disable debugging. If you wish to re-enable the debugger, you must restart STx altogether.
MESSAGE DESKTOP
MESSAGE DESKTOP
The MESSAGE DESKTOP
command retrieves the origin, the height and the width of the whole desktop (all monitors), as well as the number of monitors connected to the computer. Furthermore, for each monitor, it will return its virtual coordinates (left, top, right, and bottom, in this order). It returns this information in the #MSG variable in the following format:
desktopWidth desktopHeight desktopXOrigin desktopYOrigin numberOfMonitors left1 top1 right1 bottom1… leftN topN rightN bottomN
Note that the primary monitor always has an origin of 0/0 (x/y). Therefore, if you have three monitors, and the middle one is the primary monitor, the value desktopXOrigin will be negative.
Code example:
msg desktop readvar #msg #width #height #x0 #y0 #screencount #
MESSAGE EXIT
MESSAGE EXIT shellid
Terminate a shell shellid immediately. This message is processed by the internal message loop and not by the macros. It can be used to abort shells which are not responding.
MESSAGE LOGFILE
MESSAGE LOGFILE logfilename MESSAGE LOGFILE *
Redirect all log window output to the specified file. Set logfilename to *
to turn redirection off.
MESSAGE LOOP
MESSAGE LOOP [ /Nowait ]
Get the next message from the message queue of the shell. If the message queue is empty, the MESSAGE LOOP
command will normally block until there is a message available. For non-blocking operation, use the /Nowait
option: With /Nowait
supplied, the command will return immediately should the message queue be empty.
The return values of the MESSAGE LOOP
command are stored in the #MSG variable in the following format:
sendertype sendername msgid msgparameter1…msgparametern
Code example:
msg loop readvar #msg #sendertype #sendername #msgid #parms
MESSAGE MAIN
MESSAGE MAIN mode [style xpos ypos width height title]
Set and/or get the mode of the log window (one out of HIDDEN
, VISIBLE
, ENABLED
, *
), its style (one out of MINIMIZED
, RESTORED
, MAXIMIZED
, *
), and its position, size and/or caption. The current settings are stored in the message variable #MSG
in the following format:
mode style xpos ypos width height title
MESSAGE MENU
MESSAGE MENU /Addpopup name item1 item2… MESSAGE MENU /Addpopup name table /Table MESSAGE MENU /Show MESSAGE MENU /Delete
The MESSAGE MENU
command is for handling log window popup menus. Its sub-commands are similar to the corresponding dialog item commands for handling popup menus, ADDPOPUP
and DELPOPUP
(see there).
MESSAGE NOMAIN
MESSAGE NOMAIN
This will hide the log window and all other STx windows.
MESSAGE RUN
MESSAGE RUN shellid messageid messegaparameters
The MESSAGE RUN
command will send a message to the shell shellid. Do not use this command directly! Instead, always call the macro POSTMESSAGE
.
If you supply an asterisk, *
for the shellid argument (which you won't because you never call this command directly), the message will be sent to all shells except the sending shell. If you supply the character "=
" (which you won't either, because you never call this command directly), the message will be sent to the sending shell itself.
Messages sent using the MESSAGE RUN
command are pre-processed by the macro GETMESSAGE
.
MESSAGE QUEUE
MESSAGE QUEUE [ qtable ]
Empty the internal message queue. If the argument qtable is a simple table, a copy of the internal message queue is stored in the table before actually clearing the message queue.