home *** CD-ROM | disk | FTP | other *** search
/ Monster Media 1993 #2 / Image.iso / database / dbx131.zip / FIXUP.PRG < prev    next >
Text File  |  1993-06-24  |  10KB  |  294 lines

  1. * Program...: FIXUP.PRG
  2. * Author....: David A. Kennedy
  3. * Date......: 01/04/92
  4. * Notes.....: This code is provided for users who want to use a third-party
  5. *             library with dbMAX, such as ProClip, FUNCky, Overlay(), IDL,
  6. *             Clipper Tools, NANFOR.LIB, etc.  If you DO use a library,
  7. *             DO NOT use DBMAX.LIB and REVISE all the replacement functions
  8. *             below.  Using FIXUP.prg as is and not using DBMAX.LIB will
  9. *             result in 100% Clipper code.
  10. *
  11. * Revised...: 02/24/92, ver 1.10 - rewrote NEWCOLOR() in straight Clipper
  12. *             07/01/92, ver 1.20 - revised for 132-column mode
  13. *             08/29/92, ver 1.21 - fixed error in sample alldrives() code
  14. *             01/31/93, ver 1.26 - minor text revisions
  15. *             02/01/93, ver 1.26 - wrote GETCOLOR() in Clipper
  16. *             03/17/93, ver 1.30 - revised for Clipper 5.2
  17. *
  18. *****************************************************************************
  19. *
  20. static vaColors := {'N  ','B  ','G  ','BG |GB ','R  ','RB |BR ','RG |GR ',;
  21.                     'W  ','+N |N+ ','+B |B+ ','+G |G+ ','+BG|+GB|BG+|GB+',;
  22.                     '+R |R+ ','+RB|+BR|RB+|BR+','+RG|+GR|RG+|GR+','+W |W+ '}
  23. *
  24. *****************************************************************************
  25. *
  26. function kbd_alt()
  27. *
  28. * Detects whether the <Alt> key is pressed.
  29. *
  30. * If you have FUNCky, use "return KBDSTAT(8)".
  31. * If you have NANFOR.LIB, use "return FT_ALT()".
  32. *
  33. return (.F.)
  34. *
  35. *****************************************************************************
  36. *
  37. function alldrives()
  38. *
  39. * Returns a string containing all available drive letters.
  40. *
  41. * If you have IDL 2.x, use "return DRV_LETTERS()".
  42. * If you have FUNCky, use "return DRIVESTR()".
  43. *
  44. return 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'          && fake it
  45. *
  46. *****************************************************************************
  47. *
  48. function dosargs(vnDummy)
  49. *
  50. * Returns the drive and path where the dbMAX .EXE is located.
  51. *
  52. * If you have NANFOR.LIB, use "return FT_ORIGIN()"
  53. *
  54. * The following code will not work properly if dbMAX is not run from the
  55. * current path or if the .EXE is renamed!  The program will not be able to
  56. * find the .INI/.ENV/help files and therefore you will need to run the
  57. * program using a batch file containing the lines:
  58. *
  59. *   @ECHO OFF
  60. *   CD\DBMAX                       (or wherever .EXE is located)
  61. *   DBX %1 %2 %3 %4 %5 %6 %7
  62. *
  63. return curpath()+'DBX.EXE'         && see CURPATH() below
  64. *
  65. *****************************************************************************
  66. *
  67. function clock(vcMode)
  68. *
  69. * Displays a ticking clock on the screen (vcMode="on" or "off").
  70. *
  71. * If you have IDL 2.x, you can use "return CLOCK()"
  72. *
  73. * If you have FUNCky, use:
  74. *
  75. * if vcMode='on'
  76. *   CLOCK12(0,maxcol()-7)
  77. * else
  78. *   UNCLOCK()
  79. * endif
  80. * return ''
  81. *
  82. return ''
  83. *
  84. *****************************************************************************
  85. *
  86. function curpath(vcDrive)
  87. *
  88. * Returns a string containing the full drive and path for the selected
  89. * drive.
  90. *
  91. * If you have FUNCky, use "return CURDIR()".
  92. *
  93. if vcDrive=nil
  94.   *vcDrive := CURDRIVE()              && IDL 2.x
  95.   *vcDrive := FT_DEFAULT()            && NANFOR.LIB
  96.   *
  97.   * -or-
  98.   *
  99.   * Set the default to drive C: or whatever drive that the .EXE is on!  If
  100.   * not set to the proper drive, the .INI/.ENV/help files will not be found!
  101.   *
  102.   vcDrive := 'C'
  103. endif
  104. return vcDrive+':\'+iif(empty(curdir(vcDrive)),'',curdir(vcDrive)+'\')
  105. *
  106. *****************************************************************************
  107. *
  108. function flipcolor(vcColor)
  109. *
  110. * Used only to provide enhanced color for the DOS screen, which is not
  111. * used in this version of dbMAX.
  112. *
  113. * If you have NANFOR.LIB, use "return FT_INVCLR(vcColor)"
  114. *
  115. return (vcColor)         && fake it
  116. *
  117. *****************************************************************************
  118. *
  119. function getcolor()
  120. *
  121. * Gets the color of the DOS screen.
  122. *
  123. * If you have IDL 2.x, use "return ATT2COLOR(SCR_GETATT())".
  124. *
  125. local vnColor := asc(substr(savescreen(row(),col(),row(),col()),2,1))
  126. local vnBG    := int(vnColor/16)
  127. local vnFG    := vnColor-(vnBG*16)
  128. *
  129. return (trim(substr(vaColors[vnFG+1],1,3))+'/'+ ;
  130.  trim(substr(vaColors[vnBG+1],1,3)))
  131. *
  132. *****************************************************************************
  133. *
  134. function isptr(vnPort)
  135. *
  136. * Returns .T. if the selected printer port is ready.
  137. *
  138. * If you have IDL 2.x, use "return ISPRINTER(vnPort)" or 
  139. * "return (LPT_STAT(vnPort)=0)".
  140. *
  141. * If you have FUNCky, use "return ISPRINTER(vnPort)" or
  142. * or "return ISLPT(vnPort)" or "return (PRNSTATUS(vnPort)=0)".
  143. *
  144. * If you have NANFOR.LIB, use "return FT_ISPRINT('LPT'+str(vnPort,1,0))"
  145. *
  146. return iif(vnPort=1,isprinter(),.F.)
  147. *
  148. *****************************************************************************
  149. *
  150. function newcolor(vnTop,vnLeft,vnBottom,vnRight,vcColor)
  151. *
  152. * Sets the background color for a rectangular area on the screen.
  153. *
  154. * If you have IDL 2.x, use
  155. * "return SCR_SETATT(COLOR2ATT(vcColor),vnTop,vnLeft,vnBottom,vnRight)"
  156. *
  157. * If you have NANFOR.LIB, you can use the following:
  158. *
  159. * local vnFG := vnBG := 0
  160. * local vcFG,vcBG
  161. * *
  162. * * use only the foreground color
  163. * *
  164. * vcColor := upper(iif(','$vcColor,substr(vcColor,1,at(',',vcColor)-1),vcColor))
  165. * *
  166. * vcFG := padr(left(vcColor,at('/',vcColor)-1),3)
  167. * vcBG := padr(substr(vcColor,at('/',vcColor)+1),3)
  168. * vnFG := ascan(vaColors,{|x| vcFG$x})-1
  169. * vnBG := ascan(vaColors,{|x| vcBG$x})-1
  170. * *
  171. * return FT_SETATTR(vnTop,vnLeft,vnBottom,vnRight,vnFG+vnBG*16)
  172. *
  173. *
  174. * If you really want to use Clipper, be aware that the following code is slow.
  175. *
  176. * Clipper 5.0 can revise background colors, but vcColor will have to be
  177. * translated into a number.  To calculate the number, add the foreground
  178. * color number to 16 times the background color number.  Add 128 to make the
  179. * foreground blink or for bright backgrounds if BLINK is OFF.
  180. *
  181. * For improved performance, instead of making the numeric calculations, you
  182. * can check vcColor.  If vcColor equals the shadow color, force the
  183. * attribute to be 7, otherwise, force it to be something else.
  184. *
  185. * Foreground/Background       Foreground colors only
  186. * =========================   =======================================
  187. * black = 0   red       = 4   dark grey    = 8    bright red     = 12
  188. * blue  = 1   magenta   = 5   bright blue  = 9    bright magenta = 13
  189. * green = 2   brown     = 6   bright green = 10   yellow         = 14
  190. * cyan  = 3   dim white = 7   bright cyan  = 11   bright white   = 15
  191. *
  192. * *
  193. * local vnFG := vnBG := 0
  194. * local vcFG,vcBG,vcScreen,vnTemp
  195. * *
  196. * * use only the foreground color
  197. * *
  198. * vcColor := upper(iif(','$vcColor,substr(vcColor,1,at(',',vcColor)-1),vcColor))
  199. * *
  200. * vcFG := padr(left(vcColor,at('/',vcColor)-1),3)
  201. * vcBG := padr(substr(vcColor,at('/',vcColor)+1),3)
  202. * vnFG := ascan(vaColors,{|x| vcFG$x})-1
  203. * vnBG := ascan(vaColors,{|x| vcBG$x})-1
  204. * *
  205. * vcScreen := savescreen(vnBottom,vnLeft,vnBottom,vnRight)
  206. * for vnTemp=2 to len(vcScreen) step 2
  207. *   vcScreen := stuff(vcScreen,vnTemp,1,chr(vnFG+vnBG*16))
  208. * next
  209. * restscreen(vnBottom,vnLeft,vnBottom,vnRight,vcScreen)
  210. * *
  211. * if vlType
  212. *   vcScreen := savescreen(vnTop,vnRight-1,vnBottom,vnRight)
  213. *   for vnTemp=2 to len(vcScreen) step 2
  214. *     vcScreen := stuff(vcScreen,vnTemp,1,chr(vnColor))
  215. *   next
  216. *   restscreen(vnTop,vnRight-1,vnBottom,vnRight,vcScreen)
  217. * endif
  218. * return (nil)
  219. *
  220. * -or-   (NOTE: hard-coded colors!)
  221. *        (comment out all but RETURN for max speed)
  222. *
  223. local vnColor  := 23       && 23 = 7+(16*1) = 'w/b'
  224. local vlType   := .T.      && .T. means you're doing a shadow; .F., a hotkey
  225. local vcScreen,vnTemp
  226. *
  227. do case
  228.   case vcColor=vcShadow                    && vcShadow is shadow color
  229.     vnColor := 7                           && 7 = w/n
  230.     *
  231.   case vcColor=vcHotKey                    && vcHotKey is hot key color
  232.     vnColor := 62                          && 62 = 14+(16*3) = +rg/bg
  233.     vlType  := .F.                         && not doing a shadow!
  234.     *
  235.   otherwise
  236.     *
  237.     * In this case, newcolor() is intended to "low-light" the browse window
  238.     * (w/b) to show it is inactive.  You can change the code to do the low-
  239.     * lighting (must do a filled box), but it will be very slow.  If you
  240.     * don't low-light, when browsing two databases on screen it may be
  241.     * difficult to tell which window is active.  Try setting the color to
  242.     * w/b and drawing an unfilled box as a compromise.
  243.     *
  244.     return (nil)
  245. endcase
  246. *
  247. vcScreen := savescreen(vnBottom,vnLeft,vnBottom,vnRight)
  248. for vnTemp=2 to len(vcScreen) step 2
  249.   vcScreen := stuff(vcScreen,vnTemp,1,chr(vnColor))
  250. next
  251. restscreen(vnBottom,vnLeft,vnBottom,vnRight,vcScreen)
  252. *
  253. if vlType
  254.   vcScreen := savescreen(vnTop,vnRight-1,vnBottom,vnRight)
  255.   for vnTemp=2 to len(vcScreen) step 2
  256.     vcScreen := stuff(vcScreen,vnTemp,1,chr(vnColor))
  257.   next
  258.   restscreen(vnTop,vnRight-1,vnBottom,vnRight,vcScreen)
  259. endif
  260. return (nil)
  261. *
  262. *****************************************************************************
  263. *
  264. function overlay(vcProg,vnFree,vcSwapPath,vcPrompt)
  265. *
  266. * Used to shell to DOS and shell out and run the hypertext help program.
  267. *
  268. * vcProg     = program to run, COMMAND.COM if empty
  269. * vnFree     = amount of memory to free (0=all)
  270. * vcSwapPath = path to create swapfile on
  271. * vcPrompt   = DOS prompt and/or other environment variable to set
  272. *
  273. * Other ways to do this could be to:
  274. *
  275. *   1) use the Blinker 2.x swap function(s):
  276. *
  277. *      SWPSETENV(vcPrompt)
  278. *      return SWPRUNCMD(vcProg,vnFree,'',vcSwapPath)
  279. *
  280. *      -or-
  281. *
  282. *   2) use SET CLIPPER=X:nn (if required) and a RUN (the HELP program
  283. *      requires 55K or so plus DOS needs anything from about 30K to 40K
  284. *      (DOS 5.0 may need over 100K)).  If you don't need to run anything
  285. *      too large, don't bother with the X:nn parameter.
  286. *
  287. if empty(vcProg)
  288.   run command
  289. else
  290.   run (vcProg)
  291. endif
  292. *
  293. return (nil)
  294.