Class Get() Foundation

Class function of the Get class.

Description

The class object generates Get objects using its class method :new().

Get objects provide a mechanism for formatting, interactive editing and validation of data. The edited data may be contained in memory variables or database variables. The Get object does not directly access the data. Instead, the Get object accesses data by evaluating a special code block, termed the data code block. The data code block provides the means by which a Get object reads the value of a variable into its edit buffer and writes a changed value back to the variable.

When a Get object receives focus, it evaluates the data code block to copy the value of the variable to its edit buffer. Get object methods provide the means to navigate through the buffer, change the data stored there, and to write the changes back to the variable. Other methods provide the means to validate the data before and after editing.

When using the @...GET command, Get objects are automatically created with a data code block that accesses the variable referenced by the GET clause. When Get objects are instantiated using the class method get():new(), a data code block must be manually coded. The @...GET command stores each newly created Get object in the public array GetList. The READ command passes a reference to the GetList array to the function ReadModal(). ReadModal() is the default Get object processing routine, within which individual Get objects in the GetList array are used to edit data.

Class methods
:new()
Creates an instance of the Get class.
Instance variables
:block
Contains the data code block for accessing a variable.
:buffer
Contains the edit buffer when a Get object has input focus.
:cargo
Instance variable for ad-hoc use.
:changed
Indicates whether an edit buffer has been changed during editing.
:clear
Indicates whether the edit buffer should be cleared.
:col
Column position of a Get object on the screen.
:colorSpec
Contains the color for display and editing.
:decPos
Contains the decimal point position in the edit buffer.
:exitState
Contains numeric value which indicates how a Get object was exited.
:hasFocus
Indicates whether the Get object has input focus.
:length
Total number of characters in the edit buffer (including blank spaces).
:name
Contains the name of the variable which is associated with the Get object.
:original
Contains the original value of the variable associated with the Get object.
:picture
Contains the PICTURE format for formatted display.
:pos
Indicates the position of the cursor in the edit buffer.
:postBlock
Contains an optional code block for data validation.
:preBlock
Contains an optional code block that determines whether editing is allowed.
:reader
Contains an optional code block that determines how a Get object is edited.
:rejected
Indicates whether a character was transferred into the edit buffer.
:row
Line position of a Get object on the screen.
:subscript
Exists only for compatibility.
:type
Indicates the data type of the variable associated with the GET.
:typeOut
Indicates an attempt to move the cursor out of the editing buffer.
:width
Number of characters of the Get object's data that are visible on the screen.
Display methods
:colorDisp()
Changes the Get object's color and redisplays the Get.
:display()
Displays the Get value on the screen.
:updateBuffer()
Updates and redisplays the edit buffer.
State Methods
:badDate()
Determines whether a valid date was entered.
:minus()
Tests whether a negative numeric value was entered.
:posInBuffer()
Determines a position within the edit buffer based on screen coordinates.
State changing methods
:_assign()
Assigns the value of the edit buffer to the associated variable.
:killFocus()
Ends input focus.
:reset()
Resets all instance variables to the initial values acquired when the Get object received focus.
:setFocus()
Gives input focus.
:undo()
Resets the associated variable to the value held in :original.
:unTransform()
Converts the edit buffer to the data type of the associated variable.
:varGet()
Retrieves the current value of the associated variable.
:varPut()
Assigns a value to the associated variable.
Cursor navigation methods
:_end()
Moves the cursor to the last character in the edit buffer.
:home()
Moves the cursor to the first character in the edit buffer.
:left()
Moves the cursor one character to the left.
:right()
Moves the cursor one character to the right.
:toDecPos()
Positions the cursor to the right of the decimal point.
:wordLeft()
Positions the cursor on the first character of the next word to the left.
:wordRight()
Positions the cursor on the first character of the next word to the right.
Text editing methods
:backspace()
Deletes a character to the left of the cursor.
:delete()
Deletes the character at the current cursor position.
:delEnd()
Deletes all the characters to from the current cursor position to the end of the edit buffer.
:delLeft()
Deletes the character to the left of the cursor.
:delRight()
Deletes a character to the right of the cursor.
:delWordLeft()
Deletes the word to the left of the cursor.
:delWordRight()
Deletes a word to the right of the cursor.
Text input methods
:insert()
Inserts characters into the edit buffer.
:overStrike()
Overwrites characters in the edit buffer.
Examples
Get object usage

// The example shows three different ways to 
// generate a Get object and to edit a value 
// on the screen. 

PROCEDURE Main 
   LOCAL cPhoneNumber := "01234567890123", oGet 

   @ 10,10 SAY "Telephone:" ;          // Command syntax 
           GET cPhoneNumber ; 
         VALID .NOT. Empty(cPhoneNumber) ; 
         COLOR "N/BG,W+/B" ; 
       PICTURE "@R (99999) - 999 999 999" 
   READ                                // Editing 


   @ 12,10 SAY "Telephone:"            // Passing arguments to 
   oGet := Get():new( Row(),Col()+1, ; // the class method :new() 
                      {|x| IIf(x==NIL, cPhoneNumber, ; 
                                       cPhoneNumber := x )}, ; 
                      "cPhoneNumber", ; 
                      "@R (99999) - 999 999 999", ; 
                      "N/BG,W+/B" ) 

   oGet:postBlock := {|x| ! Empty(x) } 
   oGet:display()                       // Display value 

   ReadModal( {oGet} )                  // Edit 

   @ 14,10 SAY "Telephone:" 
   oGet           := Get():new()        // Instantiate Get object 
   oGet:row       := Row()              // and assign values to 
   oGet:col       := Col() + 1          // instance variables 
   oGet:block     := {|x| IIf(x==NIL, cPhoneNumber, ; 
                                      cPhoneNumber := x ) } 
   oGet:name      := "cPhoneNumber" 
   oGet:picture   := "@R (99999) - 999 999 999" 
   oGet:colorSpec := "N/BG,W+/B" 
   oGet:postBlock := {|x| ! Empty(x) } 
   oGet:display()                       // Display value 

   ReadModal( {oGet} )                  // Edit 

RETURN 

Feedback

If you see anything in the documentation that is not correct, does not match your experience with the particular feature or requires further clarification, please use this form to report a documentation issue.