CRT Icon  Screen Object


 

Description

The Screen object provides access to CRT's terminal screen.

 

Syntax

screen.property [ = expression ]

screen.Method([arglist])

 

Remarks

CRT's Screen object is accessed through the top-level objectÆs æScreenÆ property.

 

Screen Object Properties and Methods

Properties

Methods

ááááCurrentColumn

ááááClear

ááááCurrentRow

ááááGet

ááááColuumns

ááááPrint

ááááRows

ááááSend

ááááSynchronous

ááááSendSecial

 

ááááWaitForCursor

 

ááááWaitForKey

 

ááááWaitForString

 

ááááWaitForStrings

 

Properties

 

CurrentColumn

Description

Returns the current column of the cursor.

Syntax

object.CurrentColumn

Remarks

Read-only numeric property. The first column is 1. An error will be returned if there is no connection open.

 

CurrentRow

Description

Returns the current row of the cursor.

Syntax

object.CurrentRow

Remarks

Read-only numeric property. The first row is 1. An error will be returned if there is no connection open.

 

Columns

Description

Returns the current number of columns.

Syntax

object.Columns

Remarks

Read-only numeric property.

 

Rows

Description

Returns the current number of rows

Syntax

object.Rows

Remarks

Read-only numeric property.

 

Synchronous

Description

Returns or sets the Synchronous setting of the screen.

Syntax

object.Synchronous [ = True | False ]

Remarks

If Synchronous is False then under certain circumstances a script can miss data sent by the server that it is expecting to see. Synchronous is set to False by default, and should only be set to true in circumstances when a possibility of a script missing data exists. Scripts should then return the Synchronous state to False.

 

For example, the following code that waits for two different strings could potentially miss the second string while it is performing some operation after receiving the first string. In order to prevent this kind of condition, it temporarily sets Synchronous to True:

...

crt.screen.Synchronous = True

crt.screen.Send("someCommand")

crt.screen.WaitForString("thisString")

... do something else

crt.screen.WaitForString("thatString")

crt.screen.Synchronous = False

 

 

Methods

 

Clear

Description

Clears the screen.

Syntax

object.Clear

Remarks

None.

 

Get

Description

Returns a string of characters read for a portion of the screen.

Syntax

object.Get(row1, col1, row2, col2)

Remarks

Returns a string containing the characters on the screen rectangle defined by the numeric values row1,col1 (upper-left) and row2,col2 (lower-right).

 

Print

Description

Prints the screen

Syntax

object.Print

Remarks

If no printer is defined on your machine, an error will be returned.

 

Send

Description

Sends a string of characters.

Syntax

object.Send string

Remarks

Attempting to send a string while no connection is open returns an error.

 

SendSpecial

Description

Sends a special

Syntax

object.SendSpecial string

Remarks

The string parameter to SendSpecial should describe one of the special CRT or protocol functions. Attempting to use SendSpecial while no connection is opened will result in an error.

 

Examples:

screen.SendSpecial "TN_BREAK"

screen.SendSpecial "VT_PF1"

 

WaitForCursor

Description

Wait for the cursor to change position.

Syntax

object.WaitForCursor [ timeout ]

Remarks

The optional timeout parameter specifies the number of seconds to wait for the change. If a change of cursor position is detected WaitForCursor() returns True. If a timeout occurs the function returns False. If no timeout is specified then WaitForCursor() will not time out. An error will be returned if there is no connection open.

 

WaitForKey

Description

Wait for a keypress event.

Syntax

object.WaitForKey [ timeout ]

Remarks

The optional timeout parameter specifies the number of seconds to wait for a key event. If key event is detected WaitForKey() returns True. If a timeout occurs the function returns False. If no timeout is specified then WaitForKey() will not time out. An error will be returned if there is no connection open.

 

WaitForString

Description

Wait for a string.

Syntax

object.WaitForString string [, timeout]

Remarks

Wait for the string to appear in the input. The timeout (seconds) parameter is optional. When the string is detected in the input WaitForString() returns True. If a timeout occurs the function returns False. An error will be returned if there is no connection open.

 

Example:

If crt.screen.WaitForString("ogin:", 10) <> True Then

MsgBox "Failed to detect login!"

Exit Sub

End If

 

WaitForStrings

Description

Wait for one of several strings to appear in the input.

Syntax

object.WaitForStrings string1, [string2, ..., stringn] [, timeout]

Remarks

Waits for one of the strings given as arguments to appear in the input. When one of the argument strings is matched in the input, WaitForStrings() returns the argument index of the string that was found (the index of the first string given as an argument to WaitForStrings() is 1). If the optional timeout parameter is specified and a timeout occurs before any of the strings are found, WaitForStrings() returns 0. In the absence of a timeout parameter WaitForStrings() will block without timing out and will not return 0. An error will be returned if there is no connection open.

 

Example:

Dim result

result = crt.screen.WaitForStrings("foo", "bar", "quux", "gee", 10)

MsgBox result

If result = 3 Then

     MsgBox "Got quux!"

End If

If result = 0 Then

    MsgBox "Timed out!"

End If

 

Notes

If you are using VBScript, WaitForStrings() will accept an array of strings as its first argument followed by an optional timeout. The value returned by WaitForStrings() will be the index of the string found in the array (1st element in the array = 1). A value of 0 will be returned if no strings were found within the timeout period if specified.