Determing data type of passed parameter (*?)

This question popped up on the newsgroup today and it is something I have seen asked from time to time and the solution is quite straight forward. I always forget to make a note of it though and figured this was an opportunity. With permission from Mike, here is his implementation as posted to comp.lang.clarion:

Since this is a public gist, any comments or suggestions please let me know and I will update the gist or we can move it to a github repo or whatever. If you have your own implementation please share it as well!

1 Like

Hi Brahn,

Is there any chance of the equates/group types being in the gist.

Things the compiler is not happy about:

  1. All return type.
  2. gVariant
  3. _SAFEArray

Thanks

Mark,

The code posted here is used to determine VARIANT subtype (this is for COM manipulations). For general purpose change to something like

MAP
  Get_Type(*BYTE),LONG
  Get_Type(*SHORT),LONG
  !.. and so on
END

Get_Type                      PROCEDURE(*BYTE pVar)
  CODE
  RETURN DataType:BYTE

Get_Type                      PROCEDURE(*SHORT pVar)
  CODE
  RETURN DataType:SHORT

see Equates.clw for all possible DataType constants.

2 Likes

By the way, provided code doesn’t answer the question how to “Determine data type of passed parameter (*?)”. It can help, for example, in a template like this:

#if (%x=1)
v   BYTE(10)
#else
v  STRING('Hello')
#endif

CASE Get_Type(v)
OF DataType:BYTE
...
OF DataType:STRING
...