home *** CD-ROM | disk | FTP | other *** search
- ; email - jamesboyd@velvety.demon.co.uk
-
- ; DON'T JUST TRY TO RUN THIS!
-
- .Info
- .
- ; this file contains a whole load of statements and functions
- ; cut 'n' pasted from various source files by james l boyd.
- ; note that NOT ALL OF THESE ARE BY ME!
-
- ; just cut and paste into your programs as you need!
- ; the dotted lines are there to help you cut the right area!
-
- ; NOTES
-
- ; 1) each call has a demonstration underneath it...
-
- ; 2) remember,the function/statement names are case-sensitive.
-
- ; 3) also,some of these require you to have
- ; blitzlibs:amigalibs.res resident in
- ; the Compiler Options...
-
- ; 4) some of them require a currently used screen,or window...
-
- ; you can test each function or statement by uncommenting the
- ; function/statement demo you want to try,ONE AT A TIME (you
- ; MUST re-comment each one before testing another! - unless
- ; you know what you're doing)
-
- ;----------------------------------------------------------------
-
- .Beginners
- .
- ; B E G I N N E R S !
-
- ; if you don't know how to use statements and functions,
- ; it's easy!
-
- ; 1) Cut out the function or statement you want to use,from :
-
- ; Function...
- ; ------to------
- ; End Function
-
- ; or
-
- ; Statement...
- ; ------to------
- ; End Statement
-
- ; 2) Paste it into the TOP of your source code (or anywhere,
- ; as long as you DON'T TRY AND CALL IT BEFORE THE PROGRAM
- ; REACHES IT!)
-
- ; 3) Look at the demo for each function/statement to see
- ; how to use it...
-
- ;----------------------------------------------------------------
-
- .STATEMENTS
- .
- ;-----------------------------------------------------------------
-
- .BFWindow
-
- ; statement : BFWindow{}
-
- ; fills a window with a backfill pattern,like this :
-
- ; 010101010101010101010101010101010101
- ; 101010101010101010101010101010101010
- ; 010101010101010101010101010101010101
- ; 101010101010101010101010101010101010
- ; 010101010101010101010101010101010101
- ; 101010101010101010101010101010101010
- ; 010101010101010101010101010101010101
-
- ; that kind of thing ;) looks all white,like requesters...
- ; note that it needs a non-GIMMEZEROZERO window,or it'll be
- ; offset (I'm not trying to figure this statement out ;)
-
- ; good when used with WFBox {} - see .WFBox...
-
- Statement BFWindow{WindoID.w}
-
- *Windo.Window = Peek.l(Addr Window(WindoID.w))
- USEPATH *Windo
- \RPort\AreaPtrn = ?BackFill ;Pattern Address
- \RPort\AreaPtSz = 1 ;use 2 arrays form the
- ;Pattern Address
- WLeft.w = \BorderLeft
- WTop.w = \BorderTop
- WWidth.w = \Width - \BorderRight - 1
- WHeight.w = \Height - \BorderBottom - 1
-
- ;Put a BackFill in the Window.
- SetAPen_ \RPort,2
- SetDrMd_ \RPort,1
- BltPattern_ \RPort,0,WLeft,WTop,WWidth,WHeight,0
-
- \RPort\AreaPtrn = 0 ;Put it back to 0
- \RPort\AreaPtSz = 0 ;Put it back to 0
-
- Statement Return
- BackFill: Dc.w $5555, $AAAA
- End Statement
-
- ; demo :
-
- ; FindScreen 0
- ; Window 0,0,0,640,200,$100f,"",1,2
- ; BFWindow{0}
- ; MouseWait:End
-
- .Draw3dBox
-
- ; statement : Draw3dBox{}
-
- ; draws a 3d box in a window
- ; note that you do need a window to use this!
- ; see demo for more...
-
- Statement Draw3dBox{ax,ay,Width.l,Height.l,way.b}
- ax2.l = (ax+Width)-1:ay2.l = (ay+Height)-1
- If way=0
- Wline ax2,ay,ax,ay,ax,ay2,2
- Wline ax+1,ay2,ax2,ay2,ax2,ay,1
- Wline ax+1,ay2-1,ax2-1,ay2-1,ax2-1,ay+1,3
- Else
- Wline ax2,ay,ax,ay,ax,ay2,1
- Wline ax2-1,ay+1,ax+1,ay+1,ax+1,ay2-1,3
-
- Wline ax+1,ay2,ax2,ay2,ax2,ay,2
- EndIf
- End Statement
-
- ; demo :
-
- ; FindScreen 0
- ; Window 0,0,0,640,200,$140f,"Hello",1,2
- ; Draw3dBox{10,10,350,150,1} ; try replacing the 1 with 0 for
- ; an inverse box...
- ; MouseWait:End
-
- ;-----------------------------------------------------------------
-
- .FlashText
-
- ; statement : FlashText{}
-
- ; shows flashing text - needs a window!
- ; x is the left position,y is the top position,no is the
- ; number of times to flash,a$ is the text,speed is the DELAY
-
- Statement FlashText{x.w,y.w,no.w,a$,speed.b}
-
- For a.b=1 To no-1
- WColour 1
- WLocate x,y:Print a$
- VWait speed
- WColour 0
- WLocate x,y:Print a$
- VWait speed
- Next a
-
- WColour 1
- WLocate x,y:Print a$
-
- End Statement
-
- ; demo :
-
- ; FindScreen 0
- ; Window 0,0,0,640,200,$140f,"FlashText Demo",1,2
-
- ; FlashText{100,100,10,"Hello,I'm flashing!",2}
-
- ; End
-
- ;-----------------------------------------------------------------
- .
- .FUNCTIONS
- .
- ;-----------------------------------------------------------------
-
- .WFBox
-
- ; function : WFBox{}
-
- ; clears a 0 (standard : grey) colour box over a filled window...
- ; make all parameters "-1" (experiment with other if you want,
- ; but I never got it figured out)...
-
- ; good when used with BFWindow {} - see .BFWindow...
-
- Function.b WFBox{WindoID.w,LeftSide.w,BoxWidth.w,TopSide.w,BoxHeight.w}
-
- MakeiT.b = False
-
- *Windo.Window = Peek.l(Addr Window(WindoID))
-
- USEPATH *Windo
- ;Look to see if option are on
- LeftSide
- If LeftSide < -1 ;Not in Use
- Function Return MakeiT
- EndIf
-
- If LeftSide = -1
- WLeft.w = \BorderLeft + 5 ;then use Init Value
- Else
- WLeft.w = \BorderLeft + LeftSide ;New Value
- EndIf
-
- If LeftSide >= ( \Width - \BorderRight ) - 1 ;Value too high?
- MakeiT = False ;Do not do it
- Function Return MakeiT ;return the result
- EndIf
-
- BoxWidth
- If BoxWidth < -1 OR BoxWidth = 0
- Function Return MakeiT
- EndIf
-
- If BoxWidth = -1
- WWidth.w = ( \Width - \BorderRight ) - 5
- Else
- WWidth.w = WLeft + BoxWidth
- EndIf
-
- If WWidth >= \Width - \BorderRight
- Function Return MakeiT
- EndIf
-
- TopSide
- If TopSide < -1
- Function Return MakeiT
- EndIf
-
- If TopSide = -1
- WTop.w = \BorderTop + 5
- Else
- WTop.w = \BorderTop + TopSide
- EndIf
-
- If TopSide >= \Height - \BorderBottom
- MakeiT = False
- Function Return MakeiT
- EndIf
-
-
- BoxHeight
- If BoxHeight < -1 OR BoxHeight = 0
- Function Return MakeiT
- EndIf
-
- If BoxHeight = -1
- WHeight.w = ( \Height - \BorderBottom ) - 25
- Else
- WHeight.w = WTop + BoxHeight
- EndIf
-
- If WHeight.w >= \Height - \BorderBottom
- MakeiT = False
- Function Return MakeiT
- EndIf
-
- Draw_The_Box
- SetAPen_ \RPort,0
- BltPattern_ \RPort,0,WLeft,WTop,WWidth,WHeight,0
- SetAPen_ \RPort,1
- Move_ \RPort,WLeft,WHeight
- Draw_ \RPort,WLeft,WTop
- Draw_ \RPort,WWidth,WTop
- SetAPen_ \RPort,2
- Draw_ \RPort,WWidth,WHeight
- Draw_ \RPort,WLeft,WHeight
- MakeiT = True
-
- Function Return MakeiT
- End Function
-
- ; demo :
-
- ; FindScreen 0
- ; Window 0,0,0,640,200,$140e,"",1,2
-
- ; SetRast_ RastPort(0),2
- ; ;WCls 2
-
- ; ; Replace the SetRast_ line with "WCls 2" to see
- ; ; the bug in WCls!Look at the top line of the window...
- ; ; ...it's still grey!
-
- ; a.b=WFBox{0,-1,-1,-1,-1} ; a is False if it's failed...
-
- ; ; I don't understand the parameters,but -1 for all is nice!
-
- ; MouseWait:End
-
- ;----------------------------------------------------------------
-
- .StripFile
-
- ; function : StripFile{}
-
- ; returns the file part of a path & file string,eg from a
- ; reqtools file requester or an appicon...
-
- Function$ StripFile{p$}
-
- *fileptr.l = FilePart_(&p$)
- f$=Peek$(*fileptr)
-
- Function Return f$
- End Function
-
- ; demo :
-
- ; MaxLen f$=192 ; needed for RTEZLoadFile
- ; FindScreen 0 ; same here
-
- ; a$=RTEZLoadFile("Select file",f$)
- ; If a$="" Then End
-
- ; Request "","The file part of "+a$+"|is : "+StripFile{a$},"OK"
- ; End
-
- ;-----------------------------------------------------------------
-
- .LockReq
-
- ; function : LockReq{}
-
- ; locks calling window,puts up requester - standard Request
- ; (reqtype=0) or RTEZRequest (reqtype=1)
-
- ; RTEZRequest does lock the window normally,but if the window
- ; is closed during the program,then re-opened,sometimes the
- ; requesters fail to lock! hence this function ;)
-
- ; of course,you need to have a screen in use to call either
- ; Request or RTEZRequest...
-
- ; tl$=title
- ; rq$=body text
- ; gd$=gadget text (as normal - separate more than one gadget
- ; with "|",eg "OK|Cancel" )
- ; reqtype=0 for Request,1 for RTEZRequest
-
- Function.l LockReq{tl$,rq$,gd$,reqtype.b}
-
- lock.l=RTLockWindow (Used Window)
-
- If reqtype
- rtrq.l=RTEZRequest (tl$,Replace$(rq$,"|",Chr$(10)),gd$)
- Else rtrq.l=Request (tl$,rq$,gd$)
- EndIf
-
- If lock
- RTUnlockWindow Used Window,lock
- EndIf
-
- Function Return rtrq
- End Function
-
- ; demo:
-
- ; WBenchToFront_:FindScreen 0
- ; Window 0,0,0,640,200,$140f,"LockReq Demo - this window is locked!",1,2
- ; CatchDosErrs
- ; rt.l=LockReq{"Title","Body text","OK|Quit|Cancel",1}
- ; Print "Gadget pressed : ",rt
- ; MouseWait:End
-
- ;-----------------------------------------------------------------
-
- .GTGetStr
-
- ; function : GTGetStr{}
-
- ; use this to get the contents of a string gadget - works
- ; on WBs < 3.0 too!
-
- Function.s GTGetStr{lst.w, gdt.w}
-
- *gad.Gadget = GTGadPtr(lst, gdt)
- *si.StringInfo = *gad\SpecialInfo
- a$= Peek$(*si\_Buffer)
- Function Return a$
- End Function
-
- ; demo :
-
- ; FindScreen 0
- ; Window 0,0,0,180,60,$140a,"<- Click to End",1,2
- ; GTString 0,51,35-WLeftOff,5-WTopOff,100,20,"...and press Enter!",$8,50
- ; AttachGTList 0,0
-
- ; GTSetString 0,51,"Type here!"
-
- ; loop
-
- ; Select WaitEvent
- ; Case $200
- ; End
- ; Case $40
- ; r$=GTGetStr{0,51}
- ; ^ ^
- ; | |
- ; | l gadget number
- ; |
- ; l gadget List
-
- ; Request "Info","The gadget says : "+r$,"OK"
- ; End Select
-
- ; Goto loop
-
- ;-----------------------------------------------------------------
-
- .GTGetInt
-
- ; function : GTGetInt{}
-
- ; ; use this to get the contents of an integer gadget - works
- ; on WBs < 3.0 too!
-
- Function.l GTGetInt{lst.w, gdt.w}
- *gad.Gadget = GTGadPtr(lst, gdt)
- *si.StringInfo = *gad\SpecialInfo
- a.l = *si\LongInt
- Function Return a
- End Function
-
- ; demo :
-
- ; FindScreen 0
- ; Window 0,0,0,180,60,$140a,"<- Click to End",1,2
- ; GTInteger 0,51,50-WLeftOff,20-WTopOff,70,20,"Enter a number :",$4,0
- ; AttachGTList 0,0
-
- ; loop
-
- ; Select WaitEvent
- ; Case $200
- ; End
- ; Case $40
- ; number.l=GTGetInt{0,51}
- ; ^ ^
- ; | |
- ; | l gadget number
- ; |
- ; l gadget list
-
- ; Request "Info","The gadget says : "+Str$(number),"OK"
- ; End Select
-
- ; Goto loop
-
- ;-----------------------------------------------------------------
-
- .ProgDir
-
- ; function : ProgDir{}
-
- ; returns a string with the program's directory.
-
- ; IMPORTANT! Only works with compiled executables,as
- ; Compiling & Running doesn't use a directory (obviously ;)
-
- ; only work with CLI-run programs :(
-
- Function$ ProgDir{}
-
- lok.l=GetProgramDir_()
-
- If lok
- *stringbuffer = AllocMem_(255, 0)
- n.l=NameFromLock_ (lok, *stringbuffer, 255)
-
- If n
- lockname$ = Peek$(*stringbuffer)
- Function Return lockname$
- Else Request "Info","Couldn't get directory name!","Oh..."
- EndIf
-
- UnLock_(lok)
-
- Else Request "Info","Error locking directory!","Oh..."
- EndIf
-
- End Function
-
- ; demo :
-
- ; a$=ProgDir{}
-
- ; Print a$
- ; MouseWait:End
-
- ;-----------------------------------------------------------------
-
- .CurrentDir
-
- ; function : CurrentDir{}
-
- ; returns a string with the current directory name
- ; only work with CLI-run programs :(
-
- Function$ CurrentDir{}
-
- *stringbuffer = AllocMem_(255, 0)
- suc.l=GetCurrentDirName_(*stringbuffer,255)
-
- If suc
- cdirname$=Peek$(*stringbuffer)
- Function Return cdirname$
- Else Request "Info","Couldn't get current directory name!","Oh..."
- EndIf
-
- End Function
-
- ; demo :
-
- ; a$=CurrentDir{}
-
- ; Print a$
- ; MouseWait:End
-
- ;-----------------------------------------------------------------
-
- .ProgName
-
- ; function : ProgName{}
-
- ; returns a string with the program's DOS name
-
- Function$ ProgName{}
-
- *stringbuffer = AllocMem_(255, 0)
- suc.l=GetProgramName_(*stringbuffer,255)
-
- If suc
- progname$=Peek$(*stringbuffer)
- Function Return progname$
- Else Request "Info","Couldn't get name of program!","Oh..."
- EndIf
-
- End Function
-
- ; demo :
-
- ; a$=ProgName{}
-
- ; Print "Program name : "+a$
- ; MouseWait:End
-
- ;-----------------------------------------------------------------
-
- .ParentDir
-
- Function$ ParentDir{dir$}
-
- ; function : ParentDir{}
-
- ; returns a string with the parent directory of a given directory...
- ; only work from CLI-run programs :(
-
- *lok.l=Lock_(&dir$,#ACCESS_READ)
-
- If *lok
- *newlock.l=ParentDir_(*lok)
-
- If *newlock
- *stringbuffer = AllocMem_(255, 0)
- n.l=NameFromLock_ (*newlock, *stringbuffer, 255)
-
- If n
- lockname$=Peek$(*stringbuffer)
- Function Return lockname$
- EndIf
-
- UnLock_ (*newlock)
-
- EndIf
-
- UnLock_(*lok)
-
- EndIf
-
- End Function
-
- ; demo :
-
- ; d$="Sys:Devs/DosDrivers"
- ; Print ParentDir{d$}
- ; MouseWait:End
-
- ;-----------------------------------------------------------------
-
- .SetComment
-
- ; function : SetComment{}
-
- ; tries to write a file comment to the specified file
-
- ; (the comment appears in the Comment section when you look
- ; at a file's icon using the Icon/Information menu item
- ; from Workbench)
-
- ; returns True if it's successful,False if it fails
-
- Function SetComment{fname$,comment$}
- a.l=SetComment_ (&fname$,&comment$)
- Function Return a
- End Function
-
- ; demo :
-
- ; filename$="ram:t" ; adds a comment to the Ram:T drawer
-
- ; If SetComment{filename$,"Hello,I'm a comment!"}=True
- ; Request "","Done it! Now click on the file's icon|and go to the WB Icons/Information menu...","OK"
- ; Else Request "","Failed to write comment!","Doh!"
- ; EndIf
-
- ; End
-
- ;----------------------------------------------------------------
-
- .Memory
-
- ; function : Memory {}
-
- ; returns size of largest block of available memory -
- ; use these flags :
-
- ; $0 Any type of memory (0)
- ; $1 Public (1)
- ; $2 Chip (2)
- ; $4 Fast (4)
- ; $100 Local (256)
- ; $200 DMAable (512)
- ; $400 KickTags (1024)
- ; $20000 Largest chunk (131072)
- ; $80000 Total memory (524288)
-
- Function.l Memory{flag.l}
- Function Return AvailMem_(flag)
- End Function
-
- ; demo :
-
- ; NPrint Memory {$100} ; $100 from the table above is Chip mem...
- ; MouseWait:End
-
- ;----------------------------------------------------------------
-
- .CheckLib
-
- ; function : CheckLib {}
-
- ; checks library versions...
- ; throw it at the start of your code,then do...
-
- ; getit.l=CheckLib {"some.library",version}
-
- ; where "some.library" is the library you need to check for,
- ; and version is the version number you need (0 if it doesn't
- ; matter)...
-
- ; just repeat that call for each library you need...
-
- ; use SnoopDos to see if your program requires a particular
- ; version,otherwise you can often just use 0...
-
- Function CheckLib {lib$,libv.l}
-
- opened.b=0
-
- *pplib.l=OpenLibrary_(&lib$,libv.l)
-
- If *pplib
- opened=1
- CloseLibrary_ *pplib
- EndIf
-
- Function Return opened ; it didn't want to return *pplib properly!
-
- End Function
-
- ; demo :
-
- ; FindScreen 0
-
- ; lib$="reqtools.library" ; library to check for,
- ; libv.b=38 ; version number needed.
-
- ; If CheckLib {lib$,libv}=0 Then Request "ERROR!","You need "+lib$+" v"+Str$(libv)+"!","Abort":End
-
- ; End
-
- ;----------------------------------------------------------------
-
- .PixelLen
-
- ; function : PixelLen${}
-
- ; returns the number of pixels in width required to print
- ; the requested string
-
- Function.w PixelLen{a$}
- rp.l=RastPort(0) ; The rastport of the used window.
- Function Return TextLength_(rp,&a$,Len(a$))
- End Function
-
- ; demo :
-
- ; FindScreen 0
-
- ; If Window (0,0,0,640,200,$40f,"",1,2)=0 Then Request "","Window too wide!","END":End
-
- ; a$="Some Pixels" ; use this text
- ; pix.w=PixelLen{a$} ; find pixel width of text
-
- ; ; print information :
-
- ; NPrint ""
- ; NPrint "PixelLen {"+Chr$(34)+a$+Chr$(34)+"} returns a value of : ",pix
- ; NPrint ""
- ; Print " ":WJam 4:NPrint a$
- ; NPrint ""
- ; WJam 0:NPrint "So "+Chr$(34)+a$+Chr$(34)+" is ",pix," pixels wide in this WindowFont."
- ; NPrint "":NPrint "-----------------------------------------------------------------"
-
- ; ; demo part 2 :
-
- ; a$="Lots and lots and lots and lots and lots and lots and lots and lots and lots and lots of text"
-
- ; ; try taking out a couple of "and lots" to make it fit!
-
- ; NPrint "":NPrint a$
-
- ; If PixelLen {a$}>InnerWidth
- ; NPrint "":NPrint "The string above is too wide!"
- ; Else NPrint "":NPrint "Yep,that string fits!"
- ; EndIf
-
- ; Repeat
- ; VWait 5
- ; Until Event=$200
- ; End
-
- ;----------------------------------------------------------------
-
- .StripToDot
-
- ; function : StripToDot{}
-
- ; I use this in a program to strip file extensions off...
- ; eg. doing StripToDot{"reqtools.library"} would return
- ; just "reqtools"...
-
- Function$ StripToDot{a$}
-
- For a.w=Len(a$) To 1 Step -1
- If Mid$(a$,a,1)="." Then a$=Left$(a$,a-1):Pop For:Goto senditback
- ; if it found a dot,puts result into b$,goes to senditback label below
- Next a
-
- senditback
- Function Return a$
- End Function
-
- ; demo :
-
- ; Print "Enter a string with an extension (eg help.txt) : "
- ; a$=StripToDot{Edit$(25)}
- ; NPrint "":Print "New name : ",a$
- ; NPrint "":NPrint "Click the mouse to end..."
- ; MouseWait:End
-
- ; demo 2 :
-
- ; ; I use it along with StripFile{} to just return
- ; ; the file part of a path & file (eg "Work:Pics/Amiga.iff"
- ; ; will be returned as "Amiga"...
-
- ; a$=StripToDot{ StripFile{"Work:Pics/Amiga.iff"} }
- ; NPrint a$:MouseWait:End
-
- ;----------------------------------------------------------------
-
- .Quoted
-
- ; function : Quoted{}
-
- ; puts quotes around a file name,so that if your user has
- ; entered a file name containing spaces,it'll still be OK...
-
- ; useful for some file requester returned strings,or appicons...
-
- Function$ Quoted{a$}
-
- a$=Chr$(34)+a$+Chr$(34)
-
- Function Return a$
- End Function
-
- ; demo :
-
- ; Print "Enter a file name containing spaces : "
- ; f$=Edit$(30)
- ; NPrint "":NPrint Quoted{f$}
- ; ; Execute_ "ppmore "+Quoted{f$},0,0 ; try copying a text file into ram and typing Ram Disk:textfile.txt (or name of your file)
- ; MouseWait:End
-
- ;----------------------------------------------------------------
-
- Request "statements&functions.bb2","You can't just run this!","Oh...":End
- ; just in case ;)
- .
- .USEFUL_STUFF
- .
- ;----------- BEGINNING of Carl's WBFONT ROUTINE -----------------
-
- ; Reading the Workbench font prefs file...
-
- ; this is cut straight out of a demo by Carl Read,and requires
- ; a little more effort to cut 'n' paste into your programs :
-
- ; 1) Put the FindFont{} function at the top of your source,
-
- ; 2) Put the "LoadFile" subroutine OUT OF THE MAIN LOOP of
- ; your program,so you don't accidentally run into it!
- ; * * * * * * ^^ That's IMPORTANT!!!!! ^^ * * * * * * *
-
- ; 3) Paste in the "ReadFonts" routine to get the Workbench
- ; fonts information (see "demo").
-
- ; I've left it uncommented,as it would be a bit of a pain
- ; to have to uncomment it all to paste it in ;)
-
- ; Over to Carl ;)
-
- ; This function searches for a font name in a string and will
- ; return a pointer to it (in the string) if found, else it'll
- ; return 0. If found fontName$ will hold the font name and
- ; fontSize its size.
-
- Function.l FindFont{fontPrefs$,startPos.l}
- SHARED fontName$,fontSize
- fontName$="":fontSize=0
- fontPointer.l=Instr(fontPrefs$,"FONT",startPos)
- If fontPointer
- For fontName.l=fontPointer+36 To Len(fontPrefs$)
- a$=Mid$(fontPrefs$,fontName,1)
- If Asc(a$)
- fontName$+a$
- Else
- If Exists("sys:fonts/"+fontName$)
- fontSize=Cvi(Mid$(fontPrefs$,fontPointer+32,2))
- fontPointer+36
- EndIf
- fontName=Len(fontPrefs$)
- EndIf
- Next
- EndIf
- Function Return fontPointer
- End Function
-
- ;----------------------------------------------------------------
-
- ReadFonts
-
- ; Get user-defined fonts if they exist.
- fi$="ENV:sys/font.prefs":fiLen.l=Exists(fi$)
- If fiLen
- ; Load in WB3 (I think) font names. (1 file.)
- Gosub LoadFile
- Else
- ; Load in WB2 (I think) fonts names. (3 files.)
- fi$="ENV:sys/wbfont.prefs":fiLen.l=Exists(fi$)
- If fiLen Then Gosub LoadFile ; Icon font.
- fi$="ENV:sys/sysfont.prefs":fiLen.l=Exists(fi$)
- If fiLen Then Gosub LoadFile ; System font.
- fi$="ENV:sys/screenfont.prefs":fiLen.l=Exists(fi$)
- If fiLen Then Gosub LoadFile ; Screen font.
- EndIf
-
- If fontPrefs$<>""
- fontPointer.l=FindFont{fontPrefs$,1}
- If fontPointer
- iconFont$=fontName$:iconFontSize=fontSize
- EndIf
- If fontPointer
- fontPointer.l=FindFont{fontPrefs$,fontPointer}
- If fontPointer
- systemFont$=fontName$:systemFontSize=fontSize
- EndIf
- EndIf
- If fontPointer
- fontPointer.l=FindFont{fontPrefs$,fontPointer}
- If fontPointer
- screenFont$=fontName$:screenFontSize=fontSize
- EndIf
- EndIf
- EndIf
-
- ;----------------------------------------------------------------
-
- ; I've left this demo activated,to avoid having to comment
- ; out the LoadFile part of this routine below (cos YOU'D have
- ; to uncomment it all - see,I care! no,really.... ;)
-
- ; demo :
-
- ; To load the fonts in use by Workbench :
-
- LoadFont 0,iconFont$,iconFontSize
- LoadFont 1,systemFont$,systemFontSize
- LoadFont 2,screenFont$,screenFontSize
-
- info$="Icon font : "+iconFont$+", Size : "+Str$(iconFontSize)
- info$=info$+"|System font : "+systemFont$+", Size : "+Str$(systemFontSize)
- info$=info$+"|Screen font : "+screenFont$+", Size : "+Str$(screenFontSize)
-
- Request "",info$,"Cool"
-
- End
-
- ;----------------------------------------------------------------
-
- LoadFile
-
- ; this is the subroutine called by the "ReadFonts" routine :
-
- ; This routine adds to the string fontPrefs$ the file fi$ of
- ; length fiLen.
- err=0
- SetErr:err=-1:End SetErr
- If err=0
- If ReadFile(0,fi$)
- FileInput 0
- fontPrefs$+Inkey$(fiLen)
- EndIf
- EndIf
- CloseFile 0
- DefaultInput
- ClrErr
- Return
-
- ;------------ END of Carl's WBFONT ROUTINE ----------------------
-
-