home *** CD-ROM | disk | FTP | other *** search
/ ARM Club 3 / TheARMClub_PDCD3.iso / hensa / filemanager / director_1 / !Director / Menus / Files / TreePick (.txt) < prev   
RISC OS BBC BASIC V Source  |  1995-06-23  |  2KB  |  91 lines

  1.  >TreePick
  2.  By Dave Lawrence 22Jun95
  3.  TreePick is a magic Dynamic Menu that allows you to do things like:
  4.  TreePick -type Sprite -dir Root:Backdrops -command "Backdrop -tile %0"
  5.  It (recursively) makes menus of files of the given type starting from
  6.  'dir'.  When one is clicked on, the command is executed with the
  7.  filename substituted as expected.
  8. $;" at line ";
  9.  buf 512
  10. getargs
  11.  "OS_ReadArgs", "type/k,dir/k,command/k", in$, buf, 512
  12.  Get file type, look up type number, make sprite name
  13. type$=
  14. str0(!buf)
  15.  "OS_FSControl",31,type$ 
  16.  ,,file_type
  17. .type_spr$ = "small_"+
  18. "000"+
  19. ~file_type,3)
  20.  Just get the directory
  21. dir$=
  22. str0(buf!4)
  23.  Get the command, rebuild command with %%s replacing %s, make command to pass to sub-directories
  24. command$=
  25. str0(buf!8)
  26. sub$=""
  27.  i=1 
  28. command$
  29. command$,i,1)="%" sub$+="%"
  30.  sub$+=
  31. command$,i,1)
  32. [sub$="Dynamic:/Director:Menus.Files.TreePick -type "+type$+" -command """""+sub$+""""""
  33. !%menu=
  34. swi_number("Director_Menu")
  35. "+endmenu=
  36. swi_number("Director_EndMenu")
  37. #)option=
  38. swi_number("Director_Option")
  39. $+command=
  40. swi_number("Director_Command")
  41. %,subargs=
  42. swi_number("OS_SubstituteArgs")
  43. &%dash=
  44. swi_number("Director_Dash")
  45.  Read canonicalised path name and take menu name from the current leaf
  46.  "OS_FSControl",37,dir$,buf,,,512
  47. canon$=
  48. str0(buf)
  49. "DirectorParsePath "+canon$
  50.  menu,"<Director$CurrentLeaf> TreePick -temp"
  51.  "OS_GBPB",12,dir$,buf,1,i,128,0 
  52.  ,,,read,i
  53.  read=1 
  54.   leaf$=
  55. str0(buf+24)
  56.   path$=dir$+"."+leaf$
  57.  buf!16 
  58.  buf!20 = file_type 
  59. 7/     
  60.  option, leaf$+" -sprite "+type_spr$
  61. 89     
  62.  subargs, path$, buf, 512, command$, 
  63. command$
  64.      
  65.  command, buf
  66. :        
  67. <O    
  68.  option, leaf$+" -sprite small_dir -sub "+
  69. 34+sub$+" -dir "+path$+
  70.  i=-1
  71. *EndMenu
  72. *Set Director$Menu TreePick
  73. swi_number(swi$)
  74.  "OS_SWINumberFromString",,swi$ 
  75.  swi%
  76. F    =swi%
  77. getargs
  78.  "OS_GetEnv" 
  79. quit=
  80. A$,"-quit")
  81.  quit=0 quit=
  82. A$,"-QUIT")
  83. A$,quit+6)
  84. A$," ")
  85. A$,spc+1)
  86. str0(A)
  87. R    A$=""
  88.  ?A<>0
  89.  A$+=
  90. U     A+=1
  91.