home *** CD-ROM | disk | FTP | other *** search
/ Share Gallery 1 / share_gal_1.zip / share_gal_1 / UT / UT070.ZIP / MENUS.EXE / GOFILE.MNU < prev    next >
Text File  |  1989-12-07  |  2KB  |  86 lines

  1. Comment
  2. =============================================================
  3.  
  4. GOFILE.MNU Copyright 1989 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 NewPath Mask TmpFile W BoxDim
  23.  
  24. ClearScreenOnExit Off
  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 'Make sure you have created GOFILE.BAT.'
  35.    Writeln 'Usage: GoFile <mask>
  36.    ExitMenu
  37. endif
  38.  
  39. ;Run WHEREIS and redirect the output to a temporary file, then
  40. ;read the output file into a string array and delete the file.
  41.  
  42. Write 'Scanning for ' Mask ' Files ... '
  43.  
  44. TmpFile = UniqueFileName
  45. Execute 'WHEREIS ' + Mask + '>' + TmpFile
  46. ReadTextFile TmpFile ChooseFiles
  47. DelFile TmpFile
  48. Writeln
  49.  
  50. BoxBorderColor Green Blue
  51. BoxInsideColor Yellow Blue
  52. BoxHeaderColor Yellow Mag
  53.  
  54. ;------ this calculates the size and position of the pick window.
  55.  
  56. if NumberOfElements(ChooseFiles) > 1
  57.    BoxDim[3] = Min(LongestLine + 6,ScreenWidth - 6)
  58.    BoxDim[4] = Min(NumberOfElements(ChooseFiles) + 2,ScreenHeight)
  59.    BoxDim[1] = Max(Min(45,ScreenWidth - BoxDim[3]),1)
  60.    BoxDim[2] = Max(Min(7,ScreenHeight - BoxDim[4]),1)
  61.  
  62.    DrawBox BoxDim[1] BoxDim[2] BoxDim[3] BoxDim[4]
  63.    Choice = PickOne ChooseFiles
  64. endif
  65. if NumberOfElements(ChooseFiles) = 1 then Choice = ChooseFiles[1]
  66. if Choice = '' then ExitMenu
  67.  
  68. ;------ Here we remove the file name from the path.
  69.  
  70. W = length(Choice)
  71. while mid(Choice,W,1) <> '\'
  72.    W = W - 1
  73. endwhile
  74. NewPath = Left(Choice,W - 1)
  75. if length(NewPath) = 2 then NewPath = NewPath + '\'
  76.  
  77. ChDir NewPath
  78.  
  79. if pos('$P',UpperCase(ReadEnv('PROMPT'))) > 0 then ExitMenu
  80.  
  81. ;------ If the users prompt does not show the current path, we show it here.
  82.  
  83. TextColor Green Black
  84. Writeln
  85. Writeln 'Current Path = ' Path
  86.