home *** CD-ROM | disk | FTP | other *** search
/ Media Share 9 / MEDIASHARE_09.ISO / batch / mxmnu233.zip / GOFILE.MNU < prev    next >
Text File  |  1991-09-29  |  2KB  |  95 lines

  1. Comment
  2. =============================================================
  3.  
  4. GOFILE.MNU Copyright 1989-91 by Marc Perkel
  5.  
  6. This example allows you to find a file on your hard disk or
  7. network and go to the directory where it is.
  8.  
  9. It requires that you have WHEREIS from the Computer Tyme DOS
  10. ToolBox, or a WHEREIS type program that can scan your drive and
  11. output complete file names that can be redirected to a temporary
  12. file.
  13.  
  14. Make sure to create a file called GOFILE.BAT containing:
  15.  
  16. @ECHO OFF
  17. MARXMENU GOFILE %1
  18.  
  19. =============================================================
  20. EndComment
  21.  
  22. Var ChooseFiles Choice Mask TmpFile BoxDim ChTemp LastPath
  23.  
  24. StandardIO
  25. ClearScreenFirst Off
  26. TextColor Green Black
  27. ExitCode = 0
  28. Mask = UpperCase(ParamStr(2))
  29. Writeln
  30.  
  31. ;----- Exit if mask not specified.
  32.  
  33. if Mask = ''
  34.    Writeln 'Usage: GoFile <mask>'
  35.    ExitMenu
  36. endif
  37.  
  38. ;Run WHEREIS and redirect the output to a temporary file, then
  39. ;read the output file into a string array and delete the file.
  40.  
  41. Write 'Scanning for ' Mask ' Files ... '
  42.  
  43. TmpFile = UniqueFileName
  44. Execute 'WHEREIS ' + Mask + '>' + TmpFile
  45. ReadTextFile (TmpFile,ChooseFiles)
  46. DelFile TmpFile
  47. Writeln
  48.  
  49. ;----- Save only Path Part
  50.  
  51. Loop ChooseFiles
  52.    ChooseFiles[LoopIndex] = PathPart(ChooseFiles[LoopIndex])
  53. EndLoop
  54.  
  55. ;----- Remove Duplicates
  56.  
  57. ChTemp = ChooseFiles
  58. Dispose ChooseFiles
  59. LongestLine = 0
  60. Loop ChTemp
  61.   if ChTemp[LoopIndex] <> LastPath
  62.      LastPath = ChTemp[LoopIndex]
  63.      AppendArray(ChooseFiles,LastPath)
  64.      LongestLine = Max(LongestLine,length(LastPath))
  65.   endif
  66. EndLoop
  67.  
  68. BoxBorderColor Green Blue
  69. BoxInsideColor Yellow Blue
  70. BoxHeaderColor Yellow Mag
  71.  
  72. ;----- this calculates the size and position of the pick window.
  73.  
  74. if NumberOfElements(ChooseFiles) > 1
  75.    BoxDim[3] = Min(LongestLine + 6,ScreenWidth - 6)
  76.    BoxDim[4] = Min(NumberOfElements(ChooseFiles) + 2,ScreenHeight)
  77.    BoxDim[1] = Max(Min(45,ScreenWidth - BoxDim[3]),1)
  78.    BoxDim[2] = Max(Min(7,ScreenHeight - BoxDim[4]),1)
  79.  
  80.    DrawBox BoxDim[1] BoxDim[2] BoxDim[3] BoxDim[4]
  81.    Choice = PickOne ChooseFiles
  82. endif
  83. if NumberOfElements(ChooseFiles) = 1 then Choice = ChooseFiles[1]
  84. if Choice = '' then ExitMenu
  85.  
  86. ChDir Choice
  87.  
  88. if pos('$P',UpperCase(ReadEnv('PROMPT'))) > 0 then ExitMenu
  89.  
  90. ;----- If the users prompt does not show the current path, we show it here.
  91.  
  92. TextColor Green Black
  93. Writeln
  94. Writeln 'Current Path = ' Path
  95.