Author |
Topic: Meters-displays (Read 1416 times) |
|
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
|
|
|
|
|