12.2 TextWindow Object

The top-level object of the TextWindow UCX component. Used for retrieving information about text windows.

12.2.1 BackColor property

Sets or returns the background color of the text window.

Syntax

object.BackColor[=ColorConstant As Constant]

Type

Integer.

Attributes

Read/write.

Remarks

ColorConstant is an optional parameter that sets the background color of the text window. Either the integer value or the constant name can be given. See Section A.3, Background Color Constants.

Example

See example in Example for setting the background color of the text window to Red.

12.2.2 Cursor property

Returns the Cursor object.

Syntax

object.Cursor

Type

Cursor.

Attributes

Read-only.

Example

This example sets the back ground color and the foreground color of the textwindow and the input fields and displays the specified text in the set cursor position.

’Displays the given text at the set cursor position
’Sets the coordinates of the text window
Win.Define(5, 20, 10, 60)
’Sets the background color of the text window
Win.BackColor = WIN_BG_RED 
’Sets the foreground color of the text window
Win.ForeColor = WIN_FG_YELLOW
’Sets the background color of the input field
Win.InputBackColor = WIN_BG_CYAN
’Sets the foreground color of the input field
Win.InputForeColor = WIN_FG_WHITE
’Defines the title of the text window
Win.Title = "Unbelievably Great Window!"
’Wraps the displayed strings
Win.TextWrap = FALSE
’Sets the current window to be visible
Win.Visible = TRUE
’Defines the cursor for the text window
Set cursor = Win.Cursor 
’positions the cursor
cursor.MoveTo(2,10)
’displays the given text
Win.TextOut("Make it a great day") 
cursor.MoveTo(3,10) 
Win.TextOut("for you and yours") 
’Displays the window for 1000 mSecs
Wait 1000
’Clears the 3rd row of the window
Win.Clear(3)
Wait 1000
’Closes the window
Win.Close()

12.2.3 ForeColor property

Sets or returns the foreground color of the text window.

Syntax

object.ForeColor[=ColorConstant As Constant]

Type

Integer.

Attributes

Read/write.

Remarks

ColorConstant is an optional parameter that sets the foreground color of the text window.Either the integer value or the constant name can be given. See Section A.14, Foreground Color Constants.

Example

See example in Example to set the foreground color of the text window to yellow.

12.2.4 InputBackColor property

Sets or returns the background color of the input fields defined by the DefineInputs method.

Syntax

object.InputBackColor[=ColorConstant As Constant]

Type

Integer.

Attributes

Read/write.

Remarks

ColorConstant is an optional parameter that sets the background color of the input fields. Either the integer value or the color name can be given. See Section A.3, Background Color Constants.

Example

See example in Example to set the background color of the input fields to cyan.

12.2.5 InputForeColor property

Sets or returns the foreground color of the input fields defined by the DefineInputs method.

Syntax

object.InputForeColor[=ColorConstant As Constant]

Type

Integer.

Attributes

Read/write.

Remarks

ColorConstant is an optional parameter that sets the foreground color of the input fields. Either the integer value or the color name can be given. See Section A.14, Foreground Color Constants.

Example

See example in Example to set the foreground color of the input fields to white.

12.2.6 Menu property

Sets or returns the Menu object.

Syntax

object.Menu

Type

Menu.

Attributes

Read-Write.

Example

See example in Example for creating a menu and adding menu items.

12.2.7 Title property

Sets or returns the title of the text window.

Syntax

object.Title[=Value As String]

Type

String.

Attributes

Read/write.

Remarks

On a set operation, the Value is an optional parameter that takes the title you want to define for the text window.

Example

See example in Example to set the text window's title as "Unbelievably Great Window!".

12.2.8 TextWrap property

Sets the wrapping status of the display strings or determines whether they are are wrapped.

Syntax

object.TextWrap[=Value As Boolean]

Type

String.

Attributes

Read/write.

Remarks

Value is an optional parameter that enables (TRUE) or disables (FALSE) wrapping.

Example

See example inExample to disable the Textwrap property.

12.2.9 Visible property

Sets or determines whether the current window is visible.

Syntax

object.Visible[=Value As Boolean]

Type

Boolean.

Attributes

Read/write.

Remarks

Value is an optional parameter that enables (TRUE) or disables (FALSE) the visibility of the text window.

Example

See example in Example to set the Visible property to TRUE.

12.2.10 Clear method

Clears the window or a section of the text window.

Syntax

object.Clear(
   [Row As Integer)

Parameters

Row

Optional. The number of the rows to clear.

Return Values

Boolean. Returns TRUE if successful; otherwise, FALSE.

Remarks

If Row is specified, this method clears a section of the window. Otherwise, it clears the entire window.

Example

See example inExample to clear the text in the third row of the textwindow.

12.2.11 ClearInputs method

Clears pending input regions of the text window. This method will prevent the user from editing the input fields and will display the values set in the script for each field.

Syntax

object.ClearInputs()

Parameters

None.

Return Values

Boolean. Returns TRUE if successful. otherwise, FALSE.

Remarks

This method corresponds with the WIN:Get:Clear command in NetBasic 6.0.

Example

See example in Example to disable the input region of the string value and display the string set in the script.

 

See Also

12.2.12 Close method

Closes the text window.

Syntax

Object.Close()

Parameters

None.

Return Values

Boolean. Returns TRUE if successful. otherwise, FALSE.

Remarks

The maximum values for the row and column coordinates are 24 and 79 respectively.

Example

See example in Example to close the window.

12.2.13 Define method

Defines the coordinates of the default display window.

Syntax

object.Define(
   Row1 As Integer, 
   Column1 As Integer, 
   Row2 As Integer, 
   Column2 As Integer)

Parameters

Row1

The left hand side coordinates of the first row.

Column1

The left hand side coordinate of the first column.

Row2

The right hand side coordinate of the last row.

Column2

The right hand side coordinate of the last column.

Return Values

Long. Handle of the defined window.

Example

See example in Example to set the coordinates for the default display window to 5, 20, 10, and 60.

12.2.14 DefineInputs method

Defines a region on the screen that will accept user input.

Syntax

object.DefineInputs(
   MemVar As Anytype 
   [,Width As Integer 
   [,Format As String 
   [,ToUpper As Boolean]]])

Parameters

MemVar

The initialized memory variable.

Width

Optional. The maximum number of characters you want displayed.

Format

Optional. Identifies which inputs are acceptable for each position within the edit region.

ToUpper

Optional. Set to TRUE if you want all characters to be in uppercase.

Return Values

Boolean. Returns TRUE if successful; otherwise FALSE.

Remarks

The user input is placed in the memory variable MemVar. The number of characters that will be displayed can be limited by specifying the Width. The Format parameter is used to specify the format of the input.

Notice that Width need not be supplied even if Format is supplied. Simply supply an extra comma to indicate Width is not being supplied.

This method corresponds with the WIN:Get and WIN:Get:Picture commands in NetBasic 6.0, where the Format parameter corresponds to the sFormat parameter of the WIN:Get:Picture command.

Example

See example in Example to define input regions for the set string and integer parameters in the text window.

12.2.15 DisplayInputs method

Displays all input regions without initiating user inputs.

Syntax

object.DisplayInputs()

Parameters

None.

Return Values

Void.

Remarks

This method corresponds with the WIN:Get:Display command in NetBasic 6.0.

Example

This example displays the specified string value and makes that field non-editable.

’Displays the set string   
’Read a string input
strInput = " Initialized String"
’Sets the heading of the window
WIN.Heading(True,"Title : ReadInput example")
WIN.Define(5,2,24,79)
WIN.Visible=TRUE
Set Cur = WIN.Cursor

’Read a string and display it in the message box
Cur.MoveTo(3,1)
WIN.TextOut ("Input String:")
Cur.MoveTo(3,20)
WIN.DefineInputs(strInput,20)
WIN.Displayinputs()
WIN.ClearInputs()
Msgbox (" String Input " &strInput)

12.2.16 Heading method

Sets or returns the heading of the text window.

Syntax

Object.Heading(
 Arg1 As Boolean,
 [Arg2 As string,
 [Arg3 As String]])

Parameters

Arg1

Boolean. Displays the heading if set TRUE.

IMPORTANT:The functionality is not implemented for FALSE.

Arg2

String. Sets the title of the window.

Arg3

String. Sets the heading of the window.

Attributes

Read/write.

Example

See example in Example to set the heading of the text window as "Readinput sample".

12.2.17 LineDrawChar method

Returns a character used for drawing boxes and lines.

Syntax

object.LineDrawChar(
   LineChar As Integer)

Parameters

LineChar

The value for the line character you want to draw.

Return Values

String.

Remarks

This property corresponds with the WIN:Linedraw:Char command in NetBasic 6.0. See Section A.16, Line Drawing Characters.

Example

See example in Example for creating a double horizontal line.

12.2.18 PopUp method

Displays a popup message in a window on the screen.

Syntax

object.PopUp(
   message1 As String 
   [,messageN As String])

Parameters

message1

The first message you want displayed.

messageN

Optional. Succeeding messages you want displayed (for example, message2, message3) to a maximum of 20 messages.

Return Values

Boolean. Returns TRUE if successful; otherwise, FALSE.

Remarks

This method corresponds with the WIN:Popup command in NetBasic 6.0.

Displays a maximum of 20 messages. Each message appears on a separate line and can be up to 78 characters long. Waits until a key is pressed to display the next message. The first parameter message1 is required; all others are optional.

Example

This example displays the pop-up message "With NSN".

Win.Define(5, 20, 10, 60)
Win.BackColor = WIN_BG_RED 
Win.ForeColor = WIN_FG_YELLOW
Win.Title = "Unbelievably Great Window!"
Win.TextWrap = TRUE
Win.Visible = TRUE
Set cursor = Win.Cursor 
cursor.MoveTo(2,10) 
’Creates a double horizontal line at the set cursor position
for 10 times.
Win.textout(String(15,win.linedrawchar(1)))
cursor.MoveTo(3,10)
Win.TextOut("Enjoy Scripting ") 
cursor.MoveTo(4,10)
Win.textout(String(15,win.linedrawchar(1)))
’displays a pop up window and displays the given string
Win.popup("    with NSN") 
Wait 1000
Win.Close()

See Also

12.2.19 ReadInputs method

Initiates the user input for all the defined regions.

Syntax

Object.ReadInputs(
 [Param1 As Anytype
 [Param2 As Anytype
 [....
 [Param20 As Anytype]]]...])

Parameters

Param1- Param20

Param1, Param2 etc. represent the script variables. A maximum of 20 parameters can be defined in a single Readinputs statement.

Return Values

AnyType. The values read for the different script variables are copied to the respective arguments.

Example

This example initiates a string and an integer input and displays the final values in the set default inputs.

’Defines 2 different windows x and y
x=Win.Define(5, 20, 10, 60)
y=WIN.Define(5,2,24,79)

’Sets x as the default window and executes the script
Win.setdefault(x)
Win.BackColor = WIN_BG_RED 
Win.ForeColor = WIN_FG_YELLOW
Win.InputBackColor = WIN_BG_CYAN
Win.InputForeColor = WIN_FG_WHITE
Win.TextWrap = TRUE
Win.Visible = TRUE
Set cursor = Win.Cursor
cursor.MoveTo(2,5) 
Win.TextOut("Displays the default string value") 
Wait 1000
Win.Visible = FALSE

’Sets y as the default window and executes the script
Win.setdefault(y)
’Read a string input
WIN.Heading(True,"Title : ReadInput sample ")
WIN.Visible=TRUE
Set Cur = WIN.Cursor
’ Read a string
Cur.MoveTo(3,1)
WIN.TextOut ("Input String:")
Cur.MoveTo(3,20)
WIN.DefineInputs(strInput,25)
WIN.Displayinputs()
WIN.ClearInputs()
Cur.MoveTo(5,10)
Win.Textout("Default String Input is " &strInput)
wait 2000
win.close()

’Sets x as the default window and executes the script
Win.setdefault(x)
Win.Visible = TRUE
Set cursor = Win.Cursor 
cursor.MoveTo(2,10)
Win.Textout ("Have a nice day")
wait 1000
Win.close()

12.2.20 Scroll method

Scrolls the contents of a window up or down.

Syntax

object.Scroll(
   Lines As Integer)

Parameters

Lines

The number of lines to scroll.

Return Values

Boolean. Returns TRUE if successful; otherwise, FALSE.

Remarks

This method corresponds with the WIN:Scroll command in NetBasic 6.0.

If the Lines parameter is positive, the contents will move up; otherwise, the contents will move down.

Example

This example scrolls down the contents by a line .

Win.Define(5,3,20,60)
Win.BackColor = WIN_BG_Cyan 
Win.Visible = True 
Set cursor = Win.Cursor 
cursor.MoveTo(2,10) 
Win.TextOut("Make it a great day") 
cursor.MoveTo(3,10) 
Win.TextOut("for you and yours") 
’Scrolls the contents down by a line.
Win.Scroll(-1) 
Sub KeyRead 
  While True 
    keylast = Inkey 
    If (Keylast <> Chr(0)) Then 
     Exit Sub 
    End If 
  wend
End sub

See Also

12.2.21 SetDefault method

Selects a window as the default window.

Syntax

object.SetDefault(
   [Handle As Long])

Parameters

Handle

Optional. The handle to the defined window you want to select.

Return Values

Boolean. Returns TRUE if successful; otherwise, FALSE.

Remarks

Multiple windows can be defined in TextWindow. Use SetDefault to define a particular window as the default window. If no parameters are passed, the last defined window is considered the default window.

Example

See example in Example

12.2.22 TextOut method

Displays text at the current cursor position.

Syntax

object.TextOut(
   message1 As String 
   [,messageN As String])

Parameters

message1

The first message you want displayed.

messageN

Optional. Succeeding messages you want displayed (for example, message2, message3) to a maximum of 20 messages.

Return Values

Boolean. Returns TRUE if successful; otherwise, FALSE.

Remarks

Displays a maximum of 20 messages. Each message appears on a separate line and can be up to 78 characters long. Waits until a key is pressed to display the next message. The first parameter message1 is required; all others are optional.

Example

See example in Example.