Programmer Guide/Macro Library/CObjEx: Difference between revisions
From STX Wiki
Jump to navigationJump to search
No edit summary |
No edit summary |
||
Line 2: | Line 2: | ||
*'''File''': CLASSES.STX, linked to library STX.LIB | *'''File''': CLASSES.STX, linked to library STX.LIB | ||
*'''Title''': Base class for objects used in script applications | *'''Title''': Base class for objects used in script applications | ||
*'''Parent''': [[Programmer_Guide/Macro_Library/CObj| | *'''Parent''': [[Programmer_Guide/Macro_Library/CObj|COBJ]], '''Derived classes''': [[Programmer_Guide/Macro_Library/XPlot|XPlot]], [[Programmer_Guide/Macro_Library/XGraph|XGraph]], [[Programmer_Guide/Macro_Library/XWave|XWave]] | ||
The class <code>CObjEx</code> is an enhanced base class designed for objects which are used in {{STX}} scripts. Objects based on this class are deleted automatically before the script application is finished. By convention a class based on <code>CObjEx</code> implements the following simple instantiation method: | The class <code>CObjEx</code> is an enhanced base class designed for objects which are used in {{STX}} scripts. Objects based on this class are deleted automatically before the script application is finished. By convention a class based on <code>CObjEx</code> implements the following simple instantiation method: |
Revision as of 12:34, 7 March 2018
- File: CLASSES.STX, linked to library STX.LIB
- Title: Base class for objects used in script applications
- Parent: COBJ, Derived classes: XPlot, XGraph, XWave
The class CObjEx
is an enhanced base class designed for objects which are used in STx scripts. Objects based on this class are deleted automatically before the script application is finished. By convention a class based on CObjEx
implements the following simple instantiation method:
cobjex := cobjExClassName constructionArguments
- cobjex is the name of the created instance
- Constructor
- The default constructor calls the CObj constructor and writes a construct-message to the console window. The function takes no arguments and returns always 0 (success). It must be called by derived classes.
- Destructor
- The default constructor stops and deletes the internal timer (&logTimerItem), calls the CObj constructor and writes a destruct-message to the console window. It must be called by derived classes.
Cleanup
static
CObjEx Cleanup
- Result
- none:
- Description
- Delete all instances of classes based on
CObjEx
. This function is called automatically by the script processor (BScript
) before the script application exits.
Log
public
cobjex log text
-
- text
- The text to write to the log window.
- Result
- none
- Description
- Write the message
class-instance: text
to the script console.
LogExit
public
cobjex logError result; text
-
- result
- The result to assign after returning.
- text
- The text to write to the console window.
- Result
- The value of argument result
- Description
- Writes the message
class-instance: text
to the script console and exits from 2 macros (= return from caller) with the return value result.
LogExt
public
inst LogExt mode ; text
-
- mode
- If
0
, the text overwrites the last log window line. If1
, the text is appended to the last log window line. - text
- The text to write to the log window.
- Result
- none
- Description
- Write text to the
CON
log window with the option of overwriting the last line. This is useful for progress reports.
LogTimer
public
inst LogTimer cmd
-
- cmd
- One of the following:
ON
orBEGIN
: Start the timer and/or display the elapsed time the console window.OFF
orEND
: Stop the timer and display the elapsed time in the console window.
- Return
- The elapsed time in seconds.
- Description
- Start (continue) or stop the internal timer of the object and write the elapsed time to console window (using Log).
ELog
cobjex ELog level ; result ; text
-
- level
- The number of macro levels to return (
2
means: return from calling-macro). - result
- The result to set on returning.
- text
- The text to write to the console window.
- Result
- The value of the argument result. Note: This value is returned to macro addressed by argument level.
- Description
- Writes the message
class-instance: ERROR - text
to the script console and exits from level macros with the return value result.