Contributed samples and applications by Dr. Claudio Soto
A simple way to modify the cursor …
Activate a format when READ is executed
Syntax
SET FORMAT TO [<idProcedure>[.<ext>]]
Arguments
TO <idProcedure> is a format (.fmt) file, a program (.prg) file, or a procedure.
<ext> is the extension of the format file. If not specified, the default extension is (.fmt).
SET FORMAT TO with no argument deactivates the current format.
Description
SET FORMAT defines a procedure to execute when a READ is invoked. Unlike the interpreted environment, formats are not opened and executed at runtime. Instead, the Harbour compiler treats SET FORMAT the same as a DO command. The compiler first looks to see whether it has already compiled a procedure with the same name as <idProcedure>. If it has, it uses that procedure for the reference. If <idProcedure> is not found, the compiler looks to disk for a file with the same name. If this file is not found, an external reference is generated that must be resolved at link time.
SET FORMAT is a compatibility command and not recommended.
Notes
. Active format procedures: Unlike other dialects where each work area can have an active format, Harbour supports only one active format procedure for all work areas.
. Screen CLEARing: Harbour does not clear the screen when a format procedure is executed.
. Legal statements: Format procedures allow statements and commands in addition to @…SAY and @…GET.
. Multiple pages: Harbour does not support multiple-page format procedures.
Examples
. This example uses a format procedure to add records to a database file until the user presses Esc: USE Sales NEW SET FORMAT TO SalesScr DO WHILE LASTKEY() != 27 APPEND BLANK READ ENDDO RETURN PROCEDURE SalesScr @ 12, 12 SAY "Branch : " GET Branch @ 13, 12 SAY "Salesman : " GET Salesman RETURN
Seealso
@…GET, @…SAY, PROCEDURE, READ
Toggle the message display from READ or MEMOEDIT()
Syntax
SET SCOREBOARD ON | off | <xlToggle>
Arguments
ON allows the display of messages from READ and MEMOEDIT() on line zero of the screen.
OFF suppresses these messages.
<xlToggle> is a logical expression that must be enclosed in parentheses. A value of true (.T.) is the same as ON, and a value of false (.F.) is the same as OFF.
Description
SET SCOREBOARD controls whether or not messages from READ and MEMOEDIT() display on line zero. When SCOREBOARD is ON, READ displays messages for RANGE errors, invalid dates, and insert status. MEMOEDIT() displays an abort query message and the insert status.
To suppress the automatic display of these messages, SET SCOREBOARD OFF.
Seealso
@…GET, MEMOEDIT(), READ
Toggle Esc as a READ exit key
Syntax
SET ESCAPE ON | off | <xlToggle>
Arguments
ON enables Esc as a READ exit key.
OFF disables Esc as a READ exit key.
<xlToggle> is a logical expression that must be enclosed in parentheses. A value of true (.T.) is the same as ON, and a value of false (.F.) is the same as OFF.
Description
If SET ESCAPE is ON, Esc terminates the current READ. Any changes made to the current Get object are lost, and validation with RANGE or VALID is bypassed. When SET ESCAPE is OFF and the user presses Esc, the key press is ignored. With SET KEY, however, you can reassign Esc for special handling, regardless of the status of SET ESCAPE.
Seealso
READ, READEXIT(), SETCANCEL(), SET KEY, SETKEY()
Toggle required exit key to terminate GETs
Syntax
SET CONFIRM on | OFF | <xlToggle>
Arguments
ON requires the user to press an exit key to leave a GET.
OFF allows the user to leave a GET by typing past the end without pressing an exit key.
<xlToggle> is a logical expression that must be enclosed in parentheses. A value of true (.T.) is the same as ON, and a value of false (.F.) is the same as OFF.
Description
SET CONFIRM determines whether an exit key is required to leave a GET. If CONFIRM is OFF, the user can type past the end of a GET and the cursor will move to the next GET, if there is one. If there is not another GET, the READ terminates. If, however, CONFIRM is ON, an exit key must be pressed to leave the current GET.
In all cases, attempting to leave the current GET executes the RANGE or VALID clauses, unless the user presses the Esc key. See @…GET for more information on the behavior of GETs.
Seealso
@…GET, READ, SET BELL
Release Get objects from the current GetList array
Syntax
CLEAR GETS
Description
CLEAR GETS explicitly releases all Get objects in the current and visible GetList array, and terminates the calling READ, releasing any remaining objects in the calling READ, if executed within a SET KEY procedure or a user-defined function invoked by a VALID clause. CLEAR GETS releases Get objects by assigning an empty array to the variable GetList. GetList is the name of the variable used to hold an array of Get objects for subsequent READ commands. There are two other mechanisms that automatically release Get objects: CLEAR specified without the SCREEN clause, and READ specified without the SAVE clause.
CLEAR GETS has two basic uses. First, it can be used to terminate a READ from a SET KEY procedure or VALID user-defined function. Second, it can be used to delete Get objects from the GetList array when you have not executed a READ or you have saved the Get objects by using READ SAVE.
Seealso
@…CLEAR, @…GET, CLOSE, READ, RELEASE, SET TYPEAHEAD
Return variable name of current GET or MENU
Syntax
READVAR( [<cVarName>] ) --> cOldVarName
Arguments
<cVarName> is a new variable name to set.
Returns
READVAR() return the old variable name. If no variable previously was set, READVAR() return “”.
Description
READVAR() is set inside a READ or MENU TO command to hold the uppercase name of the GET / MENU TO variable, and re-set back to old value when those commands finished. You should not normally set a variable name but rather use it to retrieve the name of a GET variable when executing a VALID or WHEN clause, or during SET KEY execution and you are inside a READ or MENU TO.
Examples
// display a menu, press F1 to view the MENU TO variable name CLS @ 1, 10 PROMPT "blood sucking insect that infect beds " @ 2, 10 PROMPT "germ; virus infection " @ 3, 10 PROMPT "defect; snag; (source of) malfunctioning" @ 4, 10 PROMPT "small hidden microphone " @ 6, 10 SAY "(Press F1 for a hint)" SET KEY 28 TO ShowVar MENU TO What_Is_Bug PROCEDURE ShowVar Alert( ReadVar() ) // WHAT_IS_BUG in red ALERT() box
Compliance
READVAR() works exactly like CA-Cl*pper’s READKEY().
Note however, that the <cVarName> parameter is not documented and used internally by CA-Cl*pper.
Platforms
All
Files
Library is rtl
Seealso
@…GET, @…PROMPT, MENU TO, READ, SET KEY, __AtPrompt(), __MenuTo()
@…GET
Creates a GET object and displays it to the screen
Syntax
@ <nRow>,<nCol> [SAY <cSay> [PICTURE <cSayPict>] COLOR <cSayColor> ] GET <xVar> [PICTURE <cGetPict>] [WHEN <lWhen>] [COLOR <cGetColor>] [VALID <lValid> / RANGE <xStart>,<xEnd>]
Arguments
<nRow> The row coordinate.
<nCol> The column coordinate.
<cSay> Message to display.
<cSayPict> Character expression of PICTURE displayed.
<cSayColor> Color to be Used for the SAY expression.
<xVar> An variable/field name.
<cGetPict> Character expression of PICTURE to get.
<lWhen> Logical expression to allow GET.
<lValid> Logical expression to validate GET input.
<xStart> Lower RANGE value.
<xEnd> Upper RANGE value.
<cGetColor> Color string to be used for the GET expression.
Description
This command adds a GET object to the reserved array variable named GETLIST[] and displays it to the screen. The field or variable to be added to the GET object is specified in <xVar> and is displayed at row, column coordinate <nRow>, <nCol>.
If the SAY clause is used <cSay> will be displayed starting at <nRow>, <nCol>, with the field variable <xVar> displayed at ROW(), COL()+ 1. If <cSayPicr>, the picture template for the SAY expression <cSay>, is used, all formatting rules contained will apply See the TRANSFORM I function for further information.
If <cGetPict> is specified, the PICTURE clause of <xVar> will be used for the GET object and all formatting rules will apply. See the table below for GET formatting rules.
If the WHEN clause is specified, when <lWhen> evaluates to a logical true (.T.) condition, the GET object will he activated otherwise the GET object will be skipped and no information will be obtained via the screen. The name of a user-defined function returning a logical true (.T.) or false ( F.) or a code block may be , specified in <lWhen> This clause not activated until a READ command or READMODAL() function call is issued.
If the VALID clause is specified and <lValid> evaluates to it logical true (.T.) condition the current GET will be considered valid and the get operation will continue onto the next active GET object. If not, the cursor will remain on this GET object until aborted or until the condition in <lValid> evaluates to true (.T.). The name of a user-defined function returning a logical true (.T.) or false (.F.) or it code block may be specified in <lValid>. This clause is not activated until a READ command or READMODAL( ) function call is issued.
If the RANGE clause is specified instead of the VALID clause, the two inclusive range values for <xVar> must be specified in <xStart> and <xEnd>. Id <xVar> is a date data type, <xStart> and <xEnd> must also be date data types; if <xVar> is a numeric data type <xStart> and <xEnd> must also be numeric data types. If a value fails the RANGE test , a message of OUT OF RANGE will appear in the SCOREBOARD area (row = 0, col = 60). The RANGE message may be turned off it the SET SCOREBOARD command or SET() function appropriately toggled.
NOTE: GET functions/formatting rules:
@A Allows only alphabetic characters. @B Numbers will be left justified @C All positive numbers will be followed by CR. @D All dates will be in the SET DATE format. @E Dates will be in British formal: numbers in European format. @K Allows a suggested value to be seen within the GET area but clears It if any non cursor key is pressed when the cursor is in the first Position in the GET area. @R Non template characters will be inserted. @S<nSize> Allows horizontal scrolling of a field or variable that is <nSize> characters wide. @X All negative numbers will be followed by DB @Z Displays zero values as blanks. @! Forces uppercase lettering @( Displays negative numbers in parentheses with leading spaces. @) Displays negative numbers in parentheses without leading spaces.
GET templates/formatting rules:
A Only alphabetic characters allowed. N Only alphabetic and numeric characters allowed X Any character allowed. L Only T or F allowed For logical data. Y Only Y or N allowed for logical data. 9 Only digits, including signs, will be allowed. # Only digits, signs. and spaces will he allowed. ! Alphabetic characters are converted to Uppercase. $ Dollar will be displayed in place of leading spaces for numeric data types. * Asterisk,, will Be displayed in place of leading spaces for numeric data types. . Position of decimal point. , Position of comma.
Format PICTURE functions may he grouped together as well as used in Conjunction with a PICTURE templates;however, a blank space must be included in the PICTURE string if there are both functions and templates.
Examples
PROCEDURE Main() LOCAL cVar := Space( 50 ) LOCAL nId := 0 CLS @ 3,1 SAY "Name" GET cVar PICTURE "@!S 30" @ 4,1 SAY "Id" GET nId PICTURE "999.999" READ ? "The name you entered is",cVar ? "The id you entered is",nId RETURN
Tests
See Examples
Compliance
Clipper
Platforms
All
Seealso
@…SAY, READ, TRANSFORM()
Determine which key terminated a READ.
Syntax
READKEY() --> nKeyCode
Arguments
None.
Returns
READKEY() returns a numeric code representing the key that caused READ to terminate.
Description
READKEY() is used after a READ was terminated to determine the exit key pressed. If the GET buffer was updated during READ, 256 is added to the return code.
Exit Return code Return code Key (not updated) (updated) ------------------ -------------- ---------------- Up 4 260 Down 5 261 Page-Up 6 262 Page-Down 7 263 Ctrl Page-Up 34 290 Ctrl Page-Down 35 291 Esc 12 268 Ctrl End 14 270 Enter 15 271 Key >= 32 15 271 otherwise 0 0
READKEY() is a compatibility function so try not to use it. READKEY() is superseded by LASTKEY() which returns the INKEY() code for that key. UPDATED() could be used to find if the GET buffer was changed during the READ.
Compliance
READKEY() is compliant with CA-Cl*pper 5.3
Files
Library is rtl
Seealso
@…GET, INKEY(), LASTKEY(), READ, READEXIT(), UPDATED()
Superlib Description by Oasis
The final version of SuperLib, and now it’s FREEWARE, and it comes with 100% SOURCE CODE and extensive norton guide.
SuperLib is a library of functions for Clipper 5.x.
What makes SuperLib different than other libraries on the marketplace is that is contains a large collection of METAFUNCTIONS. A metafunction is like a pre-packaged mini application, ready to link and run. For instance, SuperLib’s report writer is as simple to use as:
USE
REPORTER()
All of the metafunctions are menu-driven and ready to use without modifications. All SuperLib functions are data independant. All that is required is an open DBF file. SuperLib will determine the field structure and use the current DBF. SuperLib requires no special setup or way of doing things. It works with you, not against you. SuperLib functions will do their best to save/restore all settings as they found them. (such as colors, cursor, screens, etc.)
There are over 300 functions in SuperLib, ranging from the metafunctions down to the granular common component functions such as events and popups. (see the function list below, or the .NG file). This version of SuperLib is 100% mouse aware! All SuperLib functions
are automatically aware of the mouse and respond to the mouse.
SuperLib even contains replacements for Clipper’s READ, MENU TO, ACHOICE and MEMOEDIT functions that are mouse aware. Several functions are provided to help you build mouse awareness into your own functions.
SuperLib is Blinker 3.x, 4.x and Exospace compatible for protected mode programs. SuperLib is 99.9 % pure Clipper code, and uses no Clipper internals, which makes for painless upgrading to future versions of Clipper and the various linkers.
SuperLib is network ready, with all locking already built in. (works fine for single-user too)
There is no registration of SuperLib, since it is now freeware. The author, Gary Prefontaine, is no longer supporting the product. If you need help with this library, please ask on comp.lang.clipper
Thanks, Gary.