__TextSave()

Template

Procedure

Name

__TextSave()

Category

API

Subcategory

Internal

Oneliner

Redirect console output to printer or file and save old settings

Syntax

      __TextSave( <cFile> )

Arguments

<cFile> is either “PRINTER” (note the uppercase) in which console output is SET to PRINTER, or a name of a text file with a default “.txt” extension, that is used to redirect console output.

Description

__TextSave() is used in the preprocessing of the TEXT TO command to redirect the console output while saving old settings that can be restored later by __TextRestore().

Compliance

C52U

Platforms

All

Files

Library is core

Seealso

Set(), SET ALTERNATE, SET PRINTER, TEXT, __TextRestore()

__TextRestore()

Template

Procedure

Name

__TextRestore()

Category

API

Subcategory

Internal

Oneliner

Restore console output settings as saved by __TextSave()

Syntax

      __TextRestore()

Arguments

none.

Description

__TextRestore() is used in the preprocessing of the TEXT TO command to restore console output settings that were previously saved by __TextSave().

Compliance

C52U

Platforms

All

Files

Library is core

Seealso

Set(), SET ALTERNATE, SET PRINTER, TEXT, __TextSave()

SP_STRPULL

STRPULL()

  Short:
  ------
  STRPULL() Extract text between 2 characters in a string

  Returns:
  --------
  <cExtract> => text extracted

  Syntax:
  -------
  STRPULL(cSource,cDelim1,cDelim2)

  Description:
  ------------
  Extracts text from <cSource> between characters
  <cDelim1> and <cDelim2>.

  If <cDelim1> is empty, uses beginning of <cSource>.

  If <cDelim2> is empty, uses end of <cSource>.

  Examples:
  ---------
   cString := "SUPERFUNCTION"

   cString := STRPULL(cString,'E','C')

   // (returns "RFUN")

  Source:
  -------
  S_STRPUL.PRG

 

SP_ARRANGE

ARRANGE()

  Short:
  ------
  ARRANGE() Rearranges text in a string

  Returns:
  --------
  <cNewString> => String rearranged

  Syntax:
  -------
  ARRANGE(cInString,nStart,nLength,nNewPosit)

  Description:
  ------------
  Extracts text from <cInString> starting at <nStart>
  for a length of <nLength> and moves it to position
  <nNewPosition>.

  Examples:
  ---------
   cString := "SUPERFUNCTION"
   cString := ARRANGE(cString,6,8,1)
    // =>  "FUNCTIONSUPER"

  Notes:
  ------
  New position is position AFTER text is cut from
  original position

  Source:
  -------
  S_ARRANG.PRG

 

FT_PCHR

FT_PCHR()
 Convert printer control codes

 Syntax

       FT_PCHR( <cString> )  ->  <cPrinterFormat>

 Arguments

       <cString> is the representation of the printer control codes in
       text, numeric, hexadecimal, Epson command format, or any combination
       separated by commas.

 Returns

       A character string of printer control codes.

 Description

       This function is useful for allowing the user to enter printer
       control codes in text (enclosed in double quotes), numeric,
       hexadecimal, or Epson commands preceded by a slash and returns
       the printer control code equivalent.

       NOTES"

         - Combinations of text, numbers, hex, and commands must be
            separated by commas ("A",27,&1B,/RESET).
         - Text must be enclosed in double quotes ("x").
         - Hexadecimal must be preceded by an ampersand (&1B).
         - Epson commands, listed below, must be preceded by a forward
            slash (/RESET).

         Epson commands: (slash commands are specific to the Epson)

           Job Control:

           /RESET or /INIT   Reset or initialize the printer
           /BELL  or /BEEP   Cause the printer's speaker to beep (not HS)
           /CAN              Clear print buffers (not MX)
           /SLOW             Set low speed mode (not CR, HS, MX)
           /FAST             Cancel low speed mode (not CR, HS, MX)
           /ONE              Select Unidirectional mode
           /TWO              Select Directional mode
           /ON               Activate printer
           /OFF              Turn off printer

           /FF or /EJECT     Form Feed

           Page Control:

           /1/6              Set 6 lines per inch
           /1/8              Set 8 lines per inch
           /SKIP             Set Skip perforation ON
           /SKIPOFF          Set Skip perforation OFF

           Font Selection and Manipulation:

           /ITALIC           Select italic char. set  (only FX86, EX, LX,
                                                           no LQ-1500, SX)
           /GRAPHIC          Select graphic char. set (only FX86, EX, LX,
                                                           no LQ-1500, SX)
           /ROMAN            Choose Roman font
           /SANS             Choose Sans Serif font
           /DRAFT            Choose draft
           /NLQ              Choose near letter quality
           /PICA             Choose 10 chars per inch
           /ELITE            Choose 12 chars per inch
           /COND or /SI      Choose 15 chars per inch
           /EMPH             Turn emphasize on
           /EMPHOFF          Turn emphasize off
           /SPANISH          Select spanish international char set
           /USA              Select USA international char set

 Examples

       cSetUp := '27,116,1'
       Set Print ON
       ? FT_PCHR( cSetUp )      ->  (CHR(27)+CHR(116)+CHR(1))
                                            <select Epson char. graphics>

       ? FT_PCHR( '27,"x",0' )  ->  (CHR(27)+CHR(120)+CHR(0))
                                         <Epson draft mode>

       ? FT_PCHR( '&1B,"E"'  )  ->  (CHR(27)+CHR(69))   <HP reset>

       ? FT_PCHR( '/ELITE,/NLQ' ) ->(CHR(27)+CHR(77)+CHR(27)+CHR(120)+CHR(1))
                                <Epson elite & near letter quality>

 Source: PCHR.PRG

 Author: Jim Gale

 

C5 UI – Advanced

C5 UI – Advanced

ACHOICE() :

Execute a pop-up menu

ACHOICE(<nTop>, <nLeft>, <nBottom>, <nRight>,
    <acMenuItems>,
    [<alSelectableItems> | <lSelectableItems>],
    [<cUserFunction>],
    [<nInitialItem>],
    [<nWindowRow>]) --> nPosition

BROWSE()* :

Browse records within a window

BROWSE([<nTop>], [<nLeft>],
    [<nBottom>], [<nRight>]) --> lSuccess

DBEDIT() :

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 :

Display records to the console

DISPLAY <exp list>
    [TO PRINTER] [TO FILE <xcFile>]
    [<scope>] [WHILE <lCondition>]
    [FOR <lCondition>] [OFF]

LIST :

List records to the console

LIST <exp list>
    [TO PRINTER] [TO FILE <xcFile>]
    [<scope>] [WHILE <lCondition>]
    [FOR <lCondition>] [OFF]

LABEL FORM :

Display labels to the console

LABEL FORM <xcLabel>
    [TO PRINTER] [TO FILE <xcFile>] [NOCONSOLE]
    [<scope>] [WHILE <lCondition>] [FOR <lCondition>]
    [SAMPLE]

REPORT FORM :

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]

TEXT :

Display a literal block of text

TEXT [TO PRINTER] [TO FILE <xcFile>]
    <text>...
ENDTEXT

C5_TEXT

TEXT*
 Display a literal block of text
------------------------------------------------------------------------------
 Syntax

     TEXT [TO PRINTER] [TO FILE <xcFile>]
        <text>...
     ENDTEXT

 Arguments

     <text> is the block of literal characters to be displayed to the
     screen.  Text is displayed exactly as formatted.

     TO PRINTER echoes the display to the printer.

     TO FILE <xcFile> echoes the display to the specified file.  <xcFile>
     may be specified as a literal file name or as a character expression
     enclosed in parentheses.  If no extension is specified, .txt is assumed.

 Description

     TEXT...ENDTEXT is a console command construct that displays a block of
     text to the screen, optionally echoing output to the printer and/or a
     text file.  To suppress output to the screen while printing or echoing
     output to a file, SET CONSOLE OFF before the TEXT command line.

     Text within the TEXT construct displays exactly as formatted, including
     any indentation.  Hard carriage returns are output as new lines, soft
     carriage returns as the character CHR(141).  Macro variables found
     within TEXT...ENDTEXT are expanded.  However, macro expressions are not.

     TEXT...ENDTEXT is a compatibility command and not recommended.
     Clipper has other facilities for text processing and output.  For
     example, MEMOLINE() in combination with MLCOUNT() can word wrap long
     strings according to a specified line length.  ? or @...SAY can display
     formatted text extracted from a long string with MEMOLINE().

 Examples

     .  This example demonstrates how to use TEXT...ENDTEXT to print a
        form letter:

        USE Sales NEW
        DO WHILE !EOF()
           FormLetter()
           SKIP
        ENDDO
        RETURN

        FUNCTION FormLetter
           LOCAL dDate := DTOC(DATE()), cSalesman := ;
                    RTRIM(Salesman)
           TEXT TO PRINTER
           &dDate.
           Dear &cSalesman.,
           How are you!
           ENDTEXT
           EJECT
           RETURN NIL

 Files   Library is CLIPPER.LIB.

See Also: ?|?? @…SAY MEMOLINE() MLCOUNT() SET CONSOLE



C5 Commands

 ?|??            Display one or more values to the console
 @...BOX         Draw a box on the screen
 @...CLEAR       Clear a rectangular region of the screen
 @...GET         Create a new Get object and display it
 @...PROMPT      Paint a menu item and define a message
 @...SAY         Display data at a specified screen or printer row and column
 @...TO          Draw a single- or double-line box
 ACCEPT*         Place keyboard input into a memory variable
 APPEND BLANK    Add a new record to the current database file
 APPEND FROM     Import records from a database (.dbf) file or ASCII text file
 AVERAGE         Average numeric expressions in the current work area
 CALL*           Execute a C or Assembler procedure
 CANCEL*         Terminate program processing
 CLEAR ALL*      Close files and release public and private variables
 CLEAR GETS      Release Get objects from the current GetList array
 CLEAR MEMORY    Release all public and private variables
 CLEAR SCREEN    Clear the screen and return the cursor home
 CLEAR TYPEAHEAD Empty the keyboard buffer
 CLOSE           Close a specific set of files
 COMMIT          Perform a solid-disk write for all active work areas
 CONTINUE        Resume a pending LOCATE
 COPY FILE       Copy a file to a new file or to a device
 COPY STRUCTURE  Copy the current .dbf structure to a new database (.dbf) file
 COPY STRU EXTE  Copy field definitions to a .dbf file
 COPY TO         Export records to a database (.dbf) file or ASCII text file
 COUNT           Tally records to a variable
 CREATE          Create an empty structure extended (.dbf) file
 CREATE FROM     Create a new .dbf file from a structure extended file
 DELETE          Mark records for deletion
 DELETE FILE     Remove a file from disk
 DELETE TAG      Delete a tag
 DIR*            Display a listing of files from a specified path
 DISPLAY         Display records to the console
 EJECT           Advance the printhead to top of form
 ERASE           Remove a file from disk
 FIND*           Search an index for a specified key value
 GO              Move the pointer to the specified identity
 INDEX           Create an index file
 INPUT*          Enter the result of an expression into a variable
 JOIN            Create a new database file by merging from two work areas
 KEYBOARD        Stuff a string into the keyboard buffer
 LABEL FORM      Display labels to the console
 LIST            List records to the console
 LOCATE          Search sequentially for a record matching a condition
 MENU TO         Execute a lightbar menu for defined PROMPTs
 NOTE*           Place a single-line comment in a program file
 PACK            Remove deleted records from a database file
 QUIT            Terminate program processing
 READ            Activate full-screen editing mode using Get objects
 RECALL          Restore records marked for deletion
 REINDEX         Rebuild open indexes in the current work area
 RELEASE         Delete public and private memory variables
 RENAME          Change the name of a file
 REPLACE         Assign new values to field variables
 REPORT FORM     Display a report to the console
 RESTORE         Retrieve memory variables from a memory (.mem) file
 RESTORE SCREEN* Display a saved screen
 RUN             Execute a DOS command or program
 SAVE            Save variables to a memory (.mem) file
 SAVE SCREEN*    Save the current screen to a buffer or variable
 SEEK            Search an order for a specified key value
 SELECT          Change the current work area
 SET ALTERNATE   Echo console output to a text file
 SET BELL        Toggle sounding of the bell during full-screen operations
 SET CENTURY     Modify the date format to include or omit century digits
 SET COLOR*      Define screen colors
 SET CONFIRM     Toggle required exit key to terminate GETs
 SET CONSOLE     Toggle console display to the screen
 SET CURSOR      Toggle the screen cursor on or off
 SET DATE        Set the date format for input and display
 SET DECIMALS    Set the number of decimal places to be displayed
 SET DEFAULT     Set the CA-Clipper default drive and directory
 SET DELETED     Toggle filtering of deleted records
 SET DELIMITERS  Toggle or define GET delimiters
 SET DESCENDING  Change the descending flag of the controlling order
 SET DEVICE      Direct @...SAYs to the screen or printer
 SET EPOCH       Control the interpretation of dates with no century digits
 SET ESCAPE      Toggle Esc as a READ exit key
 SET EXACT*      Toggle exact matches for character strings
 SET EXCLUSIVE*  Establish shared or exclusive USE of database files
 SET FILTER      Hide records not meeting a condition
 SET FIXED       Toggle fixing of the number of decimal digits displayed
 SET FORMAT*     Activate a format when READ is executed
 SET FUNCTION    Assign a character string to a function key
 SET INDEX       Open one or more order bags in the current work area
 SET INTENSITY   Toggle enhanced display of GETs and PROMPTs
 SET KEY         Assign a procedure invocation to a key
 SET MARGIN      Set the page offset for all printed output
 SET MEMOBLOCK   Change the block size for memo files
 SET MESSAGE     Set the @...PROMPT message line row
 SET OPTIMIZE    Change the setting that optimizes using open orders
 SET ORDER       Select the controlling order
 SET PATH        Specify the CA-Clipper search path for opening files
 SET PRINTER     Toggle echo of output to printer or set the print destination
 SET PROCEDURE*  Compile procedures and functions into the current object file
 SET RELATION    Relate two work areas by a key value or record number
 SET SCOPE       Change the boundaries for scoping keys in controlling order
 SET SCOPEBOTTOM Change bottom boundary for scoping keys in controlling order
 SET SCOPETOP    Change top boundary for scoping keys in controlling order
 SET SCOREBOARD  Toggle the message display from READ or MEMOEDIT()
 SET SOFTSEEK    Toggle relative seeking
 SET TYPEAHEAD   Set the size of the keyboard buffer
 SET UNIQUE*     Toggle inclusion of non-unique keys into an index
 SET WRAP*       Toggle wrapping of the highlight in menus
 SKIP            Move the record pointer to a new position
 SORT            Copy to a database (.dbf) file in sorted order
 STORE*          Assign a value to one or more variables
 SUM             Sum numeric expressions and assign results to variables
 TEXT*           Display a literal block of text
 TOTAL           Summarize records by key value to a database (.dbf) file
 TYPE            Display the contents of a text file
 UNLOCK          Release file/record locks set by the current user
 UPDATE          Update current database file from another database file
 USE             Open an existing database (.dbf) and its associated files
 WAIT*           Suspend program processing until a key is pressed
 ZAP             Remove all records from the current database file

 

Parsing Text – Tokens

/*
From Harbour changelog (at 2007-04-04 10:35 UTC+0200 By Przemyslaw Czerpak )
Added set of functions to manipulate string tokens:
HB_TOKENCOUNT( <cString>, [ <cDelim> ], [ <lSkipStrings> ],
 [ <lDoubleQuoteOnly> ] ) -> <nTokens>

 HB_TOKENGET( <cString>, <nToken>, [ <cDelim> ], [ <lSkipStrings> ],
 [ <lDoubleQuoteOnly> ] ) -> <cToken>

 HB_TOKENPTR( <cString>, @<nSkip>, [ <cDelim> ], [ <lSkipStrings> ],
 [ <lDoubleQuoteOnly> ] ) -> <cToken>

 HB_ATOKENS( <cString>, [ <cDelim> ], [ <lSkipStrings> ],
 [ <lDoubleQuoteOnly> ] ) -> <aTokens>

 All these functions use the same method of tokenization. They can
 accept as delimiters string longer then one character. By default
 they are using " " as delimiter. " " delimiter has special mening

 Unlike other delimiters repeted ' ' characters does not create empty
 tokens, f.e.: 

 HB_ATOKENS( " 1 2 3 " ) returns array:
 { "1", "2", "3" }

 Any other delimiters are restrictly counted, f.e.:

 HB_ATOKENS( ",,1,,2,") returns array:
 { "", "", "1", "", "2", "" }
And a strong suggession made at 2009-12-09 21:25 UTC+0100 ( By Przemyslaw Czerpak )
I strongly suggest to use hb_aTokens() and hb_token*() functions.
 They have more options and for really large data many times
 (even hundreds times) faster.

*/
#define CRLF HB_OsNewLine()
PROCEDURE Main()
LOCAL cTextFName := "Shakespeare.txt",;
 c1Line 

 SET COLO TO "W/B"
 SetMode( 40, 120 )

 CLS

 HB_MEMOWRIT( cTextFName,;
 "When in eternal lines to time thou grow'st," + CRLF + ;
 "So long as men can breathe, or eyes can see," + CRLF + ;
 "So long lives this, and this gives life to thee." )

 aLines := HB_ATOKENS( MEMOREAD( cTextFName ), CRLF )

 ?
 ? "Text file line by line :"
 ?
 AEVAL( aLines, { | c1Line | QOUT( c1Line ) } )
 ?
 WAIT "Press a key for parsing as words"
 CLS
 ?
 ? "Text file word by word :"
 ?
 FOR EACH c1Line IN aLines
 a1Line := HB_ATOKENS( c1Line ) 
 AEVAL( a1Line, { | c1Word | QOUT( c1Word ) } )
 NEXT 
 ?
 WAIT "Press a key for parsing directly as words"
 CLS
 ?
 ? "Text file directly word by word :"
 ?
 aWords := HB_ATOKENS( MEMOREAD( cTextFName ) )
 AEVAL( aWords, { | c1Word | QOUT( c1Word ) } ) 

 ?
 @ MAXROW(), 0
 WAIT "EOF TP_Token.prg" 

RETURN // TP_Token.Main()
 TP_Token