Contributed works of Grigory Filatov
Adaptation FiveWin TsBrowse class
Color Table
Center Window’s Title
Closes application when no activity
Copy Protection (Get BIOS Name)
GetFonts
Get list of all controls
Anchor Windows (ON MOUSEDRAG)
Bos Taurus – Incredible !!!
DEFINE REPORT (with filtered data)
Demo Debug
Generate PDF files
Improved interfaces (Label Button)
My color list (i_color.ch)
Display records to the console
Syntax
DISPLAY <exp list> [TO PRINTER] [TO FILE <xcFile>] [<scope>] [WHILE <lCondition>] [FOR <lCondition>] [OFF]
Arguments
<exp list> is the list of values to display for each record processed.
TO PRINTER echoes output to the printer.
TO FILE <xcFile> echoes output to the indicated file which can be specified either as a literal file name or as a character expression enclosed in parentheses. If an extension is not specified, .txt is added.
<scope> is the portion of the current database file to DISPLAY. The default is the current record, or NEXT 1. If a condition is specified, the scope becomes ALL.
WHILE <lCondition> specifies the set of records meeting the condition from the current record until the condition fails.
FOR <lCondition> specifies the conditional set of records to DISPLAY within the given scope.
OFF suppresses the display of the record number.
Description
DISPLAY is a database command that sequentially accesses records in the current work area, sending the results of the <exp list> to the console in a tabular format with each column separated by a space. The command does not display column headers or pause at predetermined intervals. DISPLAY is identical to LIST with the exception that its default scope is NEXT 1 rather than ALL.
When invoked, output is sent to the screen and optionally to the printer and/or a file. To suppress output to the screen while printing or echoing output to a file, SET CONSOLE OFF before the DISPLAY command line.
Notes
. Interrupting output: To let the user interrupt the processing of a DISPLAY command, using the INKEY() function, add a test for the interrupt key press to the FOR condition. See the example below. . Printer margin: Since DISPLAY is a console command, it honors the current SET MARGIN for output echoed to the printer.
Examples
. This example illustrates a simple DISPLAY, and a conditional DISPLAY to the printer: USE Sales NEW DISPLAY DATE(), TIME(), Branch DISPLAY Branch, Salesman FOR Amount > 500 TO PRINTER . This example interrupts a DISPLAY using INKEY() to test whether the user pressed the Esc key: #define K_ESC 27 USE Sales INDEX SalesMan NEW DISPLAY Branch, Salesman, Amount WHILE ; INKEY() != K_ESC
Seealso
DBEVAL(), INKEY(), LIST, SET MARGIN
MFIELDSTYPE() Short: ------ MFIELDSTYPE() Pops up a list of fields of given type(s) Returns: -------- <cFieldName> => name of selected field Syntax: ------- MFIELDSTYPE(cType,[cTitle],[nTop,nLeft,nBottom,nRight]) Description: ------------ <cType> is a string containing 1 or more field TYPE symbols: C Character N Numeric D Date L Logical M Memo Only fields of this type(s) are presented for the picklist. If no fields of this type(s) are present, a "" is returned. [cTitle] is a string placed at the top of the popup box for a title [nTop,nLeft,nBottom,nRight] are the coordinates of the box Examples: --------- // this selects memo field to edit use customer cField := mfieldstype("M") if !empty(cField) memoedit(FIELDGET(FIELDPOS(cField)),0,0,24,79) endif Source: ------- S_MFLDT.PRG
Language Syntax The general rule of thumb is: built-in features in lowercase, and custom-written functions in mixed case. When specifying the complete syntax of a language element in documentation, the input items, parameters, and so on are referred to using the following symbols:
For example:
Metasymbols provide a place holder for syntax elements, and they describe the expected data types. A metasymbol consists of one or more lowercase data type designators followed by a mixed case description. This is known as Hungarian Notation.
In this example,
|
![]() |
Filenames and Aliases All filenames, in any context, are in upper case. Filenames follow DOS naming conventions (preferably limited to letters, numbers, and the underscore).
When referring to specific file types in documentation, include the period. |
![]() |
Fieldnames Fieldnames are all uppercase, and always include the alias of the table. Fieldnames may contain underscores, but should not begin with one (because the underscore is generally used to indicate an internal symbol).
|
![]() |
Memory Variables Memory variables consist of a lowercase type designator followed by a mixed case description (see Hungarian Notation). Although CA-Clipper only recognizes the first 10 characters as unique, variable names may be longer.
If you use Hungarian Notation for your memory variable names and include the table alias with fieldnames, there will be no conflict between the two. |
![]() |
Commands, Functions, and Keywords All built-in commands, functions, and keywords are lowercase. In documentation, the font should be Courier or a similar font. If fonts are not available, then bold or CAPITALIZE the word for emphasis. Never use abbreviations — this practice is not necessary with a compiler, although it was common in the early days of dBase (which was an interpreter). There should never be a space between the function name and the opening parenthesis. Also, note that the iif() function should never be spelled if() .
When specifying commands that have clauses in documentation, separate the keywords with an ellipsis (
|
![]() |
Programmer-Defined Functions & Procedures These begin with an uppercase letter, followed by mixed case letters as appropriate.
Function and procedure names may contain underscores, but should not begin with one (they may conflict with internal functions which often start with an underscore). There should be only one
The return value of a function is not enclosed in parentheses, although parentheses may be used to clarify a complex expression.
|
![]() |
Preprocessor Directives Preprocessor directives are lowercase and are preceded by the # sign.
Optionally, you may use single quotes around header files that come with CA-Clipper and double quotes around your own. This convention is purely voluntary, but it helps to distinguish between the two. For example:
Manifest constants are uppercase.
Pseudo-function names should also be uppercase.
|
![]() |
Declarations Local variables are grouped according to functionality, and may be declared on one or more lines. The declarations appear as the first code at the beginning of a function or procedure.
Variables may be declared one per line and accompanied by a description.
The description can be omitted if better variable names are chosen.
Variables can be initialized when they are declared, although it is often clearer (and safer) to initialize them immediately before they are used.
|
![]() |
Logicals The .T. and .F. are typed in uppercase. |
![]() |
Operators The in-line assignment operator ( := ) is used for all assignments, and the exact comparison operator (== ) is used for all comparisons.
Although the compound assignment operators (
The increment (
|
![]() |
Spacing Whenever a list of two or more items is separated by commas, the commas are followed by a space.
Spaces may be used between successive parentheses.
Spaces should surround all operators for readability.
In declarations, often spaces are not used around the assignment operator. This tends to make searching for the declaration of a variable easier.
Thus, searching for “ |
![]() |
Indentation Indenting control structures is one of the easiest techniques, yet it improves the readability the most. Indent control structures and the code within functions and procedures 3 spaces.
Case statements in a do…case structure are also indented 3 spaces.
|
![]() |
Tabs Do not use tabs in source code — insert spaces instead. Tabs cause problems when printing or when moving from one editor to another, because of the lack of a standard tab width between editors and printers. Typically, printers expand tabs to 8 spaces which easily causes nested control structures to fall off the right-hand side of the page. Commonly, a source code editing program will insert the appropriate number of spaces when the <TAB> key is hit. |
![]() |
Line Continuation When a line of code approaches the 80th column, interrupt the code at an appropriate spot with a semicolon and continue on the next line. Indent the line so that it lines up in a readable manner.
To continue a character string, end the first line with a quote and a plus sign and place the remainder on the next line. Try to choose a logical place in the string to break it, either at a punctuation mark or after a space.
|
![]() |
Quotes Use double quotes for text that needs to be translated (will appear on the screen), and single quotes for other strings.
This is a simple but extremely effective technique because translation departments often want to see the messages in context (in the source code), so the different quote types indicate which messages are to be translated and which should be left alone. |
![]() |
Comments Comments are structured just like English sentences, with a capital letter at the beginning and a period at the end.
You may encounter old-style comment indicators if you maintain older (Summer’87 and earlier) code.
For in-line comments, use the double slashes.
Note that the ‘ |
Sending lines to a file is quite easy :
In addition of SET PRINTER on | OFF | <xlToggle> command, SET PRINTER, (like many other SET commands,) has a second form distinguished by TO keyword:
SET PRINTER TO [<xcDevice> | <xcFile> [ADDITIVE]]
The on|OFF form of SET PRINTER controls whether the output of console commands is echoed to the printer.
TO <xcDevice> identifies the name of the device where all subsequent printed output will be sent.
TO <xcFile> identifies the name of the output file. ( If a file extension is not specified, (.prn) is assumed.)
By using that last method we can send our lines to a file, instead of sending directly to printer:
SET PRINTER TO Prnfile.txt SET DEVICE TO PRINTER SET PRINTER ON // @ 0, 0 SAY "This goes to Prnfile.txt" ? "So will this!" // SET DEVICE TO SCREEN SET PRINTER OFF SET PRINTER TO // Close the print file
Note that, though our target is not printer, we have use a SETting printer ON.
We have another method for sending someting to a file may be SET ALTERNATE command:
SET ALTERNATE TO [<xcFile> [ADDITIVE]] SET ALTERNATE on | OFF | <xlToggle>
SET ALTERNATE is a console command that lets you write the output of console commands to a text file. Commands such as LIST, REPORT FORM, LABEL FORM, and ? that display to the screen without reference to row and column position are console commands. Most of these commands have a TO FILE clause that performs the same function as SET ALTERNATE. Full-screen commands such as @…SAY cannot be echoed to a disk file using SET ALTERNATE. Instead you can use SET PRINTER TO <xcFile> with SET DEVICE TO PRINTER to accomplish this.
SET ALTERNATE has two basic forms. The TO <xcFile> form creates a DOS text file with a default extension of (.txt) and overwrites any other file with the same name. Alternate files are not related to work areas with only one file open at a time. To close an alternate file, use CLOSE ALTERNATE, CLOSE ALL, or SET ALTERNATE TO with no argument.
The on|OFF form controls the writing of console output to the current alternate file. SET ALTERNATE ON begins the echoing of output to the alternate file. SET ALTERNATE OFF suppresses output to the alternate file but does not close it.
Examples :
This example creates an alternate file and writes the results of the ? command to the file for each record in the Customer database file:
SET ALTERNATE TO Listfile SET ALTERNATE ON
USE Customer NEW DO WHILE !EOF() ? Customer->Lastname, Customer->City SKIP ENDDO SET ALTERNATE OFF CLOSE ALTERNATE CLOSE Customer
A single difficulty may be making choose the best between possible methods
You can download a working example prg with a sample .dbf from here :
Execute a pop-up menu
ACHOICE(<nTop>, <nLeft>, <nBottom>, <nRight>, <acMenuItems>, [<alSelectableItems> | <lSelectableItems>], [<cUserFunction>], [<nInitialItem>], [<nWindowRow>]) --> nPosition
Browse records within a window
BROWSE([<nTop>], [<nLeft>], [<nBottom>], [<nRight>]) --> lSuccess
Browse records in a table format
DBEDIT( [<nTop>], [<nLeft>], [<nBottom>], <nRight>], [<acColumns>], [<cUserFunction>], [<acColumnSayPictures> | <cColumnSayPicture>], [<acColumnHeaders> | <cColumnHeader>], [<acHeadingSeparators> | <cHeadingSeparator>], [<acColumnSeparators> | <cColumnSeparator>], [<acFootingSeparators> | <cFootingSeparator>], [<acColumnFootings> | <cColumnFooting>]) --> NIL
Display records to the console
DISPLAY <exp list> [TO PRINTER] [TO FILE <xcFile>] [<scope>] [WHILE <lCondition>] [FOR <lCondition>] [OFF]
List records to the console
LIST <exp list> [TO PRINTER] [TO FILE <xcFile>] [<scope>] [WHILE <lCondition>] [FOR <lCondition>] [OFF]
Display labels to the console
LABEL FORM <xcLabel> [TO PRINTER] [TO FILE <xcFile>] [NOCONSOLE] [<scope>] [WHILE <lCondition>] [FOR <lCondition>] [SAMPLE]
Display a report to the console
REPORT FORM <xcReport> [TO PRINTER] [TO FILE <xcFile>] [NOCONSOLE] [<scope>] [WHILE <lCondition>] [FOR <lCondition>] [PLAIN | HEADING <cHeading>] [NOEJECT] [SUMMARY]
Display a literal block of text
TEXT [TO PRINTER] [TO FILE <xcFile>] <text>... ENDTEXT
LIST List records to the console ------------------------------------------------------------------------------ Syntax LIST <exp list> [TO PRINTER] [TO FILE <xcFile>] [<scope>] [WHILE <lCondition>] [FOR <lCondition>] [OFF] Arguments <exp list> is the list of expressions to be evaluated and displayed for each record processed. TO PRINTER echoes output to the printer. TO FILE <xcFile> echoes output to the specified file name and can be specified either as a literal file name or as a character expression enclosed in parentheses. If an extension is not specified, .txt is added. <scope> is the portion of the current database file to LIST. The default is ALL records. WHILE <lCondition> specifies the set of records meeting the condition from the current record until the condition fails. FOR <lCondition> specifies the conditional set of records to LIST within the given scope. OFF suppresses the display of record numbers. Description LIST is a console command that sequentially accesses records in the current work area, displaying the results of one or more expressions for each record accessed. The output is in tabular format with each column separated by a space. LIST is identical to DISPLAY with the exception that its default scope is ALL rather than NEXT 1. When invoked, output is sent to the screen and, optionally, to the printer and/or a file. To suppress output to the screen while printing or echoing output to a file, SET CONSOLE OFF before the LIST invocation. Notes . Interrupting LIST: So the user may interrupt a LIST, use INKEY() as part of the FOR condition to test for an interrupt key press. See the example below. . Printer margin: LIST honors the current SET MARGIN for output echoed to the printer. Examples . In this example, a simple list is followed by a conditional list to the printer: USE Sales LIST DATE(), TIME(), Branch LIST Branch, Salesman FOR Amount > 500 TO PRINTER . This example interrupts LIST using INKEY() to test whether the user pressed the Esc key: #define K_ESC 27 USE Sales INDEX Salesman NEW LIST Branch, Salesman, Amount WHILE INKEY() != K_ESC Files Library is CLIPPER.LIB.
PROC Main()
cList := " arabesque, bolero, clair de lune, la mere, nocturnes, debussy" aList := HB_ATOKENS( cList, ',' ) AEVAL( aList, { | c1 | QOUT( c1 ) } )
/* Result : arabesque bolero clair de lune la mere nocturnes debussy */ ? WAIT "EOF Lst2Arry.prg" RETU // Lst2Arry.prg