home *** CD-ROM | disk | FTP | other *** search
- /*
- Various useful preprocessor directives
- Author: Greg Lief
- Excerpted from Grumpfish Library
- Copyright (c) 1991 Greg Lief
-
- (Discussed in Chapter 7 of "Clipper 5: A Developer's Guide")
- Copyright (c) 1991 M&T Books
- 501 Galveston Drive
- Redwood City, CA 94063-4728
- (415) 366-3600
- */
-
- #xtranslate SINGLEBOX(<top>, <left>, <bottom>, <right> [,<color>] ) => ;
- DispBox(<top>, <left>, <bottom>, <right>, "┌─┐│┘─└│ " [, <color>] )
-
- #xtranslate DOUBLEBOX(<top>, <left>, <bottom>, <right> [,<color>] ) => ;
- DispBox(<top>, <left>, <bottom>, <right>, '╔═╗║╝═╚║ ' [, <color>] )
-
- #define BOXFRAMES {'╔═╗║╝═╚║ ', '┌─┐│┘─└│ ', '╒═╕│╛═╘│ ', ;
- '╓─╖║╜─╙║ ', '█▀███▄██ ', SPACE(9) }
-
- /* compile a character string to a code block -- often preferable to do
- this instead of macro expansion for LOCATE conditions et cetera */
-
- #xtranslate MakeBlock(<string>) => <string> := &("{ | | " + <string> + "}")
-
- /* ¡the ubiquitous Center() function! */
- #xtranslate CENTER(<row>, <msg>, <width> [, <color>] ) => ;
- DevPos( <row>, int(( <width> - len( <msg> )) / 2)) ; ;
- DevOut( <msg> [,<color>] )
-
- #xtranslate CENTER(<row>, <msg> [, , <color> ] ) => ;
- DevPos( <row>, int((maxcol() + 1 - len( <msg> )) / 2)) ; ;
- DevOut( <msg> [, <color>] )
-
- /*
- a modified CENTER(), which uses setpos() and dispout() to ensure
- that output always goes to the screen and never the printer
- */
- #xtranslate SCRNCENTER(<row>, <msg> [, <color> ] ) => ;
- SetPos( <row>, int(( maxcol()+1 - len(<msg>)) / 2)) ; ;
- DispOut( <msg> [, <color>] )
-
- /*
- a modified @..SAY which uses setpos() and dispout() to ensure
- that output always goes to the screen and never the printer
- */
- #command @ <row>, <col> SSAY <xpr> [COLOR <color>] => ;
- SetPos( <row>, <col> ) ; DispOut( <xpr> [, <color>] )
-
-
- /* STRPAD() is no longer necessary in light of Clipper's PADR() */
- #xtranslate strpad(<msg>, <length>) => PADR(<msg>, <length>)
-
- /* add or remove file extensions */
- #xtranslate AddExtension(<file>, <ext>) => ;
- <file> := upper(<file>) + ;
- if(! "." + upper(<ext>) $ upper(<file>), "." + upper(<ext>), '')
-
- #xtranslate StripExt( <fname> ) => ;
- if('.' $ <fname>, substr( <fname>, 1, at('.', <fname>) - 1), <fname> )
-
-
- /* simple thingie to default all parameters to a specific value
- if they were not passed to the function */
- #xcommand DEFAULT <param> TO <value> => ;
- <param> := IF(<param> == NIL, <value>, <param>)
-
- // end of file MISC.CH
-