home *** CD-ROM | disk | FTP | other *** search
/ C!T ROM 2 / ctrom_ii_b.zip / ctrom_ii_b / PROGRAM / CLIPPER / SCRNUZ / MAKEREPO.PRG < prev    next >
Text File  |  1991-12-13  |  12KB  |  393 lines

  1. *----------------------------------------------------------------------------
  2. *
  3. *   Program Name: MAKEREPO.PRG      Copyright: EDON Corporation                                         
  4. *   Date Created: 10/26/90           Language: Clipper S'87                                             
  5. *   Time Created: 17:03:18             Author: Ed Phillips                               
  6. *    Description:
  7. *----------------------------------------------------------------------------
  8.  
  9. CLEAR
  10. STORE Space(8) TO dbf1, dbf2, dbf3, dbf4, dbf5
  11. STORE Space(8) TO d1_ndx1, d1_ndx2, d1_ndx3, d1_ndx4, d1_ndx5
  12. STORE Space(8) TO d2_ndx1, d2_ndx2, d2_ndx3, d2_ndx4, d2_ndx5
  13. STORE Space(8) TO d3_ndx1, d3_ndx2, d3_ndx3, d3_ndx4, d3_ndx5
  14. STORE Space(8) TO d4_ndx1, d4_ndx2, d4_ndx3, d4_ndx4, d4_ndx5
  15. STORE Space(8) TO d5_ndx1, d5_ndx2, d5_ndx3, d5_ndx4, d5_ndx5
  16.  
  17. prg = Space(8)
  18. tit = Space(30)
  19. rpt_prompt = Space(50)
  20. key_expr = Space(50)
  21. key_len = 0
  22. key_pict = Space(20)
  23. ctrl_cond = Space(50)
  24.  
  25. exit_msg = 'To Exit, Leave Program Name Empty'
  26. prompt1 = 'Enter Data Base File Names'
  27. prompt2 = 'Enter Associated Indexes'
  28. prompt3 = 'Enter Name of Program to Create'
  29. prompt5 = 'Enter Screen Title'
  30. prompt6 = 'Enter Report Prompt'
  31. prompt7 = 'Enter Report Scope-Variable Expression'
  32. prompt8 = 'Enter Controlling DO WHILE loop condition'
  33. prompt9 = 'Enter Key Length'
  34. prompt10 = 'Enter Key Picture (no quotes)'
  35.  
  36. @ 03,Centr(prompt3,8) SAY prompt3 GET prg PICT '!XXXXXXX'
  37. @ 05,Centr(prompt5,30) SAY prompt5 GET tit
  38. @ 06,Centr(prompt6,0) SAY prompt6
  39. @ 07,15 GET rpt_prompt
  40. @ 08,Centr(prompt7,0) SAY prompt7
  41. @ 09,15 GET key_expr
  42. * @ 10,Centr(prompt9,2) SAY prompt9 GET key_len PICT '##'
  43. @ 11,Centr(prompt10,20) SAY prompt10 GET key_pict
  44. @ 12,Centr(prompt8,0) SAY prompt8
  45. @ 13,15 GET ctrl_cond
  46. @ 24,Centr(exit_msg,0) SAY exit_msg
  47. READ
  48.  
  49. IF Empty(prg)
  50.    RETURN
  51. ELSE
  52.    prefix = Trim(Subs(prg,1,4))
  53.    prg = Trim(prg)+'.prg'
  54.    tit = Trim(tit)
  55.    rpt_prompt = Trim(rpt_prompt)
  56.    key_expr = Trim(key_expr)
  57.    ctrl_cond = Trim(ctrl_cond)
  58. *   key_lstr = IIF(key_len < 10, Str(key_len,1,0), Str(key_len,2,0))
  59.    key_pict = Trim(key_pict)
  60. ENDIF
  61.  
  62. @ 6,0 CLEAR
  63. @ 06,Centr(prompt1,0) SAY prompt1
  64.  
  65. @ 07,16 GET dbf1 PICT '!XXXXXXX'
  66. @ 07,26 GET dbf2 PICT '!XXXXXXX'
  67. @ 07,36 GET dbf3 PICT '!XXXXXXX'
  68. @ 07,46 GET dbf4 PICT '!XXXXXXX'
  69. @ 07,56 GET dbf5 PICT '!XXXXXXX'
  70. READ
  71.  
  72. @ 09,Centr(prompt2,0) SAY prompt2
  73. @ 10,16 GET d1_ndx1 PICT '!XXXXXXX'
  74. @ 11,16 GET d1_ndx2 PICT '!XXXXXXX'
  75. @ 12,16 GET d1_ndx3 PICT '!XXXXXXX'
  76. @ 13,16 GET d1_ndx4 PICT '!XXXXXXX'
  77. @ 14,16 GET d1_ndx5 PICT '!XXXXXXX'
  78.  
  79. @ 10,26 GET d2_ndx1 PICT '!XXXXXXX'
  80. @ 11,26 GET d2_ndx2 PICT '!XXXXXXX'
  81. @ 12,26 GET d2_ndx3 PICT '!XXXXXXX'
  82. @ 13,26 GET d2_ndx4 PICT '!XXXXXXX'
  83. @ 14,26 GET d2_ndx5 PICT '!XXXXXXX'
  84.  
  85. @ 10,36 GET d3_ndx1 PICT '!XXXXXXX'
  86. @ 11,36 GET d3_ndx2 PICT '!XXXXXXX'
  87. @ 12,36 GET d3_ndx3 PICT '!XXXXXXX'
  88. @ 13,36 GET d3_ndx4 PICT '!XXXXXXX'
  89. @ 14,36 GET d3_ndx5 PICT '!XXXXXXX'
  90.  
  91. @ 10,46 GET d4_ndx1 PICT '!XXXXXXX'
  92. @ 11,46 GET d4_ndx2 PICT '!XXXXXXX'
  93. @ 12,46 GET d4_ndx3 PICT '!XXXXXXX'
  94. @ 13,46 GET d4_ndx4 PICT '!XXXXXXX'
  95. @ 14,46 GET d4_ndx5 PICT '!XXXXXXX'
  96.  
  97. @ 10,56 GET d5_ndx1 PICT '!XXXXXXX'
  98. @ 11,56 GET d5_ndx2 PICT '!XXXXXXX'
  99. @ 12,56 GET d5_ndx3 PICT '!XXXXXXX'
  100. @ 13,56 GET d5_ndx4 PICT '!XXXXXXX'
  101. @ 14,56 GET d5_ndx5 PICT '!XXXXXXX'
  102. READ
  103.  
  104.  
  105.    SET PRINTER TO &prg
  106.    SET DEVICE TO PRINT
  107.    Setprc(0,0)
  108.    @ Lc(),0 SAY '* Program: '+ prg
  109.    @ Lc()+1,0 SAY '* Author : Ed Phillips'
  110.    @ Lc()+1,0 SAY '* Date   : '+DTOC(DATE())
  111.    @ Lc()+1,0 SAY '* Copyright (C) '+Str(Year(Date()),4,0)+', EDON Corporation'
  112.  
  113.  
  114.    @ Lc()+3,0 SAY 'PRIV tit,phdr,rprompt,key_field'
  115.    @ Lc()+1,0 SAY 'phdr = '+ '"'+ prefix+ '_hdr'+ '"'
  116.    @ Lc()+1,0 SAY 'tit = '+ '"&tit"'
  117.    IF Empty(rpt_prompt)
  118.       @ Lc()+1,0 SAY 'rprompt = "This is a report prompt"'
  119.    ELSE
  120.       @ Lc()+1,0 SAY 'rprompt = '+'"&rpt_prompt"'
  121.    ENDIF
  122.    @ Lc()+1,0 SAY 'ex_flg = .f.'
  123.    @ Lc()+1,0 SAY ''
  124.  
  125. *------------------------------
  126. * Create Open database commands
  127. *------------------------------
  128.  
  129. IF ! Empty(dbf1)
  130.    FOR j = 1 TO 5
  131.       ndxstr = ' '
  132.       ndxlevel = 'd'+Str(j,1,0)
  133.       dbfvar = 'dbf'+Str(j,1,0)
  134.       ndxwork = ndxlevel+'_ndx1'
  135.  
  136.       IF Empty(&dbfvar)
  137.          EXIT
  138.       ENDIF
  139.  
  140.       IF ! Empty(&ndxwork)
  141.          ndxstr = ' INDEX '+Trim(&ndxwork)
  142.          FOR i = 2 TO 5
  143.             ndxvar = ndxlevel+'_ndx'+Str(i,1,0)
  144.             IF ! Empty(&ndxvar)
  145.                ndxstr = ndxstr+ ', '+Trim(&ndxvar)
  146.             ELSE
  147.                EXIT
  148.             ENDIF
  149.          NEXT   && i
  150.       ENDIF
  151.  
  152.       IF j > 1
  153.          @ Lc()+1,0 SAY 'SELECT 0'
  154.       ENDIF
  155.  
  156.       IF Empty(ndxstr)
  157.          @ Lc()+1,0 SAY 'USE '+ Trim(&dbfvar)
  158.       ELSE
  159.          @ Lc()+1,0 SAY 'USE '+ Trim(&dbfvar) + ndxstr
  160.       ENDIF
  161.    NEXT   && j
  162. ELSE
  163.    @ Lc()+1,0 SAY '*** INSERT DATABASES!! ***'
  164. ENDIF   && dbf1
  165.  
  166.  
  167. @ Lc()+2,0 SAY 'IF ! ex_flg'
  168.  
  169. IF ! Empty(dbf1)
  170.    @ Lc()+1,3 SAY 'SELECT '+ dbf1
  171. ELSE
  172.    @ Lc()+1,3 SAY 'SELECT '+'&& INSERT CONTROLLING DATABASE NAME'
  173. ENDIF
  174.  
  175. @ Lc()+1,0 SAY '   ok = .t.'
  176. @ Lc()+1,0 SAY '   Setcolor(c_norm)'
  177. @ Lc()+1,0 SAY '   CLEAR'
  178. @ Lc()+1,0 SAY '   @ 1,Centr(tit) SAY tit'
  179.  
  180. IF ! Empty(key_expr)
  181.    @ Lc()+1,3 SAY 'key_field = '+Trim(key_expr)
  182. ELSE
  183.    @ Lc()+1,3 SAY 'key_field = Space(20)'
  184. ENDIF
  185.  
  186. * handle key_field input
  187. IF ! Empty(key_pict)
  188.    @ Lc()+1,3 SAY '@ 10,Centr(rprompt,Len(key_field)) SAY rprompt GET key_field PICT "&key_pict"'
  189. ELSE
  190.    @ Lc()+1,3 SAY '@ 10,Centr(rprompt,Len(key_field)) SAY rprompt GET key_field'
  191. ENDIF
  192. @ Lc()+1,0 SAY '   READ'
  193.  
  194. @ Lc()+1,0 SAY '   IF Empty(key_field)'
  195. @ Lc()+1,0 SAY '      ok = .f.'
  196. @ Lc()+1,0 SAY '   ENDIF'
  197.  
  198. @ Lc()+2,0 SAY '   IF ok'
  199. @ Lc()+1,0 SAY "      output = 'QUIT'"
  200. @ Lc()+1,0 SAY "      f_name = Space(20)"
  201. @ Lc()+1,0 SAY '      lines = 43'
  202. @ Lc()+1,0 SAY '      page = 1'
  203.  
  204. @ Lc()+1,0 SAY '      Get_device("PFQ")'
  205. @ Lc()+1,0 SAY '      BEGIN SEQUENCE'
  206. @ Lc()+1,0 SAY "         IF (output = 'QUIT') .OR. (output = 'FILE' .AND. Empty(f_name))"
  207. @ Lc()+1,0 SAY "            BREAK"
  208. @ Lc()+1,0 SAY '         ELSE'
  209. @ Lc()+1,0 SAY "            IF output = 'PRINTER'"
  210. @ Lc()+1,0 SAY "               prt = EOSprint()"
  211. @ Lc()+1,0 SAY "               IF prt # 'Local Dot Matrix'   &&Epson FX'"
  212. @ Lc()+1,0 SAY "                  mem_defprt = 'HP Laser'"
  213. @ Lc()+1,0 SAY "                  Ljland()"
  214. @ Lc()+1,0 SAY "                  SET MARGIN TO 10"
  215. @ Lc()+1,0 SAY "               ELSE                                             && OTHERWISE..."
  216. @ Lc()+1,0 SAY "                  mem_defprt = 'Epson FX'"
  217. @ Lc()+1,0 SAY "                  Epson17()"
  218. @ Lc()+1,0 SAY "                  send_ff = .t."
  219. @ Lc()+1,0 SAY "               ENDIF"
  220. @ Lc()+1,0 SAY "               Setprc(0,0)"
  221. @ Lc()+1,0 SAY "            ENDIF                                && IF output = 'PRINTER'"
  222. @ Lc()+1,0 SAY "            Saycxl()"
  223.  
  224. @ Lc()+1,0 SAY '            Rpt_header(1,output,Lc(),.f.)'
  225.  
  226. IF ! Empty(ctrl_cond)
  227.    @ Lc()+1,0 SAY '            DO WHILE '+ ctrl_cond
  228. ELSE
  229.    @ Lc()+1,0 SAY '            DO WHILE ! Eof()'
  230. ENDIF
  231.  
  232. @ Lc()+1,0 SAY '               *-------------'
  233. @ Lc()+1,0 SAY '               * Escape route'
  234. @ Lc()+1,0 SAY '               *-------------'
  235. @ Lc()+1,0 SAY '               cxl = Inkey()'
  236. @ Lc()+1,0 SAY '               IF cxl = esc'
  237. @ Lc()+1,0 SAY '                  EXIT'
  238. @ Lc()+1,0 SAY '               ENDIF'
  239.                       
  240. @ Lc()+1,15 SAY prefix+'_det'+'()'
  241. @ Lc()+1,0 SAY '               SKIP'
  242. @ Lc()+1,0 SAY '            ENDDO'
  243. @ Lc()+1,0 SAY "            @ Lc()+2,0 SAY '** End of Report **'"
  244. @ Lc()+1,0 SAY "            IF output = 'PRINTER'"
  245. @ Lc()+1,0 SAY "               IF prt # 'Local Dot Matrix'   &&Epson FX'"
  246. @ Lc()+1,0 SAY "                  mem_defprt = 'HP Laser'"
  247. @ Lc()+1,0 SAY "                  Ljport()"
  248. @ Lc()+1,0 SAY "               ELSE                                             && OTHERWISE..."
  249. @ Lc()+1,0 SAY "                  mem_defprt = 'Epson FX'"
  250. @ Lc()+1,0 SAY "                  Epson10()"
  251. @ Lc()+1,0 SAY "               ENDIF"
  252. @ Lc()+1,0 SAY "            ENDIF                                && IF output = 'PRINTER'"
  253. @ Lc()+1,0 SAY "            SET MARGIN TO"
  254. @ Lc()+1,0 SAY '            Eorpt(send_ff)'
  255.  
  256. @ Lc()+1,0 SAY "         ENDIF                                && IF (output = 'PRINTER')"
  257. @ Lc()+1,0 SAY "      END                                     && BEGIN SEQUENCE"
  258. @ Lc()+1,0 SAY '   ENDIF                     && IF ok'
  259. @ Lc()+1,0 SAY 'ENDIF                     && ! ex_flg'
  260. @ Lc()+1,0 SAY 'CLOSE DATA'
  261. @ Lc()+1,0 SAY 'RELEASE ALL'
  262. @ Lc()+1,0 SAY 'RETURN'
  263.  
  264.  
  265. *------------------------------
  266. * Write Report header procedure
  267. *------------------------------
  268.  
  269. @ Lc()+3,0 SAY 'PROC '+prefix+'_hdr'
  270. @ Lc()+1,0 SAY 'PARA page, ln'
  271. @ Lc()+1,0 SAY 'PRIV tit1, tit2, tit3'
  272.  
  273. SET DEVICE TO SCREEN
  274.  
  275. @ 6,0 CLEAR
  276. STORE Space(130) TO tit1, tit2, tit3, tit4, tit5, tit6
  277. msg = 'Enter Report Page Header'
  278. msg1 = 'Enter Report Column Header'
  279. @ 6,Centr(msg,0) SAY msg
  280. @ 7,0 GET tit1 PICT '@S80'
  281. @ 8,0 GET tit2 PICT '@S80'
  282. @ 9,0 GET tit3 PICT '@S80'
  283. READ
  284.  
  285. col_hdr = ' '
  286. SET COLOR TO W+/GR+
  287. @ 10,Centr(msg1,0) SAY msg1
  288.  
  289. *-------------------
  290. * GET Column Headers
  291. *-------------------
  292.  
  293. col_hdr = Memoedit(col_hdr,11,0,15,80,.T.,"",130)
  294.  
  295. tit4 = Trim(Memoline(col_hdr,130,1))
  296. tit5 = Trim(Memoline(col_hdr,130,2))
  297. tit6 = Trim(Memoline(col_hdr,130,3))
  298.  
  299. max_ln = Max(80,Len(tit4))
  300. max_ln = Max(max_ln,Len(tit5))
  301. max_ln = Max(max_ln,Len(tit6))
  302.  
  303. SET DEVICE TO PRINT
  304.  
  305. IF ! Empty(tit1)
  306.    IF Upper(Subs(tit1,1,2)) = '@F'               && field flag
  307.       @ Lc()+1,3 SAY 'tit1 = '+Alltrim(tit1)
  308.    ELSE                                          && else, string
  309.       @ Lc()+1,3 SAY 'tit1 = "'+Alltrim(tit1)+'"'
  310.    ENDIF                   
  311.    IF ! Empty(tit2)
  312.       IF Upper(Subs(tit2,1,2)) = '@F'
  313.          @ Lc()+1,3 SAY 'tit2 = '+Alltrim(tit2)
  314.       ELSE
  315.          @ Lc()+1,3 SAY 'tit2 = "'+Alltrim(tit2)+'"'
  316.       ENDIF
  317.       IF ! Empty(tit3)
  318.          IF Upper(Subs(tit3,1,2)) = '@F'
  319.             tit3 = Subs(tit3,3)
  320.             @ Lc()+1,3 SAY 'tit3 = '+Alltrim(tit3)
  321.          ELSE
  322.             @ Lc()+1,3 SAY 'tit3 = "'+Alltrim(tit3)+'"'
  323.          ENDIF
  324.       ENDIF
  325.    ENDIF
  326. ENDIF
  327.  
  328. @ Lc()+2,3 SAY '@ Lc(),0 SAY page PICT "@R Page: ###"'
  329. max_str = Str(max_ln,3,0)
  330. IF ! Empty(tit1)
  331.    @ Lc()+1,3 SAY '@ Lc(),Rpt_centr(tit1,&max_str) SAY tit1'
  332. ENDIF
  333. dcol = Str(max_ln-15,3,0)
  334. @ Lc()+1,3 SAY '@ Lc(),&dcol. SAY "As Of: "+Dtoc(Date())'
  335. IF ! Empty(tit2)
  336.    @ Lc()+1,3 SAY '@ Lc(),Rpt_centr(tit2,&max_str) SAY tit2'
  337. ENDIF
  338. IF ! Empty(tit3)
  339.    @ Lc()+1,3 SAY '@ Lc(),Rpt_centr(tit3,&max_str) SAY tit3'
  340. ENDIF
  341.  
  342. *------------------------
  343. * Create Column Header(s)
  344. *------------------------
  345.  
  346. IF ! Empty(tit4)
  347.    @ Lc()+1,3 SAY '@ Lc()+2,0 SAY "&tit4"'
  348.    IF ! Empty(tit5)
  349.       @ Lc()+1,3 SAY '@ Lc()+1,0 SAY "&tit5"'
  350.       IF ! Empty(tit6)
  351.          @ Lc()+1,3 SAY '@ Lc()+1,0 SAY "&tit6"'
  352.       ENDIF
  353.    ENDIF
  354. ENDIF
  355.  
  356. IF ! Empty(tit4)
  357.    SET DECIMALS TO 0
  358.    tempstr =  '*               '
  359.    temp2 = tempstr+'          '
  360.    FOR i = 0 TO max_ln
  361.       col_num = IIF( i > 9, Mod(i, 10), i)
  362.       tempstr = tempstr + Str(col_num,1,0)
  363.    NEXT
  364.    @ Lc()+1,3 SAY tempstr
  365.    tempstr = Subs(tempstr,At('0',tempstr))
  366.    max_ln = Int(Len(tempstr)/10)
  367.    FOR i = 1 TO max_ln
  368.       col_num = IIF( i > 9, Mod(i, 10), i)
  369.       temp2 = temp2 + Str(col_num,1,0)+ Space(9)
  370.    NEXT
  371.    temp2 = Trim(temp2)
  372.    @ Lc()+1,3 SAY temp2
  373. ENDIF
  374. @ Lc()+1,0 SAY 'RETURN'
  375.  
  376.  
  377. *-----------------------------
  378. * Write Report Detail Procedure
  379. *-----------------------------
  380.  
  381. @ Lc()+2,0 SAY 'PROC '+prefix+'_det'
  382. @ Lc()+1,3 SAY 'IF ! Enuf_ln(Lc(),lines,1)'
  383. @ Lc()+1,6 SAY 'Rpt_header(1,output,1,.t.)'
  384. @ Lc()+1,3 SAY 'ENDIF'
  385. @ Lc()+1,0 SAY 'RETURN'
  386.  
  387. @ Lc()+1,0 SAY '* EOF: '+ prg
  388. SET PRINT TO
  389. SET DEVI TO SCREEN
  390. CLOSE ALL
  391. RETU
  392. * EOF: Makerepo.prg
  393.