Return variable type?

Previous topic - Next topic

jessejohnston

Would there be a way to return a variable type?

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

Schranz0r

#1
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#

?

:)
I <3 DGArray's :D

PC:
AMD Ryzen 7 3800X 16@4.5GHz, 16GB Corsair Vengeance LPX DDR4-3200 RAM, ASUS Dual GeForce RTX™ 3060 OC Edition 12GB GDDR6, Windows 11 Pro 64Bit, MSi Tomahawk B350 Mainboard

bigsofty

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?
Cheers,

Ian.

"It is practically impossible to teach good programming style to students that have had prior exposure to BASIC.  As potential programmers, they are mentally mutilated beyond hope of regeneration."
(E. W. Dijkstra)

jessejohnston

Thanks for the replies

Yes, I need something like a "TypeOf(variablename)" type function

codegit

#4
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.
------------------------------------------
1 X Acer TravelMate 4270, laptop, XP PRO
1 X Dell Studio 17 laptop, Windows 7
1 X MacBook Pro 2,2 GHz Core 2 Duo, 2 GB RAM, 160 GB HDD, 9400M
2 X iTouch
1 X HTC Desire (Android 2.1)
iPad soon to be added

Kitty Hello

what would you need the TYPEOF operator for?

Hemlos

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

Bing ChatGpt is pretty smart :O