home *** CD-ROM | disk | FTP | other *** search
/ Programmer 7500 / MAX_PROGRAMMERS.iso / CLIPPER / MISC / MAKEMEMS.ZIP / MAKEMEMS.PRG
Encoding:
Text File  |  1987-04-06  |  8.9 KB  |  281 lines

  1.  
  2. * Program.: MAKEMEMS.PRG
  3. * Author..: Harry F. Gilbert
  4. * Date....: 4/2/87
  5. * Version.: 1.00
  6. * Notice..: Copyright (c) 1987, Harry F. Gilbert, All Rights Reserved.
  7. * Notes...: Compiled with Clipper Autumn 1986 (Copyright Nantucket)
  8. * Purpose.: Creates .mem-type file for Shell System
  9. *
  10. *           This is an attempt to "externalize" the configuration
  11. *           variables and strings that clutter up my Clipper Code. By
  12. *           storing printer control codes, title strings, and common
  13. *           variables in .MEM-type files, they can be excluded from the
  14. *           .EXE file. This code fragment, which would normally be found in
  15. *           a stand-along installation program, generates a series of typical
  16. *           memory files, then allows you to choose from among the available
  17. *           printer definition files (xxx.PRT) which is then "copied" to
  18. *           the PRINTER.MEM file. The end user's program can thus change its
  19. *           current printer definition without having ANY printer data 
  20. *           hard coded! To add a printer, one merely sends the user a disk
  21. *           with any number of xxx.PRT files.
  22. *
  23. *           Note that Clipper allows use of .MEM type files with extensions
  24. *           other than .MEM; thus I define my printer definition files as
  25. *           <printername.PRT>, and then choose one to become PRINTER.MEM.
  26. *
  27. *           Also, note use of macro to handle the array name, and how the
  28. *           array element is passed to the Printbar procedure.
  29. *
  30. * Limitations: This code is for demonstration only; thus it doesn't handle
  31. *           very long lists of files that require multiple columns. You may
  32. *           wish to add such niceties as save/restore previous screen, turn
  33. *           cursor off during scroll bar, etc.
  34. *           Any suggestions for improvements are welcome, and should be sent
  35. *           to the author (Harry Gilbert) at THE BOSS DBBS
  36. *                                            (201) 568-7293
  37. *                                            1200,2400  N,8,1
  38. *           Register, join the Clipper conference, and support the board!
  39. *
  40. * Disclaimer: Copyright Holder (Harry F. Gilbert) hereby grants permission to
  41. *           copy and distribute this code freely, on condition that no charge
  42. *           whatsoever is levied for it. This software is provided FREELY
  43. *           on an "AS IS" basis, WITHOUT ANY WARRANTY, express or implied.
  44. *           IN PARTICULAR, the author disclaims all warranties or fitness for
  45. *           ANY PURPOSE, and the user waives ALL claims against author for
  46. *           special, direct, indirect, or consequential damages arising out
  47. *           of or in connection with the use or performance of this software.
  48. *
  49. * Compile Batch File:    
  50. *           RAMCLEAR   (See Data Based Advisor, October, 1986
  51. *           CLIPPER %1
  52. *           RAMCLEAR
  53. *           PLINK86 FI %1 LIB DBU
  54. *
  55. * Main Program Starts here to build .mem files for system
  56. *
  57. *
  58. SET COLOR TO "GR+/B,N/W,B"
  59. CLEAR
  60. @ 1,0 SAY "MEMORY FILE CREATION UTILITY"
  61. @ 2,0 SAY REPLICATE("=",80)
  62. @ 21,0 SAY REPLICATE("-",80)
  63. @ 22,0 SAY "Creating Memory Files"
  64. RELEASE ALL
  65. c_norm = "GR+/B,N/W,B"
  66. c_hilite = "N/G,N/W,B"
  67. c_box = "BG+/B,N/W,B"
  68. c_head = "W+/B,N/W,B"
  69. c_warn = "R*/W,N/W,B"
  70. c_alert = "R/W,N/W,B"
  71. c_1 = "W+/N,GR+/N,N"
  72. c_2 = "GR+/N,GR+/N,N"
  73. c_3 = "N/N,N/N,N"
  74. SAVE ALL LIKE c_* TO Color.MEM
  75. @ 4,0 SAY "COLOR.MEM saved"
  76. RELEASE ALL
  77. *
  78. c_norm = "W/N,N/W,N"
  79. c_hilite = "N/W,W/N,W"
  80. c_box = "W+/N,N/W,N"
  81. c_head = "W+/N,N/W,N"
  82. c_warn = "W*/N,N/W,N"
  83. c_alert = "W*/N,N/W,N"
  84. c_1 = "W/N,W/N,N"
  85. c_2 = "W+/N,W/N,N"
  86. c_3 = "N/N,N/N,N"
  87. SAVE ALL LIKE c_* TO Mono.MEM
  88. @ 5,0 SAY "MONO.MEM saved"
  89. RELEASE ALL
  90. *
  91. * Create Typical System Variables MEM file
  92. *
  93. snam1 = "Harry F. Gilbert Associates Computer Programming Database"
  94. snam2 = "H. F. G. A."
  95. STORE " " TO expression,string,help_code,mode,m_fil,m_ndx,m_fld,m_prompt
  96. STORE " " TO seg,seg_name,output,drive,mcon
  97. STORE 1 TO mcopies
  98. STORE chr(204)+REPLICATE(chr(205),78)+chr(185) TO dline
  99. SAVE TO System.MEM 
  100. @ 6,0 SAY "SYSTEM.MEM saved"
  101. RELEASE ALL
  102. *
  103. * Create a series of "source printer code definition files"
  104. *
  105. pxname  = "EPSON FX or LQ Series Dot Matrix Printer"   && name
  106. pxport  = "LPT1:"                                      && port
  107. pxreset = CHR(27)+"@"                                  && reset printer code
  108. pxcond  = CHR(27)+CHR(15)                              && condensed mode
  109. pxelite = CHR(27)+"M"                                  && elite mode
  110. pxpica  = CHR(27)+"P"                                  && pica mode
  111. pxbldon = ""                                           && bold on
  112. pxbldof = ""                                           && bold off
  113. pxulon  = ""                                           && underline on
  114. pxulof  = ""                                           && underline off
  115. SAVE ALL LIKE px* TO Epson.PRT
  116. @ 7,0 SAY "EPSON.PRT saved"
  117. RELEASE ALL
  118. *
  119. pxname  = "Hewlett-Packard Laser Jet"
  120. pxport  = "COM2:9600,N,8,1,P"
  121. pxreset = chr(27)+"E"
  122. pcxond  = chr(27)+"(s16.6H"
  123. pxelite = chr(27)+"&k10H"
  124. pxpica  = chr(27)+"&k12H"
  125. pxbldon = ""
  126. pxbldof = ""
  127. pxulon  = ""
  128. pxulof  = ""
  129. SAVE ALL LIKE px* TO Laser1.PRT
  130. @ 8,0 SAY "LASER1.PRT saved"
  131. RELEASE ALL
  132. *
  133. pxname  = "Diablo 630 Type Daisy Wheel Printer"
  134. pxport  = "LPT1:"
  135. pxreset = chr(27)+chr(13)+"P"
  136. pxcond  = chr(27)+chr(31)+chr(16)
  137. pxelite = chr(27)+chr(31)+chr(11)
  138. pxpica  = chr(27)+chr(31)+chr(13)
  139. pxbldon = ""
  140. pxbldof = ""
  141. pxulon  = ""
  142. pxulof  = ""
  143. SAVE ALL LIKE px* TO Diablo.PRT
  144. @ 9,0 SAY "DIABLO.PRT saved"
  145. RELEASE ALL
  146. *
  147. pxname  = "Okidata Dot Matrix Printer"
  148. pxport  = "LPT1:"
  149. pxreset = chr(27)+chr(48)
  150. pxcond  = chr(29)
  151. pxelite = chr(28)
  152. pxpica  = chr(30)
  153. pxbldon = ""
  154. pxbldof = ""
  155. pxulon  = ""
  156. pxulof  = ""
  157. SAVE ALL LIKE px* TO Okidata.PRT
  158. @ 10,0 SAY "OKIDATA.PRT saved"
  159. RELEASE ALL
  160. *
  161. pxname  = "NEC 8023 Series Dot Matrix Printer"
  162. pxport  = "LPT1:"
  163. pxreset = chr(27)+"N"
  164. pxcond  = chr(27)+"Q"
  165. pxelite = chr(27)+"E"
  166. pxpica  = pxreset
  167. pxbldon = ""
  168. pxbldof = ""
  169. pxulon  = ""
  170. pxulof  = ""
  171. SAVE ALL LIKE px* TO NecDmp.PRT
  172. @ 11,0 SAY "NECDMP.PRT saved"
  173. RELEASE ALL
  174. *
  175. pxname  = "IBM Proprinter Series Printer"
  176. pxport  = "LPT1:"
  177. pxreset = ""
  178. pxcond  = chr(27)+chr(15)
  179. pxelite = chr(27)+chr(58)
  180. pxpica  = ""
  181. pxbldon = ""
  182. pxbldof = ""
  183. pxulon  = ""
  184. pxulof  = ""
  185. SAVE ALL LIKE px* TO Proprint.PRT
  186. @ 12,0 SAY "PROPRINT.PRT saved" 
  187. RELEASE ALL
  188. *
  189. c1 = "GR+/B,N/W,B"
  190. c2 = "N/W,W/N,B"
  191. SET COLOR TO &c1
  192. @ 21,0 SAY "-"
  193. WAIT
  194. CLEAR
  195. @ 1, 0 SAY "Part 2 - List Mem Files"
  196. @ 2, 0 SAY REPLICATE("=",80)
  197. @ 21,0 SAY REPLICATE("-",80)
  198. *
  199. * Create array of Print Files
  200. *
  201. a1 = "array1"
  202. mask = "*.PRT"                   && You could insert a routine to get
  203. DECLARE &a1[ADIR("&mask")]       && mask from user
  204. n = ADIR("&mask",&a1)
  205. *
  206. * Draw Box and Array
  207. *
  208. namelen = 12    &&  length of the filespec = xxxxxxxx.xxx
  209. row = 4         &&  top row of box
  210. col = 5         &&  left column of box
  211. @ row,col TO n+col,col+namelen+1 DOUBLE
  212. FOR i=1 TO n
  213.   DO WHILE LEN(&a1[i]) < namelen     && make string 12 characters long
  214.     &a1[i] = &a1[i] + " "       && so scroll bar fills window
  215.   ENDDO
  216.   @ i+row,col+1 SAY &a1[i]
  217. NEXT
  218. *
  219. * Initialize variables
  220. *
  221. target = SPACE(12)  && selected file
  222. x = 0               && keypress
  223. i = 1               && position in array
  224. *
  225. * Highlight first file
  226. *
  227. SET COLOR TO &c2
  228. @ i+row,col+1 SAY &a1[i] 
  229. *
  230. * Scroll Bar Routine
  231. *
  232. DO WHILE .T.
  233.   x = INKEY()
  234.   DO CASE
  235.     CASE x = 27                          && Pressed ESCAPE (No Selection)
  236.       SET COLOR TO &c1
  237.       EXIT
  238.     CASE x = 13                          && Pressed RETURN to make a selection
  239.       target = &a1[i]
  240.       SET COLOR TO &c1 
  241.       EXIT
  242.     CASE x = 5                                     && Up arrow
  243.       DO Paintbar WITH c1,i,row,col,&a1[i]
  244.       i = IIF(i=1,n,i-1)
  245.       DO Paintbar WITH c2,i,row,col,&a1[i]
  246.     CASE x = 24                                    && Down Arrow
  247.       DO Paintbar WITH c1,i,row,col,&a1[i]
  248.       i = IIF(i=n,1,i+1)
  249.       DO Paintbar WITH c2,i,row,col,&a1[i]
  250.     CASE x = 1 .OR. x = 18                         && Home or PageUp
  251.       DO Paintbar WITH c1,i,row,col,&a1[i]
  252.       i = 1                                        && Go to top of list 
  253.       DO Paintbar WITH c2,i,row,col,&a1[i]
  254.     CASE x = 6 .OR. x = 3                          && End or PageDn
  255.       DO Paintbar WITH c1,i,row,col,&a1[i]
  256.       i = n                                        && Go to end of list
  257.       DO Paintbar WITH c2,i,row,col,&a1[i]
  258.   ENDCASE
  259. ENDDO
  260. target = TRIM(target)
  261. IF EMPTY(target)
  262.   @ 22,0 SAY "No file was selected"
  263. ELSE
  264.   @ 22,0 SAY "You have selected "+TRIM(target)+" as the current printer."
  265.   RUN COPY &target PRINTER.MEM > NUL
  266. ENDIF
  267. RETURN
  268. * EOF: MAKEMEMS.PRG
  269.  
  270.  
  271.  
  272. PROCEDURE Paintbar
  273. PARAMETERS color,j,r,c,line
  274. SET COLOR TO &color
  275. @ j+r,c+1 SAY line
  276. RETURN
  277. * EOP: Paintbar
  278.  
  279.  
  280. STORE " " TO expression,string,help_code,mode,m_fil,m_ndx,m_fld,m_prompt
  281. STORE "