home *** CD-ROM | disk | FTP | other *** search
/ Media Share 9 / MEDIASHARE_09.ISO / utility / shell452.zip / SHELL45.BAS < prev    next >
BASIC Source File  |  1992-06-24  |  9KB  |  254 lines

  1. ' Program to convert most of DOS 4 DOSSHELL Menu structures to DOS 5
  2. '               Version 1.2   multiple commands handling improved 
  3. '                             some minor mods in documentation
  4. ' The program runs in QBasic which comes free with DOS 5, or in Microsoft
  5. '   QuickBasic  (it has only been tested for 4.5)
  6. ' The program can be run any time after DOS 5 installation - it will be most
  7. '   useful if run _before_ you start manually menuing.
  8. ' DOS 5 menus are coded by text statements in the file DOSSHELL.INI.
  9. ' DOS 4  used a system of binary files with the extent .MEU
  10. '
  11. ' This program takes the binary SHELL.MEU file of DOS 4, analyses the menu
  12. '   and submenu structure and forms statements suitable for DOS 5
  13. '   It then takes the DOS 5 DOSSHELL.INI file plus the new information to
  14. '   create DOSSHELL.NEW. This can be edited for those items whose commands
  15. '   could not be determined, or changes can be made using the DOSSHELL 5
  16. '   _properties_ dialogue boxes.
  17. ' Rename the .INI to .OLD and the .NEW to .INI and restart DOSSHELL
  18. ' NB All these files should be in the C:\DOS directory.
  19. '
  20. ' Limitations:-
  21. '   1. No attempt has been made to convert shell dialogue information.
  22. '   2. Passwords are not converted, they are removed where present.
  23. '
  24. ' This program may be used freely and without charge. If you use it then it
  25. '   would be appreciated it you could notify me by email PB.VCP.MONASH.EDU.AU
  26. '   Suggestions for improvements welcome.
  27. '   Peter Bury, Victorian College of Pharmacy (Monash University)
  28. ' Usual disclaimers apply!
  29. ' If you have never run QBasic, brief instructions are appended at the end
  30. '
  31. DECLARE FUNCTION byte% (address%, slect%)
  32. DECLARE SUB pgram (slect%)
  33. DECLARE FUNCTION xtract$ (start%, last%, slect%)
  34. DEFINT A-Z
  35. COMMON SHARED GroupItem AS STRING * 1036, MenuItem AS STRING * 1036, ascii
  36. DIM main(50), submen(50)
  37. COLOR 7, 0
  38. defpath$ = "c:\dos\"
  39. PRINT "            DOSSHELL CONVERSION PROGRAM"
  40. PRINT "Copying start of DOSSHELL.INI to DOSSHELL.NEW"
  41. OPEN defpath$ + "shell.meu" FOR BINARY ACCESS READ AS #1 LEN = 1
  42. OPEN defpath$ + "dosshell.ini" FOR INPUT AS #3
  43. OPEN defpath$ + "dosshell.new" FOR OUTPUT AS #4
  44. LINE INPUT #3, a$
  45. WHILE a$ <> "}"                  ' Copy to end of existing groups/programs
  46.   PRINT #4, a$
  47.   LINE INPUT #3, a$
  48. WEND
  49. PRINT
  50. PRINT "MAIN group"
  51. GET #1, 1, GroupItem
  52. NList = byte(&H318, 1)           ' This is length of list
  53. NMain = byte(&H31A, 1)           ' This is how many items in main menu
  54. FOR j = 1 TO NList
  55.   main(byte(&H318 - 4 + 8 * j, 1)) = j      'and their order
  56. NEXT j
  57. FOR g1 = 1 TO NMain
  58.   k = &H139 + &H40C * (main(g1) - 1)
  59.   GET #1, k, GroupItem
  60.   nm$ = xtract$(&H265, &H28E, 1)      'Title of item if program
  61.   IF nm$ = "Command Prompt" OR nm$ = "Change Colors" THEN GOTO nxtgp
  62.   IF nm$ = "File System" THEN GOTO nxtgp
  63.   comgp$ = xtract$(&H298, &H40C, 1)      'Title of item if group
  64.   IF INSTR(comgp$, ".MEU") > 0 THEN      'Test for group
  65.     group$ = LEFT$(comgp$, INSTR(comgp$, ".MEU") + 3)
  66.     IF group$ = "DOSUTIL.MEU" THEN GOTO nxtgp
  67.     PRINT "Group "; group$
  68.     PRINT #4, "   group ="
  69.     PRINT #4, "   {"
  70.     PRINT #4, "       title = "; nm$
  71.     pw$ = xtract$(&H28E, &H29C, 1)
  72.     IF pw$ <> "" THEN PRINT "Password removed from "; nm$: BEEP: SLEEP 2
  73.     OPEN defpath$ + group$ FOR BINARY ACCESS READ AS #2 LEN = 1
  74.     GET #2, 1, MenuItem      'Repeat above process for items in group
  75.     nl2 = byte(&H318, 2)
  76.     ng2 = byte(&H31A, 2)
  77.     FOR j = 1 TO nl2
  78.       j1 = byte(&H318 - 4 + 8 * j, 2)
  79.       submen(j1) = j
  80.     NEXT j
  81.     FOR g2 = 1 TO ng2
  82.       l = &H139 + &H40C * (submen(g2) - 1)
  83.       GET #2, l, MenuItem
  84.       CALL pgram(2)            ' This does the work for progs in group
  85.       SLEEP 1
  86.     NEXT g2
  87.     PRINT #4, "   }"
  88.     CLOSE #2
  89.   ELSE
  90.     CALL pgram(1)              ' This does the work for progs in main
  91.   END IF
  92. nxtgp:
  93. NEXT g1
  94. PRINT #4, "}"
  95. PRINT "Copying tail of DOSSHELL.INI to DOSSHELL.NEW"
  96. WHILE NOT EOF(3)               ' Copy to end of file
  97.   LINE INPUT #3, a$
  98.   PRINT #4, a$
  99. WEND
  100. CLOSE
  101.  
  102. FUNCTION byte (address, slect)
  103.   dummy$ = xtract$(address, address + 1, slect)
  104.   byte = ascii            ' extract a single byte as an integer
  105. END FUNCTION
  106.  
  107. SUB pgram (slect)
  108. ' This routine extracts the command, help, password and title fields.
  109. ' It attempts to parse the command field to find the startup directory and
  110. '   and command, and warns if later editing might be needed.
  111. '   Hex BA corresponds to the F4 separator
  112.   warn = 0
  113.   PRINT
  114.   hlp1$ = xtract$(&H139, &H265, slect)
  115.   nm1$ = xtract$(&H265, &H28E, slect)
  116.   pw1$ = xtract$(&H28E, &H29C, slect)
  117.   comlines$ = xtract$(&H29C, &H40C, slect)
  118.   path$ = ""
  119.   p0 = 1
  120.   NewCom$ = ""
  121. comloop:
  122.   p1 = INSTR(p0, comlines$, CHR$(&HBA))
  123.   IF p1 = 0 THEN p2 = LEN(comlines$) - p0 + 1 ELSE p2 = p1 - p0
  124.   c$ = MID$(comlines$, p0, p2)
  125.   IF MID$(c$, 2, 1) = ":" AND path$ = "" THEN
  126.     path$ = LTRIM$(RTRIM$(c$))
  127.     specfound = 0
  128.   ELSE
  129.     IF LEFT$(UCASE$(c$), 2) = "CD" THEN
  130.       IF LEN(path$) < 5 THEN      ' This is looking for change drive then
  131.         IF INSTR(c$, ":") > 0 THEN      ' change directory
  132.           path$ = MID$(c$, 3)
  133.         ELSE
  134.           path$ = path$ + MID$(c$, 3)
  135.         END IF
  136.         specfound = 1
  137.       ELSE
  138.         PRINT "Path not clear"
  139.         warn = 1              ' Cant determine path. User should use shell
  140.         path$ = MID$(c$, 3)   ' PROPERTIES option to check/edit the item
  141.       END IF
  142.     ELSE
  143.       IF LEFT$(UCASE$(c$), 5) = "CHDIR" THEN
  144.         IF LEN(path$) < 5 THEN      ' Same as above, other form of CD
  145.           IF INSTR(c$, ":") > 0 THEN
  146.             path$ = MID$(c$, 6)
  147.           ELSE
  148.             path$ = path$ + MID$(c$, 6)
  149.           END IF
  150.           specfound = 1
  151.         ELSE
  152.           PRINT "Path not clear"
  153.           warn = 1              ' Cant determine path. User should use shell
  154.           path$ = MID$(c$, 6)   ' PROPERTIES option to check/edit the item
  155.         END IF
  156.       ELSE
  157.         IF NewCom$ = "" THEN
  158.           NewCom$ = c$   ' Assume this is a valid command
  159.         ELSE
  160.           NewCom$ = NewCom$ + "  ; " + c$
  161.         END IF
  162.       END IF
  163.     END IF
  164.   END IF
  165.   IF p1 > 0 THEN
  166.     p0 = p1 + 1
  167.     GOTO comloop
  168.   END IF
  169. ' parsing finished, review what we've got
  170.   sp = INSTR(path$, " ")
  171.   WHILE sp > 0            ' Remove spaces from path
  172.     path$ = LEFT$(path$, sp - 1) + MID$(path$, sp + 1)
  173.     sp = INSTR(path$, " ")
  174.   WEND
  175.  
  176.   IF NewCom$ = "" THEN
  177.     sl = INSTR(path$, "\")
  178.     IF sl = 0 THEN
  179.       warn = 1
  180.       PRINT "No command found"
  181.     ELSE
  182.       WHILE sl > 0      'find the last backslash
  183.         sll = sl
  184.         sl = INSTR(sll + 1, path$, "\")
  185.       WEND
  186.       NewCom$ = MID$(path$, sll + 1)
  187.       path$ = LEFT$(path$, sll - 1)
  188.     END IF
  189.   ELSE
  190.     IF path$ = "" THEN
  191.       sc = INSTR(NewCom$, ";")
  192.       IF sc = 0 THEN sc = LEN(NewCom$)
  193.       sl = INSTR(NewCom$, "\")
  194.       IF sl > 0 AND sl < sc THEN
  195.         WHILE sl > 0      'find the last backslash
  196.           sll = sl
  197.           sl = INSTR(sll + 1, NewCom$, "\")
  198.         WEND
  199.         path$ = LEFT$(NewCom$, sll - 1)
  200.         NewCom$ = MID$(NewCom$, sll + 1)
  201.       ELSE
  202.         warn = 1
  203.         PRINT "No startup directory found"
  204.       END IF
  205.     END IF
  206.   END IF
  207.   PRINT #4, TAB(4 * slect); "program ="
  208.   PRINT #4, TAB(4 * slect); "{"
  209.   PRINT #4, TAB(4 * slect); "    title = "; nm1$
  210.   PRINT TAB(4 * slect); "    title = "; nm1$
  211.   IF path$ <> "" THEN PRINT #4, TAB(4 * slect); "    directory = "; path$
  212.   IF path$ <> "" THEN PRINT TAB(4 * slect); "    directory = "; path$
  213.   PRINT #4, TAB(4 * slect); "    command = "; NewCom$
  214.   PRINT TAB(4 * slect); "    command = "; NewCom$
  215.   IF hlp1$ <> "" THEN PRINT #4, TAB(4 * slect); "    help = "; hlp1$
  216.   IF hlp1$ <> "" THEN PRINT TAB(4 * slect); "    help = "; hlp1$
  217.   IF pw1$ <> "" THEN PRINT "Password removed from "; nm1$: BEEP: SLEEP 2
  218.   PRINT #4, TAB(4 * slect); "    pause = disabled"
  219.   PRINT #4, TAB(4 * slect); "}"
  220.   IF warn = 1 THEN
  221.     PRINT "Edit "; : COLOR 4, 2: PRINT nm1$; : COLOR 7, 0
  222.     INPUT "if needed.  Press return to continue"; x
  223.   END IF
  224. EXIT SUB
  225. END SUB
  226.  
  227. FUNCTION xtract$ (start, last, slect)
  228. DIM Item AS STRING * 1036
  229. IF slect = 1 THEN Item = GroupItem ELSE Item = MenuItem
  230. x$ = ""
  231. FOR j = start + 1 TO last
  232.   ascii = ASC(MID$(Item, j, 1))
  233.   IF ascii >= &H20 AND (ascii <= &H7E OR ascii = &HBA) THEN
  234.     x$ = x$ + CHR$(ascii)
  235.   ELSE
  236.     EXIT FOR
  237.   END IF
  238. NEXT j
  239. xtract$ = LTRIM$(RTRIM$(x$))
  240. END FUNCTION
  241. '
  242. ' Using a text editor to remove any headers, create a file called eg.
  243. '   SHELL45.BAS. Lines starting with the apostrophe are comments and may be
  244. '   left intact.
  245. ' To run this program after DOS 5 installation, select QBasic from the
  246. '   shell menu. Type in the full path and name to wherever this file is
  247. '   stored. Press the _F5_ key to run the program.
  248. '   It will pause to let you note any warning messages displayed as it runs.
  249. ' Exit Basic by pressing _Alt_ then F then X, and exit DOSSHELL to DOS by
  250. '   pressing the _F3_ key.
  251. ' Rename DOSSHELL.INI  DOSSHELL.OLD       and then
  252. ' Rename DOSSHELL.NEW  DOSSHELL.INI
  253. ' Type DOSSHELL to restart with new menus.
  254.