home *** CD-ROM | disk | FTP | other *** search
/ CP/M / CPM_CDROM.iso / mbug / mbug104.arc / MENU.LBR / MAINT.CMD < prev    next >
OS/2 REXX Batch file  |  1979-12-31  |  12KB  |  649 lines

  1. *
  2. *  maint.cmd
  3. *
  4. *  Glenn Story - 6/12/83
  5. *
  6. *  This command file contains the routines to be used for menu-driven
  7. *  dBASE II file maintenance
  8. *  This command file is used in conjunction with MENU.CMD
  9. *
  10. do case
  11. *
  12. CASE MAINT:CMD = 'MADF'
  13. *
  14. do muse
  15. copy to temp structure
  16. use temp
  17. ?
  18. ? 'WARNING:  Do not change any field names'
  19. ?
  20. modify structure
  21. append from &cur:file
  22. erase
  23. ? 'At this point we are about to copy remove the old data base and'
  24. ? 'replace it with the new one'
  25. ? ' '
  26. ? 'Press ESC to abort and save the old data base'
  27. ? 'or press any other key to continue'
  28. wait
  29. delete file &cur:file
  30. rename temp to &cur:file
  31. *
  32. CASE MAINT:CMD = "MADD"
  33. *
  34. do muse
  35. append
  36. *
  37. CASE MAINT:CMD = "MBROWSE"
  38. *
  39. do muse
  40. browse
  41. *
  42. CASE MAINT:CMD = 'MCOM'
  43. *
  44. erase
  45. modify command
  46. *
  47. CASE MAINT:CMD = 'MCREATE'
  48. *
  49. set intensity on
  50. accept "Enter data base name: " to cur:file
  51. create &cur:file
  52. set intensity off
  53. use &cur:file
  54. do mindex
  55. *
  56. CASE MAINT:CMD = 'MDELETE'
  57. *
  58. erase
  59. store '?          ' to file:name
  60. do while file:name = '?'
  61.   @ 2,10 say 'Enter name of file to be deleted:  ' get file:name
  62.   read
  63.   if file:name = "?"
  64.     list files like *.*
  65.   endif
  66. enddo   
  67. delete file &file:name
  68. *
  69. CASE MAINT:CMD = 'MLIST1'
  70. *
  71. erase
  72. list files
  73. wait
  74. *
  75. CASE MAINT:CMD = 'MLIST2'
  76. *
  77. do muse
  78. erase
  79. list structure
  80. wait
  81. *
  82. CASE MAINT:CMD = 'MLIST3'
  83. *
  84. store '*.*        ' to file:mask
  85. erase
  86. @ 2,10 say "Enter file mask: " get file:mask
  87. read
  88. erase
  89. list files like &file:mask
  90. wait
  91. *
  92. CASE MAINT:CMD = 'MLIST4'
  93. *
  94. erase
  95. list memory
  96. wait
  97. *
  98. CASE MAINT:CMD = 'MRENAME'
  99. *
  100. DO muse
  101. copy to temp sdf
  102. ?   
  103. ? 'WARNING:  Do not change any field sizes'
  104. ?
  105. modify structure
  106. append from temp.txt sdf
  107. *
  108. CASE MAINT:CMD = 'MRENF'
  109. *
  110. erase
  111. store '?           ' to old:name
  112. do while old:name = '?'
  113.   @ 2,10 say "Enter old name:  " get old:name
  114.   read
  115.   if old:name = '?'
  116.     list files like *.*
  117.   endif
  118. enddo
  119. store '?           ' to new:name
  120. do while new:name = '?'
  121.   @ 4,10 say "Enter new name:  " get new:name
  122.   read
  123.   if new:name = '?'
  124.     list files like *.*
  125.   endif
  126. enddo
  127. rename &old:name to &new:name
  128. *
  129. CASE MAINT:CMD = 'MREPORT'
  130. *
  131. DO muse
  132. erase
  133. store ' ' to old:new
  134. do while (old:new # 'Y') .and. (old:new # 'N')
  135.   @ 2,10 say 'Do you want to use an existing form? ' get old:new
  136.   read
  137.   store !(old:new) to old:new
  138. enddo
  139. if old:new = 'Y'
  140.   store '?       ' to form:name
  141.   do while form:name = '?'
  142.     erase
  143.     @ 2,10 say "Enter form name" get form:name
  144.     read
  145.     if form:name = '?'
  146.       erase
  147.       list files like *.frm
  148.       loop
  149.     endif
  150.     store trim (form:name)+'.FRM' to file:name
  151.     if .not. file (file:name)
  152.       @ 4,10 say 'Form file does not exist'
  153.       wait
  154.       store '?       ' to form:name
  155.       loop
  156.     endif
  157.   enddo
  158. else
  159.   store ' ' to temp:sw
  160.   do while (temp:sw # 'Y') .and. (temp:sw # 'N')
  161.     @ 4,10 say 'Do you want to keep the new form? ' get temp:sw
  162.     read
  163.     store !(temp:sw) to temp:sw
  164.   enddo
  165.   if temp:sw = 'Y'
  166.     store '        ' to form:name
  167.     do while form:name = ' '
  168.       @ 6,10 say 'Enter new form name: ' get form:name
  169.       read
  170.       if file (form:name)
  171.         @ 8,10 say 'file already exists - pick another name'
  172.         store '        ' to form:name
  173.       endif
  174.     enddo
  175.   else
  176.     store 'TEMP' to form:name
  177.     if file ('TEMP.FRM')
  178.       delete file temp.frm
  179.     endif
  180.   endif
  181. endif
  182. store ' ' to print:sw
  183. do while (print:sw # 'Y') .and. (print:sw # 'N')
  184.   accept "Do you want the output to go the printer? " to print:sw
  185.   store !(print:sw) to print:sw
  186. enddo
  187. if print:sw = 'Y'
  188.   store 'TO PRINT' to print:sw
  189. else
  190.   store ' ' to print:sw
  191. endif
  192. accept "Enter scope of report" to scope
  193. accept "Enter report heading" to heading
  194. set heading to &heading
  195. report form &form:name &scope &print:sw
  196. wait
  197. *
  198. CASE MAINT:CMD = 'MINDEX'
  199. *
  200. do muse
  201. do mindex
  202. *
  203. CASE MAINT:CMD = 'MUPDATE'
  204. *
  205. *   (This  one  must be last since it has its own  CASEs  - dBASE 
  206. *    can't handle nexted cases)
  207. do muse
  208. do while 1=1
  209.   erase
  210.   @ 2,10 say "Enter search key below"
  211.   @ 4,10 say "Or '?' for cursor-control info"
  212.   @ 6,10 say "Or blank to exit"
  213.   store '                                                          ' to cur:key
  214.   @ 8,10 get cur:key
  215.   read
  216.   do case
  217.     case cur:key = ' '
  218.       store ' ' to pack:sw
  219.       do while (pack:sw # 'Y') .and. (pack:sw # 'N')     
  220.         accept "Do you want to remove deleted records?" to pack:sw
  221.         store !(pack:sw) to pack:sw
  222.       enddo
  223.       if pack:sw = 'Y'
  224.         pack
  225.       endif
  226.       do mindex
  227.       return
  228.     case cur:key = '?'
  229.      store ' ' to choice
  230.      do help3
  231.     otherwise
  232.       store trim(cur:key) to cur:key
  233.       find &cur:key
  234.       if #=0
  235.         @ 10,10 say "Record not found"
  236.         wait
  237.       else
  238.         edit *
  239.       endif
  240.   endcase
  241. enddo
  242. *
  243. OTHERWISE
  244. *
  245. erase
  246. ? 'Illegal maint function '+maint:cmd
  247. wait
  248. *
  249. ENDCASE
  250. list structure
  251. wait
  252. *
  253. CASE MAINT:CMD = 'MLIST3'
  254. *
  255. store '*.*        ' to file:mask
  256. erase
  257. @ 2,10 say "Enter file mask: " get file:mask
  258. read
  259. erase
  260. list files like &file:mask
  261. wait
  262. *
  263. CASE MAINT:CMD = 'MLIST4'
  264. *
  265. erase
  266. list memory
  267. wait
  268. *
  269. CASE      wait
  270.       else
  271.         edit *
  272.       endif
  273.   endcase
  274. enddo
  275. *
  276. OTHERWISE
  277. *
  278. erase
  279. ? 'Illegal maint function '+maint:cmd
  280. wait
  281. *
  282. ENDCASE
  283. list structure
  284. wait
  285. *
  286. CASE MAINT:CMD = 'MLIST3'
  287. *
  288. store '*.*        ' to file:mask
  289. erase
  290. @ 2,10 say "Enter file mask: " get file:mask
  291. read
  292. erase
  293. list files like &file:mask
  294. wait
  295. *
  296. CASE MAINT:CMD = 'MLIST4'
  297. *
  298. erase
  299. list memory
  300. wait
  301. *
  302. CASE mory
  303. wait
  304. *
  305. CASE 
  306.         edit *
  307.       endif
  308.   endcase
  309. enddo
  310. *
  311. OTHERWISE
  312. *
  313. erase
  314. ? 'Illegal maint function '+maint:cmd
  315. wait
  316. *
  317. ENDCASE
  318. list structure
  319. wait
  320. *
  321. CASE MAINT:CMD = 'MLIST3'
  322. *
  323. store '*.*        ' to file:mask
  324. erase
  325. @ 2,10 say "Enter file mask: " get file:mask
  326. read
  327. erase
  328. list files like &file:mask
  329. wait
  330. *
  331. CASE MAINT:CMD = 'MLIST4'
  332. *
  333. erase
  334. list memory
  335. wait
  336. *
  337. CASE mory
  338. wait
  339. *
  340. CASE s like *.*
  341.   endif
  342. enddo
  343. rename &old:name to &new:name
  344. *
  345. CASE MAINT:CMD = 'MREPORT'
  346. *
  347. DO muse
  348. erase
  349. store ' ' to old:new
  350. do while (old:new # 'Y') .and. (old:new # 'N')
  351.   @ 2,10 say 'Do you want to use an existing form? ' get old:new
  352.   read
  353.   store !(old:new) to old:new
  354. enddo
  355. if old:new = 'Y'
  356.   form:name = ' '
  357.   do while form:name = ' '  
  358.     eile:mask
  359. read
  360. erase
  361. list files like &file:mask
  362. wait
  363. *
  364. CASE MAINT:CMD = 'MLIST4'
  365. *
  366. erase
  367. list memory
  368. wait
  369. *
  370. CASE mory
  371. wait
  372. *
  373. CASE s like *.*
  374.   endif
  375. enddo
  376. rename &old:name to &new:name
  377. *
  378. CASE MAINT:CMD = 'MREPORT'
  379. *
  380. DO muse
  381. erase
  382. store ' ' to old:new
  383. do while (old:new # 'Y') .and. (old:new # 'N')
  384.   @ 2,10 say 'Do you want to use an existing form? ' get old:new
  385.   read
  386.   store !(old:new) to old:new
  387. enddo
  388. if old:new = 'Y'
  389.   form:name = ' '
  390.   do while form:name = ' '  
  391.     e
  392.       if file (form:name)
  393.         @ 8,10 say 'file already exists - pick another name'
  394. se
  395. list memory
  396. wait
  397. *
  398. CASE mory
  399. wait
  400. *
  401. CASE s like *.*
  402.   endif
  403. enddo
  404. rename &old:name to &new:name
  405. *
  406. CASE MAINT:CMD = 'MREPORT'
  407. *
  408. DO muse
  409. erase
  410. store ' ' to old:new
  411. do while (old:new # 'Y') .and. (old:new # 'N')
  412.   @ 2,10 say 'Do you want to use an existing form? ' get old:new
  413.   read
  414.   store !(old:new) to old:new
  415. enddo
  416. if old:new = 'Y'
  417.   form:name = ' '
  418.   do while form:name = ' '  
  419.     e
  420.       if file (form:name)
  421.         @ 8,10 say 'file already exists - pick another name'
  422. heading" to heading
  423. set heading to &heading
  424. report form &form:name &scope &print:sw
  425. *
  426. CASE MAINT:CMD = 'MINDEX'
  427. *
  428. do muse
  429. do mindex
  430. *
  431. CASE MAINT:CMD = 'MUPDATE'
  432. *
  433. *   (This  one  must be last since it has its own  CASEs  - dBASE 
  434. *    can't handle nexted cases)
  435. do muse
  436. do while 1=1
  437.   erase
  438.   @ 2,10 say "Enter search key below"
  439.   @ 4,10 say "Or '?' for cursor-control info"
  440.   @ 6,10 say "Or blank to exit"
  441.   store '                                                          ' to cer name'
  442. heading" to heading
  443. set heading to &heading
  444. report form &form:name &scope &print:sw
  445. *
  446. CASE MAINT:CMD = 'MINDEX'
  447. *
  448. do muse
  449. do mindex
  450. *
  451. CASE MAINT:CMD = 'MUPDATE'
  452. *
  453. *   (This  one  must be last since it has its own  CASEs  - dBASE 
  454. *    can't handle nexted cases)
  455. do muse
  456. do while 1=1
  457.   erase
  458.   @ 2,10 say "Enter search key below"
  459.   @ 4,10 say "Or '?' for cursor-control info"
  460.   @ 6,10 say "Or blank to exit"
  461.   store '                                                          ' to c       @ 10,10 say "Record not found"
  462.         wait
  463.       else
  464.         edit *
  465.       endif
  466.   endcase
  467. enddo
  468. *
  469. OTHERWISE
  470. *
  471. erase
  472. ? 'Illegal maint function '+maint:cmd
  473. wait
  474. *
  475. ENDCASE
  476. list structure
  477. wait
  478. *
  479. CASE MAINT:CMD = 'MLIST3'
  480. *
  481. store '*.*        ' to file:mask
  482. erase
  483. @ 2,10 say "Enter file mask: " get file:mask
  484. read
  485. erase
  486. list files like &file:mask
  487. wait
  488. *
  489. CASE MAINT:CMD' to c       @ 10,10 say "Record not found"
  490.         wait
  491.       else
  492.         edit *
  493.       endif
  494.   endcase
  495. enddo
  496. *
  497. OTHERWISE
  498. *
  499. erase
  500. ? 'Illegal maint function '+maint:cmd
  501. wait
  502. *
  503. ENDCASE
  504. list structure
  505. wait
  506. *
  507. CASE MAINT:CMD = 'MLIST3'
  508. *
  509. store '*.*        ' to file:mask
  510. erase
  511. @ 2,10 say "Enter file mask: " get file:mask
  512. read
  513. erase
  514. list files like &file:mask
  515. wait
  516. *
  517. CASE MAINT:CMD 'MLIST4     @ 10,10 say "Record not found"
  518.         wait
  519.       else
  520.         edit *
  521.       endif
  522.   endcase
  523. enddo
  524. *
  525. OTHERWISE
  526. *
  527. erase
  528. ? 'Illegal maint function '+maint:cmd
  529. wait
  530. *
  531. ENDCASE
  532. list structure
  533. wait
  534. *
  535. CASE MAINT:CMD = 'MLIST3'
  536. *
  537. store '*.*        ' to file:mask
  538. erase
  539. @ 2,10 say "Enter file mask: " get file:mask
  540. read
  541. erase
  542. list files like &file:mask
  543. wait
  544. *
  545. CASE MAINT:CMD 'MLIST4
  546. *
  547. erase
  548. list memory
  549. wait
  550. *
  551. CASE mory
  552. wait
  553. *
  554. CASE s like *.*
  555.   endif
  556. enddo
  557. rename &old:name to &new:name
  558. *
  559. CASE MAINT:CMD = 'MREPORT'
  560. *
  561. DO muse
  562. erase
  563. store ' ' to old:new
  564. do while (old:new # 'Y') .and. (old:new # 'N')
  565.   @ 2,10 say 'Do you want to use an existing form? ' get old:new
  566.   read
  567. *
  568. CASE MAINT:CMD = 'MLIST3'
  569. *
  570. store '*.*        ' to file:mask
  571. erase
  572. @ 2,10 say "Enter file mask: " get file:mask
  573. read
  574. erase
  575. list files like &file:mask
  576. wait
  577. *
  578. CASE MAINT:CMD 'MLIST4
  579. *
  580. erase
  581. list memory
  582. wait
  583. *
  584. CASE mory
  585. wait
  586. *
  587. CASE s like *.*
  588.   endif
  589. enddo
  590. rename &old:name to &new:name
  591. *
  592. CASE MAINT:CMD = 'MREPORT'
  593. *
  594. DO muse
  595. erase
  596. store ' ' to old:new
  597. do while (old:new # 'Y') .and. (old:new # 'N')
  598.   @ 2,10 say 'Do you want to use an existing form? ' get old:new
  599.   read  store !(old:new) to old:new
  600. enddo
  601. if old:new = 'Y'
  602.   form:name = ' '
  603.   do while form:name = ' '  
  604.     e
  605.       if file (form:name)
  606.         @ 8,10 say 'file already exists - pick another name'
  607. se
  608. list memory
  609. wait
  610. *
  611. CASE mory
  612. wait
  613. *
  614. CASE s like *.*
  615.   endif
  616. enddo
  617. rename &old:name to &new:name
  618. *
  619. CASE MAINT:CMD = 'MREPORT'
  620. *
  621. DO muse
  622. erase
  623. store ' ' to old:new
  624. do while (old:new # 'Y') .and. (old:new # 'N')
  625.   @ 2,10 say 'Do you want to use an existing form? ' get old:new
  626.   read store !(old:new) to old:new
  627. enddo
  628. if old:new = 'Y'
  629.   form:name = ' '
  630.   do while form:name = ' '  
  631.     e
  632.       if file (form:name)
  633.         @ 8,10 say 'file already exists - pick another name'
  634. heading" to heading
  635. set heading to &heading
  636. report form &form:name &scope &print:sw
  637. *
  638. CASE MAINT:CMD = 'MINDEX'
  639. *
  640. do muse
  641. do mindex
  642. *
  643. CASE MAINT:CMD = 'MUPDATE'
  644. *
  645. *   (This  one  must be last since it has its own  CASEs  - dBASE 
  646. *    can't handle nexted cases)
  647. do muse
  648. do while 1=1
  649.