Programmer Guide/Macro Library/CObjEx: Difference between revisions

From STX Wiki
Jump to navigationJump to search
No edit summary
No edit summary
Line 11: Line 11:
;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.
;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|Cleanup (static)]], [[#Log|Log]], [[#LogExt|LogExt]], [[#LogExit|LogExit]], [[#LogTimer|LogTimer]], [[#ELog|ELog]]
;Member functions: [[#Cleanup|Cleanup (static)]], [[#Log|Log]], [[#LogExit|LogExit]], [[#LogExt|LogExt]], [[#LogTimer|LogTimer]], [[#ELog|ELog]]


===Cleanup===
===Cleanup===
Line 22: Line 22:
====Log====
====Log====
'''public'''
'''public'''
;<code><var>cobjex</var> log <var>text</var></code>:
;<code><var>cobjex</var> log <var>text</var></code>:
:;<var>text</var>: The text to write to the log window.
:;<var>text</var>: The text to write to the log window.
Line 27: Line 28:
;Description: Write the message <code>class-instance: <var>text</var></code> to the script console.
;Description: Write the message <code>class-instance: <var>text</var></code> to the script console.


====LogExit====
===LogExit===
'''public'''
 
;<code><var>cobjex</var> logError <var>result</var>; <var>text</var></code>:
;<code><var>cobjex</var> logError <var>result</var>; <var>text</var></code>:
:;<var>result</var>: The result to assign after returning.
:;<var>result</var>: The result to assign after returning.
Line 33: Line 36:
;Result: The value of argument <var>result</var>
;Result: The value of argument <var>result</var>
;Description: Writes the message <code>class-instance: <var>text</var></code> to the script console and exits from 2 macros (= return from caller) with the return value <var>result</var>.
;Description: Writes the message <code>class-instance: <var>text</var></code> to the script console and exits from 2 macros (= return from caller) with the return value <var>result</var>.
=====Usage:=====


===LogExt===
===LogExt===
'''public'''


Write text to the <code>CON</code> log window with the option of overwriting the last line. This is useful for progress reports.
;<code><var>inst</var> LogExt <var>mode</var> ; <var>text</var></code>:
 
:;<var>mode</var>: If <code>0</code>, the text overwrites the last log window line. If <code>1</code>, the text is appended to the last log window line.
Usage:
:;<var>text</var>: The text to write to the log window.
 
;Result: none
<code><var>inst</var> LogExt <var>mode</var> ; <var>text</var></code>
;Description: Write text to the <code>CON</code> log window with the option of overwriting the last line. This is useful for progress reports.
 
=====Parameters:=====
 
;<var>mode</var>
 
:If <code>0</code>, the text overwrites the last log window line. If <code>1</code>, the text is appended to the last log window line.
 
;<var>text</var>
 
:The text to write to the log window.


===LogTimer===
===LogTimer===


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


Usage:
Usage:


<code><var>inst</var> LogTimer <var>cmd</var></code>
;<code><var>inst</var> LogTimer <var>cmd</var></code>:
 
:;<var>cmd</var>: One of the following:
=====Parameters:=====
::*<code>ON</code> or <code>BEGIN</code>: Start the timer and/or display the elapsed time the console window.
 
::*<code>OFF</code> or <code>END</code>: Stop the timer and display the elapsed time in the console window.
;<var>cmd</var>
;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|Log]]).
:One of the following:
 
:<code>ON</code>|<code>BEGIN</code> - 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.
 
:<code>OFF</code>|<code>END</code> - Stop the timer. The elapsed time is also displayed in the CON window.





Revision as of 09:41, 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), Log, LogExit, LogExt, LogTimer, ELog

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. If 1, 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

Usage:

inst LogTimer cmd
cmd
One of the following:
  • ON or BEGIN: Start the timer and/or display the elapsed time the console window.
  • OFF or END: 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.

Navigation menu

Personal tools