Bug? Typeface within Type generates runtime error

Gary Milne

Active Member
Licensed User
Longtime User
Code: Copy
Sub Process_Globals
    'These global variables will be declared once when the application starts.
    'These variables can be accessed from all modules.
    Type ButtonProperties(btnBold As Typeface, btnNormal As Typeface, OnColor As Int, OffColor As Int )
    Dim BP As ButtonProperties

    BP.btnBold=Typeface.CreateNew(Typeface.MONOSPACE,Typeface.STYLE_ITALIC)
    BP.btnNormal=Typeface.CreateNew(Typeface.SANS_SERIF,Typeface.STYLE_NORMAL)
    BP.OnColor=Colors.Green
    BP.OnColor=Colors.Red
End Sub

No other code required.

Try and run this and you get the error below.

Screen Shot 2014-07-09 at 9.33.31 AM.png

I conclude that you can't place a Typeface within a Type but I would expect it to generate a warning if that were the case vs getting a runtime error.

Easy enough to workaround but not as clean.
 
Thanks Erel. Did not have to do that for all of the other variables but I'm sure it's good practice.
 
Back
Top