Passing datatype ? (Solved)

General FreeBASIC programming questions.
fxm
Posts: 9132
Joined: Apr 22, 2009 12:46
Location: Paris suburbs, FRANCE

Re: Passing datatype ?

Postby fxm » May 07, 2019 14:50

I meant that this works:

Code: Select all

type BASEOBJECT extends OBJECT
'    declare abstract function MySize() as integer
end type

type UDT1 extends BASEOBJECT
    declare function MySize() as integer
    as integer _dummy(1 to 1000)
end type
function UDT1.MySize() as integer
    #print typeOf(THIS)
    return sizeOf(THIS)
end function

dim as UDT1 uu
? sizeOf(BASEOBJECT)
? sizeOf(uu)
? uu.MySize()
ppf
Posts: 38
Joined: Oct 10, 2017 6:41

Re: Passing datatype ?

Postby ppf » May 11, 2019 8:13

Code rewritten, example here updated too.
After playing with real program and my example here with, recognized not accurate design.
I do 2 in 1 step, setup gamelevel array and select fileread parameters; too simplified.
Now that ones are separated, looks much better.
Fileread parameters are in one array, gamelevels in another.Now I know directly by index,
what a buffer (variable, type, its pointer etc.) is selected.
Gamelevel sauce is more not important.
Added creation of test files (one record all) and testprint routine to show members of buffer.
Remains to solve core of the problem - read routine (random access) with one Get command.
(this question moved to new topic)

Seems I can mark this topic as solved, because here are 3 ways :
a) using 'Typeof'
b) using 'Is' in OOP version
c) rewtiting code to get direct definition of used type of variable by index, e.g. from array
of used types

Really thank you all for your help here !

Return to “General”

Who is online

Users browsing this forum: No registered users and 2 guests