Category : Dbase (Clipper, FoxBase, etc) Languages Source Code
Archive   : NFSRC21.ZIP
Filename : PRTESC.PRG

 
Output of file : PRTESC.PRG contained in archive : NFSRC21.ZIP
/*
* File......: PRTESC.PRG
* Author....: Steven Tyrakowski
* Date......: $Date: 15 Aug 1991 23:04:26 $
* Revision..: $Revision: 1.2 $
* Log file..: $Logfile: E:/nanfor/src/prtesc.prv $
*
* This is an original work by Steven Tyrakowski and is placed
* in the public domain.
*
* Modification history:
* ---------------------
*
* $Log: E:/nanfor/src/prtesc.prv $
*
* Rev 1.2 15 Aug 1991 23:04:26 GLENN
* Forest Belt proofread/edited/cleaned up doc
*
* Rev 1.1 14 Jun 1991 19:52:42 GLENN
* Minor edit to file header
*
* Rev 1.0 01 Apr 1991 01:02:02 GLENN
* Nanforum Toolkit
*
*/

#ifdef FT_TEST
FUNCTION MAIN( cParm1 )
*-------------------------------------------------------
* Sample routine to test function from command line
*-------------------------------------------------------

IF PCount() > 0
? FT_ESCCODE( cParm1 )
ELSE
? "Usage: PRT_ESC 'escape code sequence' "
? " outputs converted code to standard output"
?
ENDIF
RETURN (nil)
#endif

/* $DOC$
* $FUNCNAME$
* FT_ESCCODE()
* $CATEGORY$
* Conversion
* $ONELINER$
* Convert Lotus style escape codes
* $SYNTAX$
* FT_ESCCODE( ) ->
* $ARGUMENTS$
* is the ASCII representation of the printer control
* codes in Lotus 123 format (e.g. "\027E" for Chr(27)+"E")
*
* "\nnn" will be converted to Chr(nnn)
* "\\" will be converted to "\"
* $RETURNS$
* The binary version of an ASCII coded printer setup string.
* $DESCRIPTION$
* This function is useful for allowing the user to enter printer
* control codes in Lotus-style ASCII format, and then having
* this function convert that code to the format that the printer
* needs to receive.
* $EXAMPLES$
* cSetup = "\015" // default = Epson compressed print
* UserInput( @cSetup ) // Let user modify setup code
* SET DEVICE TO PRINT // get ready to print
* ?? FT_ESCCODE( cSetup ) // Output the converted code
* $END$
*/


FUNCTION FT_ESCCODE( cInput )

LOCAL cOutput := "" ,;
cCurrent ,;
nPointer := 1 ,;
nLen := Len( cInput )

DO WHILE nPointer <= nLen

cCurrent := Substr( cInput, nPointer, 1 )

DO CASE

CASE cCurrent == "\" .AND. ;
IsDigit(Substr(cInput, nPointer+1, 1) ) .AND. ;
IsDigit(Substr(cInput, nPointer+2, 1) ) .AND. ;
IsDigit(Substr(cInput, nPointer+3, 1) )
cOutput += Chr(Val(Substr(cInput, nPointer+1,3)))
nPointer += 4

CASE cCurrent == "\" .AND. ;
Substr(cInput, nPointer+1, 1) == "\"
cOutput += "\"
nPointer += 2

OTHERWISE
cOutput += cCurrent
nPointer++

ENDCASE
ENDDO

RETURN cOutput


  3 Responses to “Category : Dbase (Clipper, FoxBase, etc) Languages Source Code
Archive   : NFSRC21.ZIP
Filename : PRTESC.PRG

  1. Very nice! Thank you for this wonderful archive. I wonder why I found it only now. Long live the BBS file archives!

  2. This is so awesome! 😀 I’d be cool if you could download an entire archive of this at once, though.

  3. But one thing that puzzles me is the “mtswslnkmcjklsdlsbdmMICROSOFT” string. There is an article about it here. It is definitely worth a read: http://www.os2museum.com/wp/mtswslnk/