DTYPE E K
Use DTYPE to determine the data type of a column or constant (E), and store the results in a constant (K).
Values returned by DTYPE:
0 = text
1 = real numbers
2 = integers
3 = date/time
10 = empty
DTYPE is often used with free variables (and the MFREE and MTYPE commands) in cases where the macro must be flexible enough to respond to a variety of possible inputs.
DTYPE is very useful when parts of your macro only work on some types of data. For example, you may have a subcommand of your local macro that lets the user specify a title for a graph; DTYPE can tell you if the user specified a text string or a number. Or, perhaps a part of your macro requires an integer; DTYPE could tell you if a variable was not an integer, allowing your macro to convert the real number to an integer.
Note |
DTYPE only works as a command. It does not work with IF or LET, for example. |
TELLDATA tells a user the data type of the variable specified when the macro is invoked. Here is the complete code:
MACRO
TELLDATA X
MFREE X
MCONSTANT Vartype
DTYPE X Vartype
IF Vartype = 0
NOTE Variable is text
ELSEIF Vartype = 1
NOTE Variable is real number
ELSEIF Vartype = 2
NOTE Variable is integer
ELSEIF Vartype = 3
NOTE Variable is date/time
ELSEIF Vartype = 10
NOTE Variable is empty
ENDIF
ENDMACRO