home *** CD-ROM | disk | FTP | other *** search
/ High Voltage Shareware / high1.zip / high1 / DIR22 / JORF21_2.ZIP / DIRLIST.J < prev    next >
Text File  |  1993-07-05  |  4KB  |  112 lines

  1. Class:DirList                   | Class Definition
  2.   Name                          | File Name
  3.   Path                          | File Path
  4.   WildCard                      | Wildcard for directory
  5.   ExclusionList                 | Extension Exclusion List
  6.   FileArray                     | Array of files on this path
  7.   DirArray                      | Array of other paths
  8.  
  9. DirList:Start                   | FOR TESTING:  Start routine
  10.   New (FileName)
  11.   FileName = DirList:GetFile("*.*",Null)
  12.   Msg:Add
  13.     File name is {FileName}
  14.   Return (Ok)
  15.  
  16. DirList:Cancel(List)            | Routine to Cancel data entry
  17.   List->Name=Null               | Signal that we canceled
  18.   Return(Null)                  | Returning Null will finish input
  19.  
  20. DirList:Done(List,Name)         | Routine to finish data entry
  21.   If (Str:In(List->Name,"*") Or Str:In(List->Name,"?"))
  22.     List->WildCard  = List->Name
  23.     List->FileArray = DirList:FileArray(List->Wildcard, List->Exclusionlist)
  24.     Kbd:Put("Home_Key")        | Stuff home key
  25.     Win:Dsp            | Redisplay (including arrays)
  26.     Return (Ok)
  27.  
  28.   If (List->Name==Null)         | If name is still null display message
  29.     Msg:Add
  30.       Please select a file
  31.       name or "Cancel".
  32.     Return (Ok)                 | Returning Ok will continue input
  33.   Return (Null)                 | Returning Null will finish input
  34.  
  35. DirList:FileArray(WildCard,Exclusionlist)  | Read a file array
  36.   New (Array,OldMessage)
  37.   If (WildCard!='SUBDIR')
  38.     If (Win:Ptr)
  39.       OldMessage = Win:Msg('Reading Directory')
  40.     Else
  41.       Win:Add("Reading")
  42.     Reading Directory
  43.   Array = Arr:Dir (WildCard, ExclusionList, 12)
  44.   If (WildCard!='SUBDIR')
  45.     Win:Msg(OldMessage)
  46.   Return (Array)
  47.  
  48. DirList:GetFile(WildCard,ExclusionList)
  49.   New (OrigPath, DirList:List, DirChoice, FileChoice)
  50.  
  51.   | Initalize values
  52.   OrigPath            = File:ChDir()
  53.   List->Path          = OrigPath
  54.   List->WildCard      = WildCard
  55.   List->ExclusionList = Exclusionlist
  56.   List->FileArray     = DirList:FileArray(List->Wildcard, List->Exclusionlist)
  57.   List->DirArray      = DirList:FileArray("SUBDIR")
  58.  
  59.   Event:Add(Null)               | Block prior keystroke events
  60.   Win:Add ("Get File Name", 0, 0, 14, 56, Here)
  61.     Type:"Message"
  62.  
  63.     | Input File Name
  64.     Input:"File&name:  ",  Wid:24, Row:2, Col:3, Field:"List->Name"
  65.  
  66.     | Files array with a group box around
  67.     Group:"&Files",       Row:6, Col:2, Wid:16, Len:14
  68.     Array:"", Field:"List->FileArray",
  69.               Choice:"FileChoice",
  70.               Action:"DirList:NewName(List,List->FileArray[FileChoice])"
  71.  
  72.     | Directories array with a group box around
  73.     Group:"&Directories", Row:6, Col:22, Wid:16, Len:14
  74.     Array:"", Field:"List->DirArray",
  75.               Choice:"DirChoice"
  76.               Action:"DirList:NewDir(List,List->DirArray[DirChoice])"
  77.  
  78.     | Input File Path
  79.     Input:"Directory: ",   Wid:24, Row:4, Col:3, Field:"List->Path"
  80.           After:"DirList:NewDir(List,List->Path)"
  81.  
  82.     | Two buttons
  83.     Button:"   &Ok   ", Row:1, Col:42, Wid:14
  84.       Action:"DirList:Done(List,List->FileArray[FileChoice])"
  85.     Button:" &Cancel ", Row:4, Col:42, Wid:14
  86.       Action:"DirList:Cancel(List)"
  87.  
  88.   If (File:ChDir(OrigPath))
  89.     If (List->Name)
  90.       If (Str:At(List->Path,Str:Len(List->Path),1)=='\')
  91.     Return (List->Path+List->Name)
  92.       Return (List->Path+'\'+List->Name)
  93.   Return (Null)
  94.  
  95. DirList:NewDir(List,Path)       | Routine to set a new path
  96.   If (File:Chdir(Path))         | Change to the new path
  97.     List->Path = File:ChDir()   | Reset path name
  98.     List->Name = Null           | Set file name to null
  99.     | Re-read file array
  100.     List->FileArray = DirList:FileArray(List->Wildcard, List->Exclusionlist)
  101.     | Re-Read directory array - special argument "SUBDIR" does this
  102.     List->DirArray  = DirList:FileArray("SUBDIR")
  103.     Win:Dsp                     | Redisplay Window
  104.   Return(Ok)                    | Returning Ok continues input
  105.  
  106. DirList:NewName(List,Name)      | Routine to set a new name
  107.   List->Name = Word:At(Name,1)  | Set the name (Easy!)
  108.   Win:Dsp                       | Redisplay the screen
  109.   Kbd:Put("Home_Key")        | And go back to file name
  110.   Return(Ok)                    | Returning OK will continue input
  111.  
  112.