Types In use with Module Functions

BlitzMax Forums/BlitzMax Programming/Types In use with Module Functions

KrayzBlu(Posted 2006) [#1]
I'm trying to create a module for text effects that uses an object for each letter. The text effects are all part of a module, and the letter's methods use functions from the rest of the module, so they have to be in the same file. :(Nasty Loop)

Unfortunately, the compiler won't seem to let me create a object from a module function (Unable to convert from '<unknown>' to 'Letter' in the line 'local l:Letter = new letter'. Does anyone have any advice on the situation?

Thanks,
KrayzBlu


tonyg(Posted 2006) [#2]
You'll need to post some code.


Dreamora(Posted 2006) [#3]
Thats very bad OO design. If the functions are used on letters only, then they should be part of the letter class and not an external thing.

Thats exactly against what classes are actually for: Encapsulating code into its objects.


KrayzBlu(Posted 2006) [#4]
Thats very bad OO design. If the functions are used on letters only, then they should be part of the letter class and not an external thing.


Yeah, unfortunately, the function that my methods use are common functions that are used in many other places outside the class.

You'll need to post some code.


Well, to make a long story short....

type letter
       field stuff

      method draw()
            stuff = a()
      end method
end type

function a()
        'Do stuff
end function

function b()
        local l:letter = new letter      '<----- Compiler stops here
        l.stuff = 2
end function




FlameDuck(Posted 2006) [#5]
Yeah, unfortunately, the function that my methods use are common functions that are used in many other places outside the class.
In which case they should be part of a super class that your letters extend.


Dreamora(Posted 2006) [#6]
Hmm this error does not make much sense ... At least as long you have nothing else called letter that might interfere ... did you try renaming the class to something different like TLETTER and check that?


KrayzBlu(Posted 2006) [#7]
try renaming the class to something different


Of all things... :/

Thanks for your help everyone,
KrayzBlu