home *** CD-ROM | disk | FTP | other *** search
/ Shareware 1 2 the Maxx / sw_1.zip / sw_1 / DBASE / DBX112.ZIP / FIXUP.PRG < prev    next >
Text File  |  1992-04-07  |  11KB  |  316 lines

  1. * Program...: FIXUP.PRG
  2. * Author....: David A. Kennedy
  3. * Date......: 01/04/92
  4. * Notes.....: This code is provided for users who don't have IDL, ProClip,
  5. *             or Overlay() libraries.  If you do have one of the libraries,
  6. *             be sure to delete all the replacement functions below.  Using
  7. *             this code AS IS will result in 100% Clipper code.
  8. *
  9. * Revised...: 02/24/92, ver 1.10 - rewrote NEWCOLOR() in straight Clipper
  10. *
  11. *****************************************************************************
  12. *
  13. function kbd_alt()
  14. *
  15. * Replacement for IDL 2.11 function of the same name.
  16. *
  17. * If you have FUNCky, use "return KBDSTAT(8)".
  18. *
  19. * If you have NANFOR.LIB, use "return FT_ALT()".
  20. *
  21. return (.F.)
  22. *
  23. *****************************************************************************
  24. *
  25. function alldrives()
  26. *
  27. * Replacement for ProClip 4.0 function of the same name.
  28. *
  29. * If you have IDL 2.11, use "return DRV_LETTERS()".
  30. *
  31. * If you have FUNCky, use "return DRIVESTR()".
  32. *
  33. * If you have NANFOR.LIB, you may want to make repeated calls to FT_EXIST()
  34. * (for A:-Z:), which would work even better than ProClip/IDL but would be
  35. * MUCH slower the first time the function is called:
  36. *
  37. * static vcDrives := nil
  38. * *
  39. * local vnTemp
  40. * *
  41. * if vcDrives=nil
  42. *   for vnTemp=65 to 90                   && A: - Z:
  43. *     if FT_EXIST(asc(vnTemp)+':')
  44. *       vcDrives := vcDrives+asc(vnTemp)
  45. *     endif
  46. *   next
  47. * endif
  48. * return (vcDrives)
  49. *
  50. return 'ABCDEF'                          && fake it
  51. *
  52. *****************************************************************************
  53. *
  54. function dosargs(vnDummy)
  55. *
  56. * Replacement for ProClip 4.0 function of the same name.
  57. *
  58. * If you have NANFOR.LIB, use "return FT_ORIGIN()", although ProClip can
  59. * return all the command line parameters.
  60. *
  61. *   Warning:  FT_ORIGIN() apparently contains a bug, since on my machine
  62. *   (Compaq 386+DOS 3.31+QEMM 6.01) I get garbage as a return value!
  63. *
  64. * The following code will not work properly if dbMAX is not run from the
  65. * current path or if the .EXE is renamed!  The program will not be able to
  66. * find the .INI/.ENV/help files and therefore you will need to run the
  67. * program using a batch file containing the lines:
  68. *
  69. *   @ECHO OFF
  70. *   CD\DBMAX                       (or wherever .EXE is located)
  71. *   DBX %1 %2 %3 %4 %5 %6 %7
  72. *
  73. return curpath()+'DBX.EXE'         && see CURPATH() below
  74. *
  75. *****************************************************************************
  76. *
  77. function clock(vcMode)
  78. *
  79. * Replacement for ProClip 4.0 function of the same name (vcMode="on" or
  80. * "off").
  81. *
  82. * If you have IDL 2.11, you can use CLOCK(), but IDL's clock will crash your
  83. * PC if you bomb the program without turning the clock off, unlike ProClip.
  84. *
  85. * If you have FUNCky, use:
  86. *
  87. * if vcMode='on'
  88. *   CLOCK12(0,72)
  89. * else
  90. *   UNCLOCK()
  91. * endif
  92. * return ''
  93. *
  94. return ''
  95. *
  96. *****************************************************************************
  97. *
  98. function curpath(vcDrive)
  99. *
  100. * Replacement for ProClip 4.0 function of the same name.
  101. *
  102. * If you have FUNCky, use "return CURDIR()".
  103. *
  104. * If you have NANFOR.LIB or IDL 2.11, use:
  105. *
  106. * if vcDrive=nil
  107. *   vcDrive := CURDRIVE()              && IDL 2.11
  108. *    -or-
  109. *   vcDrive := FT_DEFAULT()            && NANFOR.LIB
  110. * endif
  111. * return vcDrive+':\'+iif(empty(curdir(vcDrive)),'',curdir(vcDrive)+'\')
  112. *
  113. if vcDrive=nil
  114.   *
  115.   * Set the default to drive C: or whatever drive that the .EXE is on!  If
  116.   * not set to the proper drive, the .INI/.ENV/help files will not be found!
  117.   *
  118.   vcDrive := 'C'
  119. endif
  120. *
  121. return vcDrive+':\'+iif(empty(curdir(vcDrive)),'',curdir(vcDrive)+'\')
  122. *
  123. *****************************************************************************
  124. *
  125. function flipcolor(vcColor)
  126. *
  127. * Replacement for ProClip 4.0 function of the same name.
  128. *
  129. * If you have NANFOR.LIB, use "return FT_INVCLR(vcColor)"
  130. *
  131. return (vcColor)         && fake it
  132. *
  133. *****************************************************************************
  134. *
  135. function getcolor()
  136. *
  137. * Replacement for ProClip 4.0 function of the same name (this function is
  138. * used only to get the color of the DOS screen).
  139. *
  140. * If you have IDL 2.11, use "return ATT2COLOR(SCR_GETATT())".
  141. *
  142. return '+w/b'            && fake it (SETCOLOR() will NOT work)
  143. *
  144. *****************************************************************************
  145. *
  146. function isptr(vnPort)
  147. *
  148. * Replacement for ProClip 4.0 function of the same name.
  149. *
  150. * If you have IDL 2.11, use "return ISPRINTER(vnPort)" or
  151. * "return (LPT_STAT(vnPort)=0)".
  152. *
  153. * If you have FUNCky, use "return ISPRINTER(vnPort)" or
  154. * or "return ISLPT(vnPort)" or "return (PRNSTATUS(vnPort)=0)".
  155. *
  156. * If you have NANFOR.LIB, use "return FT_ISPRINT('LPT'+str(vnPort,1,0))"
  157. *
  158. return iif(vnPort=1,isprinter(),.F.)
  159. *
  160. *****************************************************************************
  161. *
  162. function newcolor(vnTop,vnLeft,vnBottom,vnRight,vcColor)
  163. *
  164. * Replacement for ProClip 4.0 function of the same name.
  165. *
  166. * If you have IDL 2.11, use
  167. * "return SCR_SETATT(COLOR2ATT(vcColor),vnTop,vnLeft,vnBottom,vnRight)"
  168. *
  169. *
  170. * If you have NANFOR.LIB, you can use the following (based on the 5.0 code
  171. * detailed below):
  172. *
  173. * static vaColors := {'N  ','B  ','G  ','BG |GB ','R  ','RB |BR ','RG |GR ',;
  174. *                     'W  ','+N |N+ ','+B |B+ ','+G |G+ ','+BG|+GB|BG+|GB+',;
  175. *                     '+R |R+ ','+RB|+BR|RB+|BR+','+RG|+GR|RG+|GR+','+W |W+ '}
  176. * local vnFG := vnBG := 0
  177. * local vcFG,vcBG
  178. * *
  179. * * use only the foreground color
  180. * *
  181. * vcColor := upper(iif(','$vcColor,substr(vcColor,1,at(',',vcColor)-1),vcColor))
  182. * *
  183. * vcFG := padr(left(vcColor,at('/',vcColor)-1),3)
  184. * vcBG := padr(substr(vcColor,at('/',vcColor)+1),3)
  185. * vnFG := ascan(vaColors,{|x| vcFG$x})-1
  186. * vnBG := ascan(vaColors,{|x| vcBG$x})-1
  187. * *
  188. * return FT_SETATTR(vnTop,vnLeft,vnBottom,vnRight,vnFG+vnBG*16)
  189. *
  190. * -or-   (NOTE: hard-coded colors!)
  191. *
  192. * local vnTemp,vnColor := 23
  193. * *
  194. * if vcColor=vcShadow
  195. *   vnColor := 7
  196. * elseif vcColor=vcHotKey
  197. *   vnColor := 62
  198. * endif
  199. * return FT_SETATTR(vnTop,vnLeft,vnBottom,vnRight,vnColor)
  200. *
  201. *
  202. * If you really want to use Clipper, be aware that the following code is slow.
  203. *
  204. * Clipper 5.0 can revise background colors, but vcColor will have to be
  205. * translated into a number.  To calculate the number, add the foreground
  206. * color number to 16 times the background color number.  Add 128 to make the
  207. * foreground blink or for bright backgrounds if BLINK is OFF.
  208. *
  209. * For improved performance, instead of making the numeric calculations, you
  210. * can check vcColor.  If vcColor equals the shadow color, force the
  211. * attribute to be 7, otherwise, force it to be something else.
  212. *
  213. * Foreground/Background       Foreground colors only
  214. * =========================   =======================================
  215. * black = 0   red       = 4   dark grey    = 8    bright red     = 12
  216. * blue  = 1   magenta   = 5   bright blue  = 9    bright magenta = 13
  217. * green = 2   brown     = 6   bright green = 10   yellow         = 14
  218. * cyan  = 3   dim white = 7   bright cyan  = 11   bright white   = 15
  219. *
  220. * static vaColors := {'N  ','B  ','G  ','BG |GB ','R  ','RB |BR ','RG |GR ',;
  221. *                     'W  ','+N |N+ ','+B |B+ ','+G |G+ ','+BG|+GB|BG+|GB+',;
  222. *                     '+R |R+ ','+RB|+BR|RB+|BR+','+RG|+GR|RG+|GR+','+W |W+ '}
  223. * *
  224. * local vnFG := vnBG := 0
  225. * local vcFG,vcBG,vcScreen,vnTemp
  226. * *
  227. * * use only the foreground color
  228. * *
  229. * vcColor := upper(iif(','$vcColor,substr(vcColor,1,at(',',vcColor)-1),vcColor))
  230. * *
  231. * vcFG := padr(left(vcColor,at('/',vcColor)-1),3)
  232. * vcBG := padr(substr(vcColor,at('/',vcColor)+1),3)
  233. * vnFG := ascan(vaColors,{|x| vcFG$x})-1
  234. * vnBG := ascan(vaColors,{|x| vcBG$x})-1
  235. * *
  236. * vcScreen := savescreen(vnBottom,vnLeft,vnBottom,vnRight)
  237. * for vnTemp=2 to len(vcScreen) step 2
  238. *   vcScreen := stuff(vcScreen,vnTemp,1,chr(vnFG+vnBG*16))
  239. * next
  240. * restscreen(vnBottom,vnLeft,vnBottom,vnRight,vcScreen)
  241. * *
  242. * if vlType
  243. *   vcScreen := savescreen(vnTop,vnRight-1,vnBottom,vnRight)
  244. *   for vnTemp=2 to len(vcScreen) step 2
  245. *     vcScreen := stuff(vcScreen,vnTemp,1,chr(vnColor))
  246. *   next
  247. *   restscreen(vnTop,vnRight-1,vnBottom,vnRight,vcScreen)
  248. * endif
  249. * return (nil)
  250. *
  251. * -or-   (NOTE: hard-coded colors!)
  252. *        (comment out all but RETURN for max speed)
  253. *
  254. local vnColor  := 23       && 23 = 7+(16*1) = 'w/b'
  255. local vlType   := .T.      && .T. means you're doing a shadow; .F., a hotkey
  256. local vcScreen,vnTemp
  257. *
  258. do case
  259.   case vcColor=vcShadow                    && vcShadow is shadow color
  260.     vnColor := 7                           && 7 = w/n
  261.     *
  262.   case vcColor=vcHotKey                    && vcHotKey is hot key color
  263.     vnColor := 62                          && 62 = 14+(16*3) = +rg/bg
  264.     vlType  := .F.                         && not doing a shadow!
  265.     *
  266.   otherwise
  267.     *
  268.     * In this case, newcolor() is intended to "low-light" the browse window
  269.     * (w/b) to show it is inactive.  You can change the code to do the low-
  270.     * lighting (must do a filled box), but it will be very slow.  If you
  271.     * don't low-light, when browsing two databases on screen it may be
  272.     * difficult to tell which window is active.  Try setting the color to
  273.     * w/b and drawing an unfilled box as a compromise.
  274.     *
  275.     return (nil)
  276. endcase
  277. *
  278. vcScreen := savescreen(vnBottom,vnLeft,vnBottom,vnRight)
  279. for vnTemp=2 to len(vcScreen) step 2
  280.   vcScreen := stuff(vcScreen,vnTemp,1,chr(vnColor))
  281. next
  282. restscreen(vnBottom,vnLeft,vnBottom,vnRight,vcScreen)
  283. *
  284. if vlType
  285.   vcScreen := savescreen(vnTop,vnRight-1,vnBottom,vnRight)
  286.   for vnTemp=2 to len(vcScreen) step 2
  287.     vcScreen := stuff(vcScreen,vnTemp,1,chr(vnColor))
  288.   next
  289.   restscreen(vnTop,vnRight-1,vnBottom,vnRight,vcScreen)
  290. endif
  291. return (nil)
  292. *
  293. *****************************************************************************
  294. *
  295. function overlay(vcProg,vnDummy,vcDummy1,vcDummy2)
  296. *
  297. * Fakes Overlay 3.5 function of the same name, used to shell to DOS and to
  298. * run the hypertext help program).
  299. *
  300. * A better way to do this could be to
  301. *
  302. *   1) use the new Blinker 2.0 swap function, or
  303. *
  304. *   2) use SET CLIPPER=X:nn and a RUN (the HELP program requires 55K or so
  305. *      plus DOS needs anything from about 30K to 40K (DOS 5.0 may need over
  306. *      100K)).  If you don't need to run anything too large, don't bother
  307. *      with the X:nn parameter.
  308. *
  309. if empty(vcProg)
  310.   run command
  311. else
  312.   run (vcProg)
  313. endif
  314. *
  315. return (nil)
  316.