xHarbour Reference Documentation > Class Reference (textmode) xHarbour Developers Network  

Get()

Creates a new Get object.

Syntax

Get():new( [<nRow>]     , ;
           [<nCol>]     , ;
           <bVarBlock>  , ;
           [<cVarName>] , ;
           [<cPicture>] , ;
           [<cColorSpec>] ) --> oGet

Arguments

<nRow>
This is the numeric row coordinate on the screen where the Get object is displayed. It defaults to the return value of function Row(). <nRow> is assigned to oGet:row.
<nCol>
This is the numeric column coordinate on the screen where the Get object is displayed. It defaults to the return value of function Col(). <nCol> is assigned to oGet:col.
<bVarBlock>
This is the data code block connecting a Get object with a variable holding the edited value (see description below). <bVarBlock> is assigned to oGet:block.
<cVarName>
This is a character string holding the symbolic name of a memory variable of PRIVATE or PUBLIC scope. If the Get object should edit such a variable, <bVarBlock> is optional. <cVarName> defaults to an empty string ("") and is assigned to oGet:name.
<cPicture>
This is a character string holding a PICTURE format. <cPicture> defaults to an empty string ("") and is assigned to oGet:picture.
<cColorSpec>
This is a character string holding a color string of up to four color values. (refer to function SetColor() for color values). <cColorSpec> is assigned to oGet:colorSpec.

Return

Function Get() returns a new Get object and method :new() initializes the object.

Description

Get objects provide the means for data entry in text mode applications. They are generally created with the @...GET command and collected in a PUBLIC array named GetList. All Get objects stored in the GetList array are processed with the READ command, or the ReadModal() function, respectively.

A Get object displays data to be edited and provides methods for keyboard input and cursor movement when it receives input focus. The data to be edited can be stored a memory or field variable, it is not stored in the Get object itself. Instead, a Get object must receive a data code block with the <bVarBlock> parameter, which can be created using functions MemVarBlock(), FieldBlock() or FieldWBlock().

The data code block can also be coded in a general form like this:

LOCAL variable

bVarBlock := {|xValue| IIf( xValue==NIL, variable, variable := xValue ) }

This code block has one parameter and refers to the variable whose value is edited. A Get object retrieves the variable's value by evaluating the data code block with no parameter, and it assigns the edited value to the variable by passing the edited value to the data code block when it looses input focus.

Instance variables

:badDate
Indicates if the editing buffer contains an invalid date value.
:block
Data code block of the Get object.
:buffer
Character string held in the editing buffer.
:capCol
Numeric column position of a caption.
:capRow
Numeric row position of a caption.
:caption
Character string defining the caption.
:cargo
Instance variable for user-defined purposes.
:changed
Indicates if the editing buffer was changed.
:clear
Indicates if the editing buffer should be cleared
:col
Numeric column position of the Get object.
:colorSpec
Color string for display and editing.
:control
Optional object for extended editing.
:decPos
Numeric position of the decimal point during editing.
:exitState
Numeric code indicating how editing was terminated.
:hasFocus
Indicates if the Get object has input focus.
:minus
Indicates if a minus sign is entered for numbers.
:message
Character string to be displayed as message when Get receives input focus.
:name
Character string holding the symbolic name of the edited variable.
:original
Character string holding the original value before editing started.
:picture
Character string holding a PICTURE format.
:pos
Current cursor position within the editing buffer.
:postBlock
Code block to validate a new value before Get looses input focus.
:preBlock
Code block to validate a value before Get receives input focus.
:reader
Code block calling an alternative Get reader procedure.
:rejected
Indicates if the last key stroke was rejected during editing.
:row
Numeric row position of the Get object.
:subscript
Array element subscript when array is edited.
:type
Data type of edited value.
:typeOut
Indicates attempt to move the cursor out of editing buffer.

State changing methods

:assign() --> self
Assigns the contents of the edit buffer to the edited variable
:colorDisp( <cColorSpec> ) --> self
Changes the color and redisplays the Get.
:display() --> self
Displays the Get on the screen.
:hitTest( <nMouseRow>, <nMouseCol> ) --> nHitCode
Tests if a Get is hit by the mouse cursor.
:killFocus() --> self
Removes input focus from the Get object.
:reset() --> self
Resets internal state information of a Get object.
:setFocus() --> self
Gives input focus to the Get object.
:undo() --> self
Assigns the original value back to the edited variable.
:unTransform() --> xValue
Converts the editing buffer to its original data type.
:updateBuffer() --> self
Updates the editing buffer and redisplays the Get.
:varGet() --> xValue
Returns the current value of the edited variable.
:varPut( <xValue>) --> xValue
Assigns a new value to the edited variable.

Cursor movement methods

:end() --> self
Moves the cursor to the last position in the edit buffer.
:home() --> self
Moves the cursor to the first position in the edit buffer.
:left() --> self
Moves the cursor one character to the left.
:right() --> self
Moves the cursor one character to the right.
:toDecPos() --> self
Moves the cursor to the immediate right of Get:decPos.
:wordLeft() --> self
Moves the cursor to the beginning of the next left word.
:wordRight() --> self
Moves the cursor to the beginning of the next right word.

Editing methods

:backspace() --> self
Moves the cursor to the left and deletes a character.
:delete() --> self
Deletes the character at the current cursor position.
:delEnd() --> self
Deletes all characters from the current cursor position to the end of the edit buffer.
:delLeft() --> self
Deletes the character to the left of the cursor.
:delRight() --> self
Deletes the character to the right of the cursor.
:delWordLeft() --> self
Deletes the word to the left of the cursor.
:delWordRight() --> self
Deletes the word to the right of the cursor
:insert( <cCharacter> ) --> self
Inserts a single character into the edit buffer.
:overStrike( <cCharacter> ) --> self
Overwrites a single character in the editing buffer.

Info

See also:@...GET, READ, ReadModal(), ReadVar(), Valtype(), SetColor()
Category: Get system , Object functions
Header:Button.ch, Getexit.ch
Source:rtl\getsys.prg, rtl\tget.prg, rtl\tgetlist.prg, rtl\mssgline.prg
LIB:xhb.lib
DLL:xhbdll.dll

Example

// The example compares the creation of a single Get
// using command oriented and object oriented syntax

   PROCEDURE Main
      LOCAL cString:= "Testing Gets     "
      LOCAL bBlock

      @ 2, 2 SAY "String 1"        ;
             GET cString           ;
           COLOR "N/BG,W+/B"       ;
           VALID !Empty( cString ) ;
         PICTURE "@K"

      READ

      bBlock := {|x| IIf( x==NIL, cString, cString := x ) }

      @ 4, 2 SAY "String 2"

      oGet           := Get():new()
      oGet:row       := Row()
      oGet:col       := Col() + 1
      oGet:block     := bBlock
      oGet:name      := "cString"
      oGet:picture   := "@K"
      oGet:colorSpec := "N/BG,W+/B"
      oGet:postBlock := {|o| ! Empty(o:varGet()) }
      oGet:display()

      ReadModal( {oGet} )

   RETURN

Copyright © 2006-2007 xHarbour.com Inc. All rights reserved.
http://www.xHarbour.com
Created by docmaker.exe