Problems using FRAMEWORK command

BlitzMax Forums/BlitzMax Programming/Problems using FRAMEWORK command

Scaremonger(Posted 2007) [#1]
I'm afraid I have to admit I have something I cannot understand...

How do I use Framework?

I have a sample module...
Module itspeedway.test
'
Import Brl.linkedlist
Import brl.retro
'
ModuleInfo "Author: Si Dunford"
'
Function testmodule$()
Return "Hey its ok"
End Function

The module works fine like this:
Framework itspeedway.test
Print testmodule()

But when I try to use graphics, I get an error, 'Unhandled Exception: Attempt to access field or method of Null object' in module Brl.Max2d - SetBlend()
Framework itspeedway.test
Import brl.max2d
Graphics 800 , 600
SetBlend(ALPHABLEND)
DrawText( testmodule(), 0,0 )

Is there a module I should be including that initialises the graphics object?


Gabriel(Posted 2007) [#2]
Looks like you haven't imported an implementation of Max2D. Max2D is just a generic 2d engine with no renderer implemented. Graphics defaults to DX now, I guess, so you would also need to

Import brl.d3d7max2d


Does that do it?

EDIT: Fixed sleepy typo.


Scaremonger(Posted 2007) [#3]
I get the error Compile Error: Expecting identifier but encountered Mod.

I think I see what you are saying. I have to select DirectX etc with the appropriate module...

I tried, this but it failed too.
Import brl.dxgraphics



popcade(Posted 2007) [#4]
Try to scan your module with Framework Assistant and see what's required?


tonyg(Posted 2007) [#5]
Take out the hard work and use the excellent FrameWork Assistant


Gabriel(Posted 2007) [#6]
Sorry, still half asleep. I meant to type

Import brl.d3d7max2d



tonyg(Posted 2007) [#7]

Sorry, still half asleep. I meant to type


Import brl.d2d7max2d


Should really be listening to the half that's awake as it *IS* brl.d3d7Max2d. :-)


Gabriel(Posted 2007) [#8]
Should really be listening to the half that's awake as it *IS* brl.d3d7Max2d. :-)

Yes it is, but that's not what I typed originally either ;)

I fixed up the first message and then typoed again when adding a reply :P


Scaremonger(Posted 2007) [#9]
Framework assistant says I need:
Framework BRL.GLMax2D
Import itspeedway.test

or
Framework BRL.D3D7Max2D
Import itspeedway.test


Does that mean mine cannot be a framework?


tonyg(Posted 2007) [#10]
I have no idea why the code you've posted is expecting Pub.win32 and BRL.Win32MaxGui. Does it compile OK if you take them out?
When I run FA against
Framework itspeedway.test
Import brl.max2d
Graphics 800 , 600
SetBlend(ALPHABLEND)
DrawText( testmodule(), 0,0 )

it returns :
Framework BRL.GLMax2D

or
Framework BRL.D3D7Max2D

You can then use the compiler directives to make the code x-platform


Scaremonger(Posted 2007) [#11]
Thanks, the Win32 bit was my mistake. I ran Fa against the wrong source file...


tonyg(Posted 2007) [#12]
I've never really known the real difference between Framework and Import so I came up with an explanation which I'm happy with.
Some modules provide a 'basic template' as they import a number of modules themselves. This means you don't have to specify all the imported modules individually.
These would be your starting 'framework'.
However, on top of the framework, you might need some additional function. These are not necessary for the template and would cause .exes to be larger than necessary so BRL have made them 'optional'. These are your imports.
That's my guess anyway.
Your module *can* be a framework if you want it to be.
It's whether it will be used a a base template or as additional function is the question.


Gabriel(Posted 2007) [#13]
Posted 2 days ago? I knew I was sleepy, but I had no idea I'd dozed off for 2 days there.

The only real difference between Framework and Import is that Framework says Import blah ( and don't import anything else. ) where as Import just says import this ( plus whatever else you have lying around. )

Framework is to stop all the standard BRL modules you're not using being imported anyway. The alternative, I guess, would be to never import modules unless you ask for them, but that's a lot less beginner friendly, so I think the chosen way is best.


H&K(Posted 2007) [#14]
Hello Peeps
Gab, this
The only real difference between Framework and Import is that Framework says Import blah ( and don't import anything else. ) where as Import just says import this ( plus whatever else you have lying around. )
Is this true of Moduals. Because I dont use framework in a mod import If you see what I mean ;)


Gabriel(Posted 2007) [#15]
No, it's not true of modules. Modules can't "see" any BRL module commands unless you explicitly import the module.