home *** CD-ROM | disk | FTP | other *** search
/ Media Share 9 / MEDIASHARE_09.ISO / batch / mxmnu233.zip / ENV.MNU < prev    next >
Text File  |  1991-09-28  |  5KB  |  252 lines

  1. Comment
  2. =============================================================
  3.  
  4. Environment Editor * Copyright 1990 by Marc Perkel
  5.  
  6. This is a MarxMenu demo program that lets you edit your master
  7. environment area. To use type: MARXMENU ENV
  8.  
  9. =============================================================
  10. EndComment
  11.  
  12. Var
  13.   Env, Env2, Paths, Paths2, NewPath, SetString, SetA, SetB, Middle
  14.   PathLevel
  15.  
  16. Const MyEditor = 'ME.EXE'
  17.  
  18. ClearScreenOnExit Off
  19.  
  20. ReadEnvironment(Env)
  21.  
  22. UseArrows
  23. BoxBorderColor Green Blue
  24. BoxInsideColor Yellow Blue
  25. if ColorScreen
  26.    BoxHeaderColor Yellow Mag
  27.    InverseColor Yellow Red
  28. else
  29.    BoxHeaderColor Black Grey
  30.    InverseColor Black Grey
  31. endif
  32. BoxHeader ' Environment '
  33. DrawBox 27 6 32 9
  34. TextColor LCyan Blue
  35. ClearLine 205
  36. TextColor Yellow Blue
  37. Writeln
  38. Writeln '   A - Change One Line'
  39. Writeln '   B - Delete Lines'
  40. Writeln '   C - Edit Environment'
  41. Writeln '   D - Sort Environment'
  42. Writeln '   E - Edit Paths'
  43. Write   '   F - Information'
  44.  
  45. OnKey 'A'
  46.    ^SetALine
  47.  
  48. OnKey 'B'
  49.    ^DelLines
  50.  
  51. OnKey 'C'
  52.    ^EdEnv
  53.  
  54. OnKey 'D'
  55.    |DrawBox 33 13 11 3
  56.    |Write ' Sorting'
  57.    |SortArray(Env)
  58.    |WasteEnv(Env)
  59.    |WriteEnv(Env)
  60.    |Wait 20
  61.    |EraseTopWindow
  62.  
  63. OnKey 'E'
  64.    ^EdPath
  65.  
  66. OnKey 'F'
  67.    |BoxHeader ' Information '
  68.    |DrawBox 30 9 32 6
  69.    |TextColor LCyan Blue
  70.    |ClearLine 205
  71.    |TextColor Yellow Blue
  72.    |Writeln
  73.    |Writeln '    Environment Size: ' EnvSize
  74.    |Writeln '    Environment Free: ' EnvFree
  75.    |Write   '    Environment Used: ' (EnvSize - EnvFree)
  76.    |WaitOrKBDReady 4000
  77.    |EraseTopWindow
  78.  
  79. :SetALine
  80. if NumberOfElements(Env) > 1
  81.    BoxHeader ' Pick String to Edit '
  82.    DrawPickBox(Env)
  83.    SetString = PickOne Env
  84.    EraseTopWindow
  85.    EraseTopWindow
  86. endif
  87. if NumberOfElements(Env) = 1 then SetString = Env[1]
  88. if LastKey = Esc then ExitMenu
  89. SetA = Left(SetString,pos('=',SetString) - 1)
  90. delete(SetString,1,pos('=',SetString))
  91. DrawBox 1 20 80 3
  92. Write ' ' SetA '='
  93. InputString = SetString
  94. SetB = Readln
  95. EraseTopWindow
  96. if LastKey = Esc then ExitMenu
  97. SetEnv(SetA + '=' + SetB)
  98. ExitMenu
  99.  
  100. :DelLines
  101. BoxHeader ' Mark Lines to Delete '
  102. DrawPickBox(Env)
  103. PickMany(Env,Env2)
  104. EraseTopWindow
  105. EraseTopWindow
  106. WasteEnv(Env2)
  107. ExitMenu
  108.  
  109. :EdEnv
  110. WriteTextFile ('ENV.TMP',Env)
  111. Explode Off
  112. Execute (MyEditor + ' ENV.TMP')
  113. ReadTextFile ('ENV.TMP',Env2)
  114. DelFile ('ENV.TMP')
  115. DelFile ('ENV.BAK')
  116. WasteEnv(Env)
  117. WriteEnv(Env2)
  118. ExitMenu
  119.  
  120. :EdPath
  121. SeparatePaths
  122. BoxHeader ' Edit Path '
  123. DrawBox 30 9 32 5
  124. TextColor LCyan Blue
  125. ClearLine 205
  126. TextColor Yellow Blue
  127. Writeln
  128. Writeln '   A - Add a Path'
  129. Write   '   B - Delete Paths'
  130.  
  131. OnKey 'A'
  132.    |DrawBox 1 20 80 3
  133.    |repeat
  134.    |   Write ' New Path: '
  135.    |   NewPath = UpperCase(Readln)
  136.    |until ExistDir(NewPath) or (LastKey = Esc) or (SetB = '')
  137.    |EraseTopWindow
  138.    |if ExistDir(NewPath) and (LastKey <> Esc)
  139.    |   Paths[NumberOfElements(Paths) + 1] = NewPath
  140.    |endif
  141.    |MergePaths
  142.  
  143. OnKey 'B'
  144.    ^DelPaths
  145.  
  146. :DelPaths
  147. BoxHeader ' Mark Paths to Delete '
  148. PathLevel = True
  149. DrawPickBox(Paths)
  150. PathLevel = False
  151. PickMany(Paths,Paths2)
  152. EraseTopWindow
  153. EraseTopWindow
  154. EraseTopWindow
  155. EraseTopWindow
  156. SubtractPaths(Paths,Paths2)
  157. MergePaths
  158. ExitMenu
  159.  
  160. Procedure WasteEnv (EnvArray)
  161.    Loop EnvArray
  162.       EnvArray[LoopIndex] = Left(EnvArray[LoopIndex],pos('=',EnvArray[LoopIndex]))
  163.       SetEnv(EnvArray[LoopIndex])
  164.    EndLoop
  165. EndProc
  166.  
  167.  
  168. Procedure WriteEnv (EnvArray)
  169.    Loop EnvArray
  170.       SetEnv(EnvArray[LoopIndex])
  171.    EndLoop
  172. EndProc
  173.  
  174.  
  175. Procedure DrawPickBox (ChooseList)
  176. var BoxDim Longest
  177.    Longest = length(BoxHeader) - 2
  178.    Loop NumberOfElements(ChooseList)
  179.       Longest = Max(Longest,length(ChooseList[LoopIndex]))
  180.    EndLoop
  181.    BoxDim[3] = Min(Longest + 6,ScreenWidth - 6)
  182.    BoxDim[4] = Min(NumberOfElements(ChooseList) + 3,ScreenHeight)
  183.    if PathLevel
  184.       BoxDim[1] = Max(Min(33,ScreenWidth - BoxDim[3]),1)
  185.       BoxDim[2] = Max(Min(12,ScreenHeight - BoxDim[4]),1)
  186.    else
  187.       BoxDim[1] = Max(Min(30,ScreenWidth - BoxDim[3]),1)
  188.       BoxDim[2] = Max(Min(9,ScreenHeight - BoxDim[4]),1)
  189.    endif
  190.    DrawBox BoxDim[1] BoxDim[2] BoxDim[3] BoxDim[4]
  191.    TextColor LCyan Blue
  192.    ClearLine 205
  193.    TextColor Yellow Blue
  194.    NoBoxBorder
  195.    Explode Off
  196.    DrawBox BoxDim[1] + 1 BoxDim[2] + 2 BoxDim[3] - 2 BoxDim[4] - 3
  197.    BlockBox
  198.    Explode
  199. EndProc
  200.  
  201.  
  202. Procedure AppendPaths (Directory)
  203.    if ExistDir(Directory)
  204.       Paths[NumberOfElements(Paths) + 1] = Directory
  205.    endif
  206. EndProc
  207.  
  208.  
  209. Procedure SeparatePaths
  210. var Path B
  211.    Path = UpperCase(ReadEnv('PATH'))
  212.    Dispose(Paths)
  213.    while Path > ''
  214.       B = pos(';',Path)
  215.       if B > 0
  216.          AppendPaths(Left(Path,B - 1))
  217.          delete(Path,1,B)
  218.       else
  219.          AppendPaths(Path)
  220.          Return
  221.       endif
  222.    endwhile
  223. EndProc
  224.  
  225.  
  226. Procedure MergePaths
  227. var Path
  228.    Path = ''
  229.    Loop Paths
  230.       Path = Path + Paths[LoopIndex] + ';'
  231.    EndLoop
  232.    SetEnv('PATH=' + Path)
  233. EndProc
  234.  
  235.  
  236. Procedure SubtractPaths (Org,Sub)
  237. var I Match
  238.    Dispose(Paths)
  239.    I = 1
  240.    while I <= NumberOfElements(Org)
  241.       Match = False
  242.       Loop Sub
  243.          if Org[I] = Sub[LoopIndex]
  244.             Match = True
  245.          endif
  246.       EndLoop
  247.       if not Match then Paths[NumberOfElements(Paths) + 1] = Org[I]
  248.       I = I + 1
  249.    endwhile
  250. EndProc
  251.  
  252.