BASIC

Author Topic: Return variable type?  (Read 1605 times)

jessejohnston

  • Guest
Return variable type?
« 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

Offline Schranz0r

  • Premium User :)
  • Administrator
  • Prof. Inline
  • *******
  • Posts: 5013
  • O Rly?
    • View Profile
Re: Return variable type?
« Reply #1 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#

?

:)
« Last Edit: 2010-May-10 by Schranz0r »
I <3 DGArray's :D

PC:
AMD RYzen 7 1700 @3.9Ghz, 16GB HyperX Fury 2666Mhz Ram, ASUS ROG GTX 1060 STRIX 6GB, Windows 10 Pro 64Bit, MSi Tomahawk B350 Mainboard

Offline bigsofty

  • Community Developer
  • Prof. Inline
  • ******
  • Posts: 2605
    • View Profile
Re: Return variable type?
« Reply #2 on: 2010-May-10 »
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

  • Guest
Re: Return variable type?
« Reply #3 on: 2010-May-11 »
Thanks for the replies

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

Offline codegit

  • Dr. Type
  • ****
  • Posts: 270
    • View Profile
Re: Return variable type?
« Reply #4 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.
« Last Edit: 2010-May-11 by codegit »
------------------------------------------
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

Offline Kitty Hello

  • code monkey
  • Administrator
  • Prof. Inline
  • *******
  • Posts: 10695
  • here on my island the sea says 'hello'
    • View Profile
    • http://www.glbasic.com
Re: Return variable type?
« Reply #5 on: 2010-May-13 »
what would you need the TYPEOF operator for?

Offline Hemlos

  • To boldy go where no pixel has gone before!
  • Global Moderator
  • Prof. Inline
  • *******
  • Posts: 1634
  • Particle Hawk
    • View Profile
Re: Return variable type?
« Reply #6 on: 2010-May-16 »
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

Volume_of_Earth(km^3) = 4/3*3.14*POW(6371.392896,3)