Programmer Guide/Macro Library/CObjEx: Difference between revisions

From STX Wiki
Jump to navigationJump to search
No edit summary
No edit summary
Line 4: Line 4:
*'''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]]
*'''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 CObjEx 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:
::<code> cobjExInstance := cobjExClassName <var>constructionArguments</var> </code>
::<code> cobjExInstance := cobjExClassName <var>constructionArguments</var> </code>


;Constructor: The default constructor calls the CObj constructor and writes a construct-message in 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 in the console window. It must be called by derived classes.


====CObjEx Member Functions====
;Member functions: [[#Cleanup|Cleanup (static)]],


The <code>CObjEx</code> class has the following member functions. See CObj Member Functions for a list of functions implemented in the parent class.
====Cleanup====
'''static'''
;<code>CObjEx Cleanup</code>
Delete all instances of classes based on <code>CObjEx</code>. This function is called automatically by the script processor (<code>BScript</code>) before the script application exits.


===cleanup===
====ELog====
;<code><var>cobjex</var> ELog <var>level</var> ; <var>result</var> ; <var>text</var></code>:
:;<var>level</var>: The number of macro levels to return (<code>2</code> means: return from calling-macro).
:;<var>result</var>: The result to set on returning.
:;<var>text</var>: The text to write to the console window.
;Result: The value of the argument <var>result</var>. Note: This value is returned to macro addressed by argument <var>level</var>.
;Description: Writes the message <code>class-instance: ERROR - <var>text</var></code> to the script console and exits from <var>level</var> macros with the return value <var>result</var>.


Delete all instances of classes based on <code>COBJEX</code>. This function is called automatically by <code>BScript</code> before the application exits.


=====Usage:=====
<code><var>cobjex</var> cleanup</code>
===construct===
Calls the <code>COBJ</code> constructor and writes a construct message to the script console.
=====Usage:=====
<code><var>cobjex</var> construct</code>
===destruct===
Calls the <code>COBJ</code> destructor and writes a destruct message to the script console.
=====Usage:=====
<code><var>cobjex</var> destruct</code>
===elog===
Writes the message "<code>class-instance: ERROR -</code> <var>text</var>" to the script console and exits from '<var>level</var>' macros with the return value '<var>result</var>'.
=====Usage:=====
<code><var>cobjex</var> elog <var>level</var>; <var>result</var>; <var>text</var></code>
=====Parameters:=====
;<var>level</var>
:The number of macro levels to return.
;<var>result</var>
:The result to set on returning.
;<var>text</var>
:The text to use write to the console window.


===log===
===log===
Line 63: Line 32:
Write the message "<code>class-instance:</code> <var>text</var>" to the script console.
Write the message "<code>class-instance:</code> <var>text</var>" to the script console.


=====Usage:=====
====Log====


<code><var>cobjex</var> log <var>text</var></code>
<code><var>cobjex</var> log <var>text</var></code>

Revision as of 09:07, 5 June 2012

  • 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:

cobjExInstance := cobjExClassName constructionArguments
Constructor
The default constructor calls the CObj constructor and writes a construct-message in 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 in the console window. It must be called by derived classes.
Member functions
Cleanup (static),

Cleanup

static

CObjEx Cleanup

Delete all instances of classes based on CObjEx. This function is called automatically by the script processor (BScript) before the script application exits.

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.


log

Write the message "class-instance: text" to the script console.

Log

cobjex log text

Parameters:
text
The text to write to the log window.

logError

Writes the message "class-instance: ERROR - text" to the script console and exits from 2 macros with the return value 'result'.

Usage:

cobjex logError result; text

Parameters:
result
The result to assign after returning.
text
The text to write to the console window.

LogExt

Write text to the CON log window with the option of overwriting the last line. This is useful for progress reports.

Usage:

inst LogExt mode ; text

Parameters:
mode
If 0, the text overwrites the last log window line. If 1, the text is appended to the last log window line.
text
The text to write to the log window.

LogTimer

Start or stop the internal BScript timer. The elapsed time is written to the CON log window.

Usage:

inst LogTimer cmd

Parameters:
cmd
One of the following:
ON|BEGIN - Start the timer. If the timer has already been started, then the elapsed time in seconds is returned. The elapsed time is also displayed in the CON window.
OFF|END - Stop the timer. The elapsed time is also displayed in the CON window.

Navigation menu

Personal tools