Author |
Topic: Meters-displays (Read 1415 times) |
|
DDRM
Administrator
member is offline


Gender: 
Posts: 321
|
 |
Re: Meters-displays
« Reply #5 on: Jun 19th, 2012, 08:28am » |
|
Hi Richard,
I didn't mean to imply that you had involved the offset capabilities - I thought it was obvious that they were still there. I was just commenting that I didn't use ORIGIN instead so that I didn't affect the outside frame of reference (too much - of course playing with the font and colours does to some extent).
Agreed, my use of *FONT was unsatisfactory. Again, I was trying to avoid affecting the environment too much by changing the font, and fell between two stools. Looking through HELP now, I see you provide a function to find out what it is, so I could do this on entry, and then restore it on exit... though I note that won't give the size to set.
@vdu%216 and 220: I had thought this was a fixed characteristic of the MODE when it was defined, and that changing the font would mean the letters painted wouldn't match the spec, but I see from trying now that they are altered - that's really useful - if, as you say, you use a non-proportional font...
Best wishes,
D
|
|
Logged
|
|
|
|
admin
Administrator
member is offline


Posts: 1145
|
 |
Re: Meters-displays
« Reply #6 on: Jun 20th, 2012, 08:11am » |
|
on Jun 19th, 2012, 08:28am, DDRM wrote:| I was just commenting that I didn't use ORIGIN instead so that I didn't affect the outside frame of reference |
|
Well, if you look you'll see that my only use of ORIGIN is in the 'main program' (which represent's the end-user's code), so if anything it demonstrates that the 'meter' procedures aren't affected by, and don't affect, the "outside frame of reference" in that respect.
Quote:| (too much - of course playing with the font and colours does to some extent). |
|
Indeed. You could consider borrowing the code in the MULTIWIN.BBC library, which saves-and-retores the current VDU state fairly 'completely'.
Richard.
|
|
Logged
|
|
|
|
JGHarston
Junior Member
member is offline


Gender: 
Posts: 52
|
 |
Re: Meters-displays
« Reply #7 on: Jul 18th, 2012, 1:38pm » |
|
on Jun 19th, 2012, 08:28am, DDRM wrote:| Agreed, my use of *FONT was unsatisfactory. |
|
You could use the following subroutine which will attempt to select a font, and the tell you if it was successful so that you can make another attempt if it wasn't: Code: REM Font_Select - Attempt to select a font, returns non-zero if failed
REM ------------------------------------------------------------------
REM Returns FALSE if font not selected
:
DEFFNFont_Select(font$)
LOCAL face%,face$:DIM face% LOCAL 31
SYS "CharUpperBuff", !^font$, LEN font$
OSCLI"FONT "+font$
SYS "GetTextFace", @memhdc%, 32, face%:face$=$$face%
SYS "CharUpperBuff", !^face$, LEN face$
font$=LEFT$(font$,INSTR(font$+",",",")-1)
=font$=face$
: Then you can do things like: IF FNFont_Select("Transport")=0 THEN A%=FNFont_Select("Ariel")
If the specified font is the null string "" then the WINBBC font is selected. This is always available to BBC BASIC for Windows programs and so can always be used as a fall-back font, for example: IF FNFont_Select("Courier")=0 THEN A%=FNFont_Select("")
|
|
Logged
|
|
|
|
admin
Administrator
member is offline


Posts: 1145
|
 |
Re: Meters-displays
« Reply #8 on: Jul 21st, 2012, 9:59pm » |
|
on Jul 18th, 2012, 1:38pm, JGHarston wrote:IF FNFont_Select("Transport")=0 THEN A%=FNFont_Select("Ariel") |
|
Ariel is a character in Shakespeare's The Tempest, a moon of Uranus, and the name of the BBC's in-house staff magazine. As far as I know there isn't a font of that name (although there is a font called Arial).
Richard.
|
|
Logged
|
|
|
|
RayRayTea
New Member
member is offline


Posts: 7
|
 |
Re: Meters-displays
« Reply #9 on: Aug 6th, 2012, 1:07pm » |
|
on Jun 18th, 2012, 11:59am, Richard Russell wrote:A couple of comments on your code, if I may.
…
A version with these and a few other changes made is as follows:
Code: MODE 8
ORIGIN 640,512
COLOUR 128+4
CLS
OFF
px% = 0
py% = 0
radius% = 300
PROCdrawspeedo(px%,py%,radius%)
FOR x% = 0 TO 1256
PROCupdatespeedo(px%,py%,radius%,200*ABS(SIN(x%/200)),x%)
WAIT 2
NEXT x%
END
;
DEFPROCdrawspeedo(cx%,cy%,r%)
LOCAL x%,px%,py%,a,s$
GCOL 0
CIRCLE FILL cx%,cy%,r%
GCOL 15
CIRCLE cx%,cy%,r%
VDU 5
FOR x% = 0 TO 200 STEP 10
s$ = STR$(x%)
a = RAD(250-x%*1.5)
px% = cx%+r%*0.9*COS(a)
py% = cy%+r%*0.9*SIN(a)
MOVE px%-LEN(s$)*@vdu%!216,py%+@vdu%!220
PRINT s$;
NEXT x%
VDU 4
ENDPROC
;
DEFPROCupdatespeedo(cx%,cy%,r%,s%,d%)
LOCAL s$
PRIVATE erase%, olds%
s$ = STR$(d%)
GCOL 3,1
VDU 23,23,2;0;0;0;
IF erase% THEN
a = RAD(250-olds%*1.5)
LINE cx%+r%*0.2*COS(a),cy%+r%*0.2*SIN(a),cx%+r%*0.8*COS(a),cy%+r%*0.8*SIN(a)
ENDIF
a = RAD(250-s%*1.5)
LINE cx%+r%*0.2*COS(a),cy%+r%*0.2*SIN(a),cx%+r%*0.8*COS(a),cy%+r%*0.8*SIN(a)
GCOL 0
RECTANGLE FILL cx%-8*@vdu%!216,cy%-@vdu%!220,16*@vdu%!216,2*@vdu%!220
GCOL 15
MOVE cx%-LEN(s$)*@vdu%!216,cy%+@vdu%!220
VDU 5
PRINT s$;
VDU 4
olds% = s%
erase% = TRUE
ENDPROC |
|
If I try to just copy, paste and run this code, the compiler automatically picks up all the instances of "radius" and attempts to interpret it as part of "rad" (makes sense)… so it produces a Syntax Error and I can't run it unless all instances of "radius" are changed to whatever non-keyword ("rdius" or"rds", for example).
So how come it works for you – I assume you tested it before posting, so it should have produced an error on your end too, or is there a setting in IDE that I'm missing :)
|
|
Logged
|
|
|
|
admin
Administrator
member is offline


Posts: 1145
|
 |
Re: Meters-displays
« Reply #10 on: Aug 6th, 2012, 3:31pm » |
|
on Aug 6th, 2012, 1:07pm, RayRayTea wrote:| If I try to just copy, paste and run this code, the compiler automatically picks up all the instances of "radius" and attempts to interpret it as part of "rad" |
|
It sounds as though you have the Lowercase Keywords option set. That is non-standard for BBC BASIC (all versions apart from BB4W force you to use capitals for keywords) and since most users don't set that option you will find many programs listed that are not compatible with it.
If you want to ensure that all programs you find listed on the web and elsewhere run, disable the Lowercase Keywords option. That is the default setting on installation and it will ensure maximum compatibility with other versions of BBC BASIC.
Richard.
|
|
Logged
|
|
|
|
RayRayTea
New Member
member is offline


Posts: 7
|
 |
Re: Meters-displays
« Reply #11 on: Aug 7th, 2012, 03:08am » |
|
Right that was it – no idea how it ended up turned on though, must have been a mistake. Thanks!
|
|
Logged
|
|
|
|
|