home *** CD-ROM | disk | FTP | other *** search
/ ARM Club 3 / TheARMClub_PDCD3.iso / hensa / filemanager / director_1 / !Director / Menus / System / ExpPath (.txt) < prev    next >
RISC OS BBC BASIC V Source  |  1995-06-16  |  3KB  |  174 lines

  1.  >Director:Menus.System.ExpPath
  2.  This expands a path into a serious of menu entries
  3.  By SJM (simon@uniqway.demon.co.uk)
  4.  Call with the Path variable to be expanded as the argument
  5.  eg "Dynamic:/Director:Menus.System.ExpPath C"
  6.  1.00 15/5/95 SJM Started
  7.  1.01 23/5/95 SJM Fixed bug with Foo: path entries
  8.  1.02 26/5/95 NCW Made it recurse in Foo:Bar entries also
  9.                   Collapses paths as far as possible
  10. $+" at "+
  11.  set this to false if you don't want nested paths to be expanded also
  12. allow_recurse=
  13. debug=
  14. (XOS_Module=
  15. swi_number("XOS_Module")
  16. %Menu=
  17. swi_number("Director_Menu")
  18. +EndMenu=
  19. swi_number("Director_EndMenu")
  20. )Option=
  21. swi_number("Director_Option")
  22. +Command=
  23. swi_number("Director_Command")
  24. %Dash=
  25. swi_number("Director_Dash")
  26. 0XOS_ReadVarVal=
  27. swi_number("XOS_ReadVarVal")
  28. buffer_size%=1024
  29.  buffer% buffer_size%
  30. "OS_GetEnv" 
  31. skippast
  32. A$,1)=" " A$=
  33. A$,5))="-QUIT" 
  34. skippast : 
  35. skippast
  36. path$=A$
  37. title$=path$
  38. reduce(path$, dir$, 
  39. make_menu
  40. "Set Director$Menu ExpandedPath"
  41.   path$+=dir$
  42.  "." = 
  43. path$) 
  44.  path$ = 
  45. path$)
  46. "Set Director$Menu Path:"+path$
  47. make_menu
  48.  Menu,""""+title$+""" ExpandedPath -temp"
  49.     comma%=
  50. path$,",",1)
  51.  comma% 
  52.       
  53.  comma% = 1 
  54.          element$=""
  55.       
  56. <&         element$=
  57. path$,comma%-1)
  58.       
  59. >       path$=
  60. path$,comma%+1)
  61. ?        
  62.       element$=path$
  63.       path$=""
  64. B        
  65.     element$+=dir$
  66. E$    
  67.  element$="" 
  68.  element$="@"
  69. G,    recurse%=
  70. reduce(element$, edir$, 
  71.     element$+=edir$
  72. I&    
  73.  allow_recurse=0 
  74.  recurse%=
  75. K2    
  76.  "." = 
  77. element$) 
  78.  element$ = 
  79. element$)
  80.  recurse% 
  81. Mv      
  82.  Option,""""+element$+""" -sub ""Dynamic:/Director:Menus.System.ExpPath "+element$+""" -sprite small_path"
  83. N        
  84. O,      
  85.  Option,"-path "+element$+" -up"
  86. P        
  87.  path$=""
  88.  EndMenu
  89. reduce(
  90.  path$, 
  91.  dir$, all_the_way%)
  92.  done%,p%,q%,var$,a$,more%
  93.   dir$=""
  94.   more%=
  95. \4    
  96.  debug 
  97.  Option,"["+path$+dir$+"] -grey"
  98.     done%=
  99.     p%=
  100. path$,":")
  101. `*      var$=
  102. read(
  103. path$,p%-1)+"$Path")
  104.       
  105.  var$<>"" 
  106.         q%=
  107. var$,",")
  108. d#        
  109.  q%=0 
  110.  all_the_way% 
  111.           a$=
  112. path$,p%+1)
  113. f,          
  114. a$)<>"." 
  115.  a$<>"" 
  116.  a$+="."
  117.           dir$=a$+dir$
  118.           path$=var$
  119. i(          
  120. dir$)="." 
  121.  dir$=
  122. dir$)
  123. j(          
  124.  q%=0 
  125.  done%=
  126.  more%=
  127.         
  128.           more%=
  129.         
  130.       
  131. p        
  132.  done%
  133. =more%
  134. swi_number(name$)
  135.  "OS_SWINumberFromString",,name$ 
  136. 0(a%)
  137. y    s$=""
  138.  ?a%<>0
  139.  s$+=
  140.  a%+=1
  141. skiptospace 
  142. A$,1)<>" "
  143. A$<>0 A$=
  144. A$,2):
  145. skipspace 
  146. A$,1)=" " A$=
  147. A$,2):
  148. skippast 
  149. skiptospace:
  150. skipspace:
  151. uc(a$)
  152. Z%,z$,b$
  153. a$,Z%,1)
  154. z$>="a"
  155. z$<="z" z$=
  156. z$-32)
  157. b$+=z$:
  158. leaf(path$)
  159. leaf$=""
  160. path$ 
  161.  "." = 
  162. path$,I,1) 
  163. path$,I+1)
  164. =path$
  165. read(a$)
  166.  read%,flags%
  167.   ?buffer%=13
  168.  XOS_ReadVarVal,a$,buffer%,buffer_size%,0,3 
  169.  ,,read%;flags%
  170.  flags% 
  171.  read%=0
  172.   buffer%?read%=13
  173. =$buffer%
  174.