home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 5 / 05.iso / a / a012 / 1.ddi / CHAP07.EXE / MISC.CH < prev   
Encoding:
Text File  |  1991-04-30  |  2.6 KB  |  71 lines

  1. /*
  2.    Various useful preprocessor directives
  3.    Author: Greg Lief
  4.    Excerpted from Grumpfish Library
  5.    Copyright (c) 1991 Greg Lief
  6.  
  7.    (Discussed in Chapter 7 of "Clipper 5: A Developer's Guide")
  8.    Copyright (c) 1991 M&T Books
  9.                       501 Galveston Drive
  10.                       Redwood City, CA 94063-4728
  11.                       (415) 366-3600
  12. */
  13.  
  14. #xtranslate SINGLEBOX(<top>, <left>, <bottom>, <right> [,<color>] ) => ;
  15.            DispBox(<top>, <left>, <bottom>, <right>, "┌─┐│┘─└│ " [, <color>] )
  16.  
  17. #xtranslate DOUBLEBOX(<top>, <left>, <bottom>, <right> [,<color>] ) => ;
  18.            DispBox(<top>, <left>, <bottom>, <right>, '╔═╗║╝═╚║ ' [, <color>] )
  19.  
  20. #define BOXFRAMES {'╔═╗║╝═╚║ ', '┌─┐│┘─└│ ', '╒═╕│╛═╘│ ', ;
  21.                    '╓─╖║╜─╙║ ', '█▀███▄██ ', SPACE(9) }
  22.  
  23. /* compile a character string to a code block -- often preferable to do
  24.    this instead of macro expansion for LOCATE conditions et cetera     */
  25.  
  26. #xtranslate MakeBlock(<string>) => <string> := &("{ | | " + <string> + "}")
  27.  
  28. /* ¡the ubiquitous Center() function! */
  29. #xtranslate CENTER(<row>, <msg>, <width> [, <color>] ) => ;
  30.             DevPos( <row>, int(( <width> - len( <msg> )) / 2)) ; ;
  31.             DevOut( <msg> [,<color>] )
  32.  
  33. #xtranslate CENTER(<row>, <msg> [, , <color> ] ) => ;
  34.             DevPos( <row>, int((maxcol() + 1 - len( <msg> )) / 2)) ; ;
  35.             DevOut( <msg> [, <color>] )
  36.  
  37. /*
  38.    a modified CENTER(), which uses setpos() and dispout() to ensure
  39.    that output always goes to the screen and never the printer
  40. */
  41. #xtranslate SCRNCENTER(<row>, <msg> [, <color> ] ) => ;
  42.             SetPos( <row>, int(( maxcol()+1 - len(<msg>)) / 2)) ; ;
  43.             DispOut( <msg> [, <color>] )
  44.  
  45. /*
  46.    a modified @..SAY which uses setpos() and dispout() to ensure
  47.    that output always goes to the screen and never the printer
  48. */
  49. #command @ <row>, <col> SSAY <xpr> [COLOR <color>] => ;
  50.          SetPos( <row>, <col> ) ; DispOut( <xpr> [, <color>] )
  51.  
  52.  
  53. /* STRPAD() is no longer necessary in light of Clipper's PADR() */
  54. #xtranslate strpad(<msg>, <length>) => PADR(<msg>, <length>)
  55.  
  56. /* add or remove file extensions */
  57. #xtranslate AddExtension(<file>, <ext>) => ;
  58.        <file> := upper(<file>) + ;
  59.        if(! "." + upper(<ext>) $ upper(<file>), "." + upper(<ext>), '')
  60.  
  61. #xtranslate StripExt( <fname> ) => ;
  62.       if('.' $ <fname>, substr( <fname>, 1, at('.', <fname>) - 1), <fname> )
  63.  
  64.  
  65. /* simple thingie to default all parameters to a specific value
  66.    if they were not passed to the function */
  67. #xcommand DEFAULT <param> TO <value> => ;
  68.          <param> := IF(<param> == NIL, <value>, <param>)
  69.  
  70. // end of file MISC.CH
  71.