Programmer Guide/General Descriptions/Shell Environment: Difference between revisions

From STX Wiki
Jump to navigationJump to search
m (1 revision: Initial import)
 
(28 intermediate revisions by 2 users not shown)
Line 1: Line 1:
{{DISPLAYTITLE:{{SUBPAGENAME}}}}
{{DISPLAYTITLE:{{SUBPAGENAME}}}}
====Shell Environment (first character not equal to @, # or &)====
{{Shell}}
Variables which do not begin with <code>@</code>, <code>#</code> or <code>&amp;</code> (i.e. all variables beginning with an alphanumeric character) are so-called ''shell environment'' variables. You can use shell variables yourself when programming. The following shell variables have predefined uses:


Variables which do not begin with @, # or & (i.e. all variables beginning with an alphanumeric character) are so-called shell environment variables.APPMODE<code>APPMODE = applicationrunmode</code>
== <var>APPMODE</var>, the application run-mode ==


The shell variable <code>APPMODE</code> indicates the current mode the application <code>APPMAIN</code> is in. A value of <code>0</code> indicates that <code>APPNAME</code> is inactive or finished; a value of <code>1</code> indicates that <code>APPNAME</code> is currently active..
The shell variable <code>APPMODE</code> indicates the current mode the application <code>APPMAIN</code> is in. A value of <code>0</code> indicates that <code>APPNAME</code> is inactive or finished; a value of <code>1</code> indicates that <code>APPNAME</code> is currently active..


APPNAME<code>APPNAME = applicationname</code>
== <var>APPNAME</var>, the application name ==


The shell variable <code>APPNAME</code> is defined in the registration entry in the configuration files. To start the shell application defined and registered in the configuration files, the macro <code>APPMAIN</code> is used. Before calling the application's main macro (called: RUNappname), <code>APPMAIN</code> assigns the application name to the variable <code>APPNAME</code> and sets the application mode <code>APPMODE</code> to active (<code>1</code>). The variable <code>APPMODE</code> is used by the macro <code>GETMESSAGE</code> to check the application mode. If <code>APPMODE</code> is set to <code>0</code> (e.g. in a message handler) <code>GETMESSAGE</code> stops receiving messages and returns the value <code>* * * *</code>.
The shell variable <code>APPNAME</code> is defined in the registration entry in the configuration files. To start the shell application defined and registered in the configuration files, the macro <code>APPMAIN</code> is used. Before calling the application's main macro (called: RUNappname), <code>APPMAIN</code> assigns the application name to the variable <code>APPNAME</code> and sets the application mode <code>APPMODE</code> to active (<code>1</code>). The variable <code>APPMODE</code> is used by the macro <code>GETMESSAGE</code> to check the application mode. If <code>APPMODE</code> is set to <code>0</code> (e.g. in a message handler) <code>GETMESSAGE</code> stops receiving messages and returns the value <code>* * * *</code>.
Line 12: Line 13:
Applications started via <code>APPMAIN</code> must never use <code>EXIT 0</code> to terminate the shell. They must return to <code>APPMAIN</code> (using a normal <code>EXIT 1</code> command from the main macro) which performs some clean-up functions before the shell is terminated.
Applications started via <code>APPMAIN</code> must never use <code>EXIT 0</code> to terminate the shell. They must return to <code>APPMAIN</code> (using a normal <code>EXIT 1</code> command from the main macro) which performs some clean-up functions before the shell is terminated.


CSF<code>CSF = currentsoundfilename</code>
== <var>CSF</var>, the name of the current sound file ==


<code>CSFH = srate channels samples code type mode</code>
The name (full path) of the current, i.e. active sound file is assigned to the variable <var>CSF</var> when a <code>LOAD</code> (open) or <code>UNLOAD</code> (close) command is executed. If <var>CSF</var> is not set (i.e. empty), no sound file is active.


The name (full path) of the current/active soundfile is assigned to the variable <code>CSF</code> when a <code>LOAD</code> (open) or <code>UNLOAD</code> (close) command is executed. If <code>CSF</code> is not set (i.e. empty), no soundfile is active.
== <var>CSFH</var>, properties of the current sound file ==


CSFH<code>CSFH = srate channels samples code type mode</code>
<var>CSFH</var> = <var>srate</var> <var>channels</var> <var>samples</var> <var>code</var> <var>type</var> <var>mode</var>


The parameters of the current/active soundfile are assigned to the variable <code>CSFH</code> when a <code>LOAD</code> (open) or <code>UNLOAD</code> (close) command is executed.
The parameters of the current/active sound file are assigned to the variable <code>CSFH</code> when a <code>LOAD</code> (open) or <code>UNLOAD</code> (close) command is executed.


EMSG<code>EMSG = errortext</code>
== <var>EMSG</var>, the current error message string ==


If an error occurs, the description text corresponding to the return code <code>RC</code> is stored in <code>EMSG</code>.
If an error occurs, the textual description corresponding to the return code <var>RC</var> is stored in <var>EMSG</var>.


Note that you can use the command <code>EMSG</code> to retrieve a description of an error code.
Note that you can use the command [[Programmer_Guide/Command_Reference/EMSG|<code>EMSG</code>]] to retrieve a description of an error code.


PARENT<code>PARENT = windowitemname</code>
== <var>PARENT</var>, the parent window ==


The variable <code>PARENT</code> is used by the window-management functions (e.g. in <code>GETMESSAGE</code> or by <code>DOMODALDIALOG</code>) to identify the parent (main) window of an application. In each application the name of the item (of type display or dialog) used as main window should be assigned to this variable (directly after creation). If <code>PARENT</code> is not set, some functions or user interactions will not work correctly (e.g. minimize/restore).
PARENT = windowitemname
 
The variable <code>PARENT</code> is used by the window-management functions (e.g. in <code>GETMESSAGE</code> or by <code>DOMODALDIALOG</code>) to identify the parent (main) window of an application. In each application the name of the item (of type display or dialog) used as main window should be assigned to this variable (directly after creation). If <var>PARENT</var> is not set, some functions or user interactions will not work correctly (e.g. minimize/restore).


Special processing applied to the main window:
Special processing applied to the main window:


*The main-window item's close message is translated by <code>GETMESSAGE</code> into the message <code>SHELL thisshell EXIT</code>.
*If the application is minimized, the main window is displayed in the taskbar while all other window are set to invisible. On restore, all windows are restored to their last status/position.
== <var>RC</var>, the return code ==
The return code of the last executed command. See [[Programmer_Guide/General_Descriptions/Return_Codes#RC|Command Return Codes]] for details.
== <var>RESULT</var>, the macro result ==


*The main-window item's close message is translated by <code>GETMESSAGE</code> into the message <code>SHELL thisshell EXIT</code>.
The value returned by the previous macro. See [[Programmer_Guide/General_Descriptions/Return_Codes#RESULT|Macro Results]] for details.
 
== <var>SCRIPTDIRECTORY</var>, the directory of the running script ==
 
The shell variable <var>SCRIPTDIRECTORY</var> is available when an {{STX}} script (*.sts) is running. It contains the directory path where the running script file is stored.


*If the application is minimized, the main window is displayed in the taskbar while all other window are set to invisible. On restore, all windows are restored to their last status/position.
== <var>SCRIPTFILEPATH</var>, the filename of the running script ==


RC<code>RC = command_return_code</code>
The shell variable <var>SCRIPTFILEPATH</var> is available when an {{STX}} script (*.sts) is running. It contains the name of the running script file including the path.


The last command's return code. See Return Codes for details.
==<var>SCRIPTMAINNAME</var>, the running macro ==


RESULT<code>RESULT = macro_result</code>
The shell variable <var>SCRIPTMAINNAME</var> is available when an {{STX}} script (*.sts) is running. It contains the name of the running macro.


The value returned by the previous macro. See Return Codes for details.
== <var>SCRIPTREVISION</var>, the creating {{STX}} version number ==


SCRIPTDIRECTORYThe shell variable <code>SCRIPTDIRECTORY</code> is available when an S_TOOLS-STx script (*.sts) is running. It contains the directory path where the running script file is.
The shell variable <var>SCRIPTREVISION</var> contains the Subversion repository revision number of the {{STX}} version used to create the current script. For scripts created before r751, this variable is set to 0.


SCRIPTFILEPATHThe shell variable <code>SCRIPTFILEPATH</code> is available when an S_TOOLS-STx script (*.sts) is running. It contains the name of the name of the running script file including the path.
== <var>SHELL</var>, the executing and the calling shell ==


SCRIPTMAINNAMEThe shell variable <code>SCRIPTMAINNAME</code> is available when an S_TOOLS-STx script (*.sts) is running. It contains the name of the running macro.
The variable <var>SHELL</var> is generated during the startup code execution of the shell called via the command [[Programmer_Guide/Command_Reference/SHELL|<code>SHELL</code>]]. Its format is


SCRIPTREVISIONThe shell variable <code>SCRIPTREVISION</code> contains the Subversion repository revision number of the S_TOOLS-STx version used to create the current script. For scripts created before r751, this variable is set to 0.
<var>thisshellid</var> <var>callershellid</var>


SHELL<code>SHELL = thisshellid [callershellid]</code>
with <var>callershellid</var> being the ID of the calling shell, and <var>thisshellid</var> being the ID of the new shell. The one exception is the master shell (the first one to be started (automatically) during program initialization) which only stores its own id in <var>SHELL</var>.


The variable <code>SHELL</code> is generated during the startup code execution of the shell called via the command <code>SHELL</code>. Both the id of the calling shell (<code>callershellid</code>) and that of new shell (<code>thisshellid</code>) are assigned. The one exception is the master shell (the first one to be started (automatically) during program initialization) which only stores its own id in <code>SHELL</code>.
== <var>STXREVISION</var>, the executing {{STx}} version ==


STXREVISIONThe shell variable <code>STXREVISION</code> contains the Subversion repository revision number of the running S_TOOLS-STx version.
The shell variable <var>STXREVISION</var> contains the Subversion repository revision number of the running {{STX}} version. This variable is only available in scripts.


XRC<code>XRC := system return code</code>
== <var>XRC</var>, the system return code ==


The value returned by the system when the command <code>SYSTEM</code> is called.
The value returned by the operating system when the command [[Programmer_Guide/Command_Reference/SYSTEM|<code>SYSTEM</code>]] has been called.


[[Category:Programmer Guide]][[Category:General Descriptions]]
[[Category:Programmer Guide]][[Category:General Descriptions]]

Latest revision as of 12:18, 24 October 2019

Variables which do not begin with @, # or & (i.e. all variables beginning with an alphanumeric character) are so-called shell environment variables. You can use shell variables yourself when programming. The following shell variables have predefined uses:

APPMODE, the application run-mode

The shell variable APPMODE indicates the current mode the application APPMAIN is in. A value of 0 indicates that APPNAME is inactive or finished; a value of 1 indicates that APPNAME is currently active..

APPNAME, the application name

The shell variable APPNAME is defined in the registration entry in the configuration files. To start the shell application defined and registered in the configuration files, the macro APPMAIN is used. Before calling the application's main macro (called: RUNappname), APPMAIN assigns the application name to the variable APPNAME and sets the application mode APPMODE to active (1). The variable APPMODE is used by the macro GETMESSAGE to check the application mode. If APPMODE is set to 0 (e.g. in a message handler) GETMESSAGE stops receiving messages and returns the value * * * *.

Applications started via APPMAIN must never use EXIT 0 to terminate the shell. They must return to APPMAIN (using a normal EXIT 1 command from the main macro) which performs some clean-up functions before the shell is terminated.

CSF, the name of the current sound file

The name (full path) of the current, i.e. active sound file is assigned to the variable CSF when a LOAD (open) or UNLOAD (close) command is executed. If CSF is not set (i.e. empty), no sound file is active.

CSFH, properties of the current sound file

CSFH = srate channels samples code type mode

The parameters of the current/active sound file are assigned to the variable CSFH when a LOAD (open) or UNLOAD (close) command is executed.

EMSG, the current error message string

If an error occurs, the textual description corresponding to the return code RC is stored in EMSG.

Note that you can use the command EMSG to retrieve a description of an error code.

PARENT, the parent window

PARENT = windowitemname

The variable PARENT is used by the window-management functions (e.g. in GETMESSAGE or by DOMODALDIALOG) to identify the parent (main) window of an application. In each application the name of the item (of type display or dialog) used as main window should be assigned to this variable (directly after creation). If PARENT is not set, some functions or user interactions will not work correctly (e.g. minimize/restore).

Special processing applied to the main window:

  • The main-window item's close message is translated by GETMESSAGE into the message SHELL thisshell EXIT.
  • If the application is minimized, the main window is displayed in the taskbar while all other window are set to invisible. On restore, all windows are restored to their last status/position.

RC, the return code

The return code of the last executed command. See Command Return Codes for details.

RESULT, the macro result

The value returned by the previous macro. See Macro Results for details.

SCRIPTDIRECTORY, the directory of the running script

The shell variable SCRIPTDIRECTORY is available when an STx script (*.sts) is running. It contains the directory path where the running script file is stored.

SCRIPTFILEPATH, the filename of the running script

The shell variable SCRIPTFILEPATH is available when an STx script (*.sts) is running. It contains the name of the running script file including the path.

SCRIPTMAINNAME, the running macro

The shell variable SCRIPTMAINNAME is available when an STx script (*.sts) is running. It contains the name of the running macro.

SCRIPTREVISION, the creating STx version number

The shell variable SCRIPTREVISION contains the Subversion repository revision number of the STx version used to create the current script. For scripts created before r751, this variable is set to 0.

SHELL, the executing and the calling shell

The variable SHELL is generated during the startup code execution of the shell called via the command SHELL. Its format is

thisshellid callershellid

with callershellid being the ID of the calling shell, and thisshellid being the ID of the new shell. The one exception is the master shell (the first one to be started (automatically) during program initialization) which only stores its own id in SHELL.

STXREVISION, the executing STx version

The shell variable STXREVISION contains the Subversion repository revision number of the running STx version. This variable is only available in scripts.

XRC, the system return code

The value returned by the operating system when the command SYSTEM has been called.

Navigation menu

Personal tools