home *** CD-ROM | disk | FTP | other *** search
/ ARM Club 3 / TheARMClub_PDCD3.iso / hensa / menus / deskmen_2 / Convert (.txt) next >
RISC OS BBC BASIC V Source  |  1996-01-11  |  4KB  |  187 lines

  1.  Menu file converter v2
  2.  Converts DeskMen menu files to text
  3.  Written by Ian Clark
  4.  (c) 1994-96 Ian Clark
  5.  This prog converts DeskMen menu files to plain text
  6.  It's a bit messy but it'll do!
  7. $+" ("+
  8.     t$=""
  9. "DeskMen menu file to text converter."
  10. "By and (c) 1994-96 Ian Clark"
  11. "------------------------------------"'
  12. "Please enter the name of the file to convert."
  13. "If you just press <Return> then the default of"
  14. "'<DMen$Menu>' will be used."'
  15. "File to convert =>"in$
  16.  in$="" 
  17.  in$="<DMen$Menu>"
  18. '"Now enter the output file, default '<DMen$Dir>.^.Converted'"'
  19. "Output as  =>"out$
  20.  out$="" 
  21.  out$="<DMen$Dir>.^.Converted"
  22. "XOS_File",17,in$ 
  23.  ,,,,len%;error%
  24.  error% 
  25.  0,"I can't read that file! Does it exist?"
  26.  block% len%
  27. "OS_File",16,in$,block%,0
  28.  x%=0 
  29. (block%?x%)
  30.  "UNEM" : 
  31.  V2 file
  32.  stack% 256:stptr%=stack%
  33.  '"Version 2 style file"
  34. Loadmenu(in$)
  35. #& menu%=0:old%=0:mptr%=mtable%:m%=0
  36.  hand%=
  37. (out$)
  38. #hand%,"| DeskMen Menu definition file"
  39.  ?block%=3
  40. "OS_Word",14,block%
  41. "Territory_ConvertDateAndTime",-1,block%,block%,256,"%24:%MI.%SE on %WE, %DY%ST %MO %CE%YR"
  42. #hand%,"| Created by 'Convert' v2 at "+
  43. String(block%)
  44. #hand%,"|"
  45.  mptr%+=2
  46. St(mptr%):
  47. #hand%,"{"+t$
  48.  mptr%+=1
  49.  iptr%=itable%
  50. Readitem(0) : 
  51.  Proc to recursivly read each item
  52. #hand%,"}"
  53. #hand%
  54. "SetType "+out$+" FFF"
  55.  "MENU" : 
  56.  ~V1.30 ish version
  57.  '"Old style menu file"
  58.  x%=4 
  59.  len%
  60.  block%?x%=block%?x% 
  61.  block%?x%=0 block%?x%=10
  62.  '"Saving file"
  63. "OS_File",10,out$,&FFF,,block%+4,block%+len%
  64.  very old version
  65.  '"Very old style menu file"
  66.  x%=0 
  67.  len%
  68.  block%?x%=block%?x%>>>1
  69.  block%?x%=0 block%?x%=10
  70.  block%-=4
  71.  len%+=4
  72.  '"Saving file"
  73. "OS_File",10,out$,&FFF,,block%+4,block%+len%
  74.  '"File saved as '";out$;"'"
  75. Loadmenu(path$)
  76.  path$ points to <DMen$Menu> but could change if I impliment multi
  77.  menus, etc.
  78.  ioffset%,poffset%,ipos%,ppos%,hand%
  79. "OS_File",17,path$ 
  80.  ptr%,,,,len%
  81.  ptr%<>1 
  82.  len%<=0 
  83. hand%=
  84. (path$)
  85.  x%=0 
  86. block%?x%=
  87. #hand%
  88.  x%=0 
  89. block%?x%=
  90. #hand%
  91.  menu% len%-8
  92. "OS_GBPB",4,hand%,menu%,len%-8
  93. #hand%
  94.  x%=0 
  95.  len%-8
  96. menu%?(x%)=menu%?(x%) 
  97. "OS_CRC",0,menu%,menu%+len%-8,1 
  98.  crc%
  99.  crc%<>!block% 
  100.  '"That menu failed it's CRC check!"
  101. ipos%=!menu%
  102. ppos%=menu%!4
  103. mlen%=menu%!8
  104. ilen%=menu%!12
  105. plen%=menu%!16
  106.  mtable% mlen%
  107.  itable% ilen%
  108.  ptable% plen%
  109. ptr%=menu%+20
  110.  x%=mtable% 
  111.  mtable%+mlen% 
  112. !x%=!ptr%
  113. ptr%+=4
  114. ptr%=menu%+ipos%
  115.  x%=itable% 
  116.  itable%+ilen% 
  117. !x%=!ptr%
  118. ptr%+=4
  119. ptr%=menu%+ppos%
  120.  x%=ptable% 
  121.  ptable%+plen% 
  122. !x%=!ptr%
  123. ptr%+=4
  124.  ptr%)
  125.  ?ptr%>25 
  126. tx$<255
  127. tx$+=
  128. (?ptr%):ptr%+=1
  129. String(ptr%)
  130.  ?ptr%>31 
  131. tx$<255
  132. tx$+=
  133. (?ptr%):ptr%+=1
  134. Menutext(menu%)
  135.  ptr%,found%,text$
  136. ptr%=mtable%
  137. found%=
  138.  ptr%-mtable%<mlen% 
  139.  found%
  140. old%=?ptr%
  141. ptr%+=2
  142. text$=
  143. St(ptr%)
  144. ptr%+=1
  145.  m%=menu% found%=
  146. =text$
  147. Push(i%)
  148. ?stptr%
  149. stptr%+=1
  150.  val%
  151. val%=?stptr%
  152. stptr%-=1
  153.     =val%
  154. Readitem(menu%)
  155.  m%,iptr%
  156. iptr%=itable%
  157.  iptr%<itable%+ilen%
  158.  m%=?iptr%
  159.  t%=iptr%?1
  160.  o%=iptr%!2
  161.  iptr%+=6
  162. St(iptr%)
  163.  iptr%+=1
  164.  m%=menu% 
  165. #hand%,t$
  166.  0 : 
  167.  Menu
  168.     t$=
  169. Menutext(o%)
  170. #hand%,"{"+t$
  171. Readitem(menu%+1)
  172. #hand%,"}"
  173.  Item
  174.     o%+=ptable%
  175.     t$=
  176. St(o%)
  177.      
  178.  1 : 
  179. #hand%,t$
  180.      
  181.  2 : 
  182. #hand%,"+"+t$
  183.      
  184.  3 : 
  185. #hand%,"-"+t$
  186.         
  187.