Contributed samples by Agil Abdullah
BosTaurus Show – Digital Artist
BosTaurus Show – Digital Artist
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()
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()
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
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() 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
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
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
/* 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()