Author Topic: Type as a parameter to a function?  (Read 2020 times)

Offline backspace

  • Mr. Drawsprite
  • **
  • Posts: 53
    • View Profile
Type as a parameter to a function?
« on: 2012-Dec-28 »
Is it possible to pass a "type" variable as a parameter to a function?
I came, I saw, I coded.

Offline hardyx

  • Community Developer
  • Prof. Inline
  • ******
  • Posts: 504
    • View Profile
Re: Type as a parameter to a function?
« Reply #1 on: 2012-Dec-28 »
Example for pass a person type to a function:

Code: (glbasic) [Select]
TYPE TPerson
   name$
   age%
ENDTYPE

FUNCTION IsAdult: per AS TPerson
    RETURN per.age >= 18
ENDFUNCTION
« Last Edit: 2012-Dec-28 by hardyx »

Offline backspace

  • Mr. Drawsprite
  • **
  • Posts: 53
    • View Profile
Re: Type as a parameter to a function?
« Reply #2 on: 2012-Dec-28 »
I was not familiar with the "AS" keyword. Now I know. lol
Noobs have to start somewhere, and they will "try it themself" when they have learned how !!!
Thank you.
« Last Edit: 2012-Dec-28 by backspace »
I came, I saw, I coded.

Offline matchy

  • Prof. Inline
  • *****
  • Posts: 1545
    • View Profile
Re: Type as a parameter to a function?
« Reply #3 on: 2012-Dec-30 »
Noobs have to start somewhere...

No need to devalue yourself but you are asking the right questions.