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!
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.
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
...