GLBasic forum

Main forum => GLBasic - en => Topic started by: jessejohnston on 2010-May-08

Title: Return variable type?
Post by: jessejohnston on 2010-May-08
Would there be a way to return a variable type?

I would like to write a function to free the memory of a varaible
Title: Re: Return variable type?
Post by: Schranz0r on 2010-May-10
Variable type?

do you meen somethink like that:
Code (glbasic) Select
TYPE MyType
   a;b;c
ENDTYPE

GLOBAL _MyType[] AS MyType

...

FUNCTION MyFunction AS MyType: a, b, c
   LOCAL t AS MyType
   
   t.a = a
   t.b = b
   t.c = c

   DIMPUSH _MyType[],t
   RETURN t
ENDFUNCTION


or you meen:

FUNCTION Bla$

or

FUNCTION Bla%

or

FUNCTION Bla#

?

:)
Title: Re: Return variable type?
Post by: bigsofty on 2010-May-10
Quote from: jessejohnston on 2010-May-08
Would there be a way to return a variable type?

I would like to write a function to free the memory of a varaible

What type of variable are you referring to that needs memory freed?
Title: Re: Return variable type?
Post by: jessejohnston on 2010-May-11
Thanks for the replies

Yes, I need something like a "TypeOf(variablename)" type function
Title: Re: Return variable type?
Post by: codegit on 2010-May-11
If you trying to achieve reflection with GLBASIC, it is going to be difficult but I suppose not impossible.  ;/ IE: If you are trying to find the type of a TYPE(object) during runtime.
Title: Re: Return variable type?
Post by: Kitty Hello on 2010-May-13
what would you need the TYPEOF operator for?
Title: Re: Return variable type?
Post by: Hemlos on 2010-May-16
Quote from: jessejohnston on 2010-May-08
Would there be a way to return a variable type?

I would like to write a function to free the memory of a varaible

Variables are stored as strings or numerals, and likewise inside a TYPE.
Thus, to free the memory of a variable you simply do this:

a$=""
a=0