One of the frustrations I have with BASIC! is managing the display modes.. I can't keep track of what's open and closed. These functions I made today do a lot of the work with some limitaions. You first call dinit() to initialize it to console mode then whenever you want to change a mode you do dmode(m$) where m$=console, html or gr.. It's a little messy because it uses the file mode.txt to keep track of the current setting and things will get screwed up if you use any open or close commands outside of it.
Still a nice thing about it is that it will automatically close the old mode, open the new one or not bother if it's the same. Seems to work pretty well so far.
! change display mode to console, html or gr(aphics) fn.def dmode(m$) if m$="console" then m=0 if m$="html" then m=1 if m$="gr" then m=2
oldm=val(readln$("mode.txt")) if val(readln$("mode.txt"))=m fn.rtn m endif writeln("mode.txt",int$(m)) if oldm=1 html.close endif if oldm=2 gr.close endif if m=1 html.open 0 pause 500 endif if m=2 gr.open 255,0,0,0,0 pause 500 endif fn.end
Another thing you might want to do is trap for errors with ONERROR:
ONERROR: dmode("console") err$ = "The following error occurred: "+CHR$(10) err$ += GETERROR$() DIALOG.MESSAGE , err$, q, "OK" EXIT
Joined: Wed Oct 03, 2012 9:53 am Posts: 2776 Location: Colorado, U.S.
Ah, I see. Sorry.
Would it be useful to have a command that tells you the current mode? To fix bugs in v01.88 I had to add a ContextManager that does approximately what your program does -- not to set modes but to keep track of them.
! change display mode to console,html or gr(aphics) FN.DEF dmode(m$) bundle.get 1,"mode",oldm$ IF oldm$=m$ THEN FN.RTN 0 bundle.put 1,"mode",m$ IF oldm$="html" then HTML.CLOSE IF oldm$="gr" then GR.CLOSE IF m$="html" THEN HTML.OPEN 0 IF m$="gr" then GR.OPEN 255,0,0,0,0,1 pause 300 FN.END
Users browsing this forum: No registered users and 1 guest
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot post attachments in this forum