home *** CD-ROM | disk | FTP | other *** search
RISC OS BBC BASIC V Source | 1996-01-11 | 3.9 KB | 187 lines |
- Menu file converter v2
- Converts DeskMen menu files to text
- Written by Ian Clark
- (c) 1994-96 Ian Clark
- This prog converts DeskMen menu files to plain text
- It's a bit messy but it'll do!
- $+" ("+
- t$=""
- "DeskMen menu file to text converter."
- "By and (c) 1994-96 Ian Clark"
- "------------------------------------"'
- "Please enter the name of the file to convert."
- "If you just press <Return> then the default of"
- "'<DMen$Menu>' will be used."'
- "File to convert =>"in$
- in$=""
- in$="<DMen$Menu>"
- '"Now enter the output file, default '<DMen$Dir>.^.Converted'"'
- "Output as =>"out$
- out$=""
- out$="<DMen$Dir>.^.Converted"
- "XOS_File",17,in$
- ,,,,len%;error%
- error%
- 0,"I can't read that file! Does it exist?"
- block% len%
- "OS_File",16,in$,block%,0
- x%=0
- (block%?x%)
- "UNEM" :
- V2 file
- stack% 256:stptr%=stack%
- '"Version 2 style file"
- Loadmenu(in$)
- #& menu%=0:old%=0:mptr%=mtable%:m%=0
- hand%=
- (out$)
- #hand%,"| DeskMen Menu definition file"
- ?block%=3
- "OS_Word",14,block%
- "Territory_ConvertDateAndTime",-1,block%,block%,256,"%24:%MI.%SE on %WE, %DY%ST %MO %CE%YR"
- #hand%,"| Created by 'Convert' v2 at "+
- String(block%)
- #hand%,"|"
- mptr%+=2
- St(mptr%):
- #hand%,"{"+t$
- mptr%+=1
- iptr%=itable%
- Readitem(0) :
- Proc to recursivly read each item
- #hand%,"}"
- #hand%
- "SetType "+out$+" FFF"
- "MENU" :
- ~V1.30 ish version
- '"Old style menu file"
- x%=4
- len%
- block%?x%=block%?x%
- block%?x%=0 block%?x%=10
- '"Saving file"
- "OS_File",10,out$,&FFF,,block%+4,block%+len%
- very old version
- '"Very old style menu file"
- x%=0
- len%
- block%?x%=block%?x%>>>1
- block%?x%=0 block%?x%=10
- block%-=4
- len%+=4
- '"Saving file"
- "OS_File",10,out$,&FFF,,block%+4,block%+len%
- '"File saved as '";out$;"'"
- Loadmenu(path$)
- path$ points to <DMen$Menu> but could change if I impliment multi
- menus, etc.
- ioffset%,poffset%,ipos%,ppos%,hand%
- "OS_File",17,path$
- ptr%,,,,len%
- ptr%<>1
- len%<=0
- hand%=
- (path$)
- x%=0
- block%?x%=
- #hand%
- x%=0
- block%?x%=
- #hand%
- menu% len%-8
- "OS_GBPB",4,hand%,menu%,len%-8
- #hand%
- x%=0
- len%-8
- menu%?(x%)=menu%?(x%)
- "OS_CRC",0,menu%,menu%+len%-8,1
- crc%
- crc%<>!block%
- '"That menu failed it's CRC check!"
- ipos%=!menu%
- ppos%=menu%!4
- mlen%=menu%!8
- ilen%=menu%!12
- plen%=menu%!16
- mtable% mlen%
- itable% ilen%
- ptable% plen%
- ptr%=menu%+20
- x%=mtable%
- mtable%+mlen%
- !x%=!ptr%
- ptr%+=4
- ptr%=menu%+ipos%
- x%=itable%
- itable%+ilen%
- !x%=!ptr%
- ptr%+=4
- ptr%=menu%+ppos%
- x%=ptable%
- ptable%+plen%
- !x%=!ptr%
- ptr%+=4
- ptr%)
- ?ptr%>25
- tx$<255
- tx$+=
- (?ptr%):ptr%+=1
- String(ptr%)
- ?ptr%>31
- tx$<255
- tx$+=
- (?ptr%):ptr%+=1
- Menutext(menu%)
- ptr%,found%,text$
- ptr%=mtable%
- found%=
- ptr%-mtable%<mlen%
- found%
- old%=?ptr%
- ptr%+=2
- text$=
- St(ptr%)
- ptr%+=1
- m%=menu% found%=
- =text$
- Push(i%)
- ?stptr%
- stptr%+=1
- val%
- val%=?stptr%
- stptr%-=1
- =val%
- Readitem(menu%)
- m%,iptr%
- iptr%=itable%
- iptr%<itable%+ilen%
- m%=?iptr%
- t%=iptr%?1
- o%=iptr%!2
- iptr%+=6
- St(iptr%)
- iptr%+=1
- m%=menu%
- #hand%,t$
- 0 :
- Menu
- t$=
- Menutext(o%)
- #hand%,"{"+t$
- Readitem(menu%+1)
- #hand%,"}"
- Item
- o%+=ptable%
- t$=
- St(o%)
-
- 1 :
- #hand%,t$
-
- 2 :
- #hand%,"+"+t$
-
- 3 :
- #hand%,"-"+t$
-
-