home *** CD-ROM | disk | FTP | other *** search
/ ARM Club 3 / TheARMClub_PDCD3.iso / hensa / filemanager / director_1 / !Director / Utils / ExpandMenu (.txt) < prev    next >
RISC OS BBC BASIC V Source  |  1994-09-06  |  6KB  |  278 lines

  1.  >ExpandMenu
  2. taskwindow
  3.  "Expand BackMenu file"'
  4.  "Shift-Drag files to input their paths if running in a task window"'
  5.  " Input  : "f$
  6.  '"Press Return for """f$+"<"""'
  7.  " Output : "o$:
  8.  o$="" o$=f$+"<"
  9. tab$=
  10. 4," ")
  11. tab2$=
  12. 8," ")
  13.  "OS_File",5,f$ 
  14.  ,,,,len
  15.  mem len
  16.  "OS_File",&FF,f$,mem
  17.  menu$(256),count(256)
  18. menus=0
  19. duplicates=
  20. collate("",0)
  21.  "OS_CLI","Create "+o$
  22. throwback=
  23.  duplicates 
  24.  "XOS_SWINumberFromString",,"DDEUtils_ThrowbackStart" 
  25.  throwback=(v 
  26.  1)=0
  27.  throwback 
  28.  canon 256
  29.  "OS_FSControl",37,o$,canon,,,256
  30.  "DDEUtils_ThrowbackStart"
  31.  "DDEUtils_ThrowbackSend",0,,canon
  32. $;" at ";
  33. #out: 
  34. out_line=0
  35. bput("|Start "+f$+lf$)
  36. first_menu=
  37. show_menu(0)
  38. bput(lf$)
  39. bput("|End"+lf$)
  40.  throwback 
  41.  "DDEUtils_ThrowbackEnd"
  42.  #out
  43.  "OS_CLI","SetType "+o$+" Obey"
  44. '"Done"'
  45.  "You will probably need to edit the file by hand now to"
  46.  "1) Replace %%0 with <MenuText> and %% with % or <37>"
  47.  "   in parameterised Menus"
  48.  "2) Delete key shortcuts from option texts (-key adds"
  49.  "   them for you)"'
  50. collate(root$,start)
  51.  ptr,sub(),s,i,name$
  52.  sub(50)
  53. name$=$(mem+start)
  54. add_menu(name$)
  55. ptr=mem+start+28
  56. PRINT MID$(root$+"."+name$,2)
  57.  last=
  58. bit(7,!ptr)
  59.  ptr!4<>-1 s+=1:sub(s)=ptr!4
  60.  ptr+=24
  61.  last
  62.  s>0 
  63.  i=1 
  64. collate(root$+"."+name$,sub(i))
  65. show_menu(start)
  66.  ptr,a,last,sub(),s,i
  67.  sub(50)
  68. ptr=mem+start
  69. name$=$ptr
  70. bput(lf$)
  71. bput("Menu "+
  72. quoted(name$))
  73.  first_menu 
  74. bput(" Pinboard")
  75.   first_menu=
  76. bput(lf$)
  77. check("Duplicated definition of",name$)
  78. title_fg=ptr?12
  79. title_bg=ptr?13
  80. work_fg=ptr?14
  81. work_bg=ptr?15
  82. width=ptr!16
  83. height=ptr!20
  84. gap=ptr!24
  85. a=ptr+28
  86.  tick=
  87. bit(0,!a)
  88.  line=
  89. bit(1,!a)
  90.  write=
  91. bit(2,!a)
  92.  last=
  93. bit(7,!a)
  94.  sub=a!4
  95.  flags=a!8
  96.  text_bg=(flags>>28) 
  97.  text_fg=(flags>>24) 
  98.  text=mem+a!12
  99. l8 command=mem+a!16+1 : 
  100.  all have a &07 at the start!
  101.  type=a!20-1
  102.  keys=command+
  103. $command+1
  104.  keys=keys+
  105. $keys
  106.  keys=(keys+1+3)
  107.  sub<>-1 s+=1:sub(s)=sub
  108. bput(tab$+"Option "+
  109. quoted($text))
  110.  $command<>"" 
  111.  command1$=
  112. com($command) 
  113.  command1$=""
  114.  type=0 
  115.  command2$=
  116. com($(command+
  117. $command+1)) 
  118.  command2$=""
  119.  command2$="" 
  120. command1$,10)="Filer_Run " 
  121. command1$,"|M")=0 
  122.  sub=-1 
  123. w&   
  124. bput(" -path "+
  125. command1$,11))
  126.    command1$=""
  127.  sub<>-1 
  128. bput(" -sub ")
  129.   sub$=$(mem+sub)
  130.  sub$<>$text 
  131. bput(
  132. quoted(sub$)) 
  133. bput("*")
  134.  sub<>-1 
  135. check("Call to submenu",sub$)
  136.  i=0 
  137.   key=keys!(i*4)
  138.  key<>&FF 
  139.  i=0 
  140. #      
  141. bput(" -key "+
  142. key(key))
  143.         
  144. )      
  145.  "Can't assign key ";
  146. key(key)
  147.         
  148.  tick 
  149. bput(" -tick")
  150.  text_bg<>0 
  151.  text_fg<>7 
  152. bput(" -bg "+
  153. text_bg+" -fg "+
  154. text_fg)
  155.  type>0 
  156. bput(" -len "+
  157. type)
  158. bput(lf$)
  159.  command1$<>"" 
  160. bput(tab2$+"Command "+command1$+lf$)
  161.  command2$<>"" 
  162. bput(tab2$+"Command "+command2$+lf$)
  163.  line 
  164. bput("Dash"+lf$)
  165.  a+=24
  166.  last
  167. bput("EndMenu"+lf$)
  168.  s>0 
  169.  i=1 
  170. show_menu(sub(i))
  171. bput(o$)
  172.  #out,o$;
  173. o$,1)=lf$ out_line+=1
  174. quoted(a$)
  175. a$," ") 
  176.  a$="" 
  177.  =""""+a$+""""
  178. bit(b,n)
  179.  (1<<b))>0
  180. key(key)
  181.  m$=""
  182.  key >= &180 
  183.  key <= &1FF 
  184.  key 
  185.  &10 
  186.  m$+=
  187.  key 
  188.  &20 
  189.  m$+="^"
  190.    key = key 
  191.  key >= 
  192.  key <= 
  193.  key = key - 64
  194.  key 
  195.  &01E: =m$+"Home"
  196.  &01D: =m$+"Return"
  197.  &01C: =m$+"Backspace"
  198.  &020: =m$+"Space"
  199.  &07F: =m$+"Delete"
  200.  &01B: =m$+"Esc"
  201.  &180: =m$+"Print"
  202.  &181: =m$+"F1"
  203.  &182: =m$+"F2"
  204.  &183: =m$+"F3"
  205.  &184: =m$+"F4"
  206.  &185: =m$+"F5"
  207.  &186: =m$+"F6"
  208.  &187: =m$+"F7"
  209.  &188: =m$+"F8"
  210.  &189: =m$+"F9"
  211.  &18A: =m$+"Tab"
  212.  &18B: =m$+"Copy"
  213.  &18C: =m$+"Left"
  214.  &18D: =m$+"Right"
  215.  &18E: =m$+"Down"
  216.  &18F: =m$+"Up"
  217.  &1CA: =m$+"F10"
  218.  &1CB: =m$+"F11"
  219.  &1CC: =m$+"F12"
  220.  &1CD: =m$+"Insert"
  221. A     
  222.  (key >= 33 
  223.  key <= 126) 
  224.  (key >= 128 
  225.  key <= 255) 
  226.        =
  227.      
  228. !       
  229.  key >= 0 
  230.  key <= 31
  231.          ="^"+
  232. (key + 64)
  233.        
  234.      
  235.  "Unknown key &";~key
  236. com(c$)
  237.  o$,i
  238.     o$=""
  239. c$,"%")
  240.  i=0 
  241.   o$+=c$
  242.   o$+=
  243. c$,i)+"%"
  244.   c$=
  245. c$,i+1)
  246. add_menu(n$)
  247.  i<menus 
  248.  n$<>menu$(i)
  249.      i+=1
  250.  n$<>menu$(i) menu$(i)=n$:menus+=1 
  251.  duplicates=
  252. count(i)+=1
  253. check(err$,n$)
  254.  i<menus 
  255.  menu$(i)<>n$
  256.      i+=1
  257.  count(i)>1 
  258.  throwback 
  259.  "DDEUtils_ThrowbackSend",1,,canon,out_line,0,err$+" 
  260. "+n$+"
  261. err$+" 
  262. "+n$+"
  263.  at line ";out_line
  264. taskwindow
  265.  buf 256
  266.  "OS_GetEnv" 
  267.  env$
  268.  "XOS_ReadArgs","quit/k,task/S,,,,,",env$,buf,256 
  269.  !buf<>0 
  270. ) n$="":i=!buf:
  271.  ?i>31:n$+=
  272. ?i:i+=1:
  273. 7 l$="":i=
  274. n$,i,1)<>".":l$=
  275. n$,i,1)+l$:i-=1:
  276.  buf!4=0 
  277.  "OS_CLI","TaskWindow -quit -name "+l$+" ""Run "+n$+" -task"""
  278.