Skip to content

#CHECK Compiler Directive

Purpose

#Check checks the validity of an identifier against a list of type-checking characters.

Syntax

#Check {symbol} {type-list}

Argument Explanation

  • symbol: The identifier that you wish the compiler to check.
  • type-list: The list of type-checking characters that the {symbol} is tested against (see below).

What It Does

You may check the type and class of a symbol with the #Check command. #Check will generate an error message if the type or class of the symbol is not in the {type-list}.

#Check is intended for type error checking. Both use negative logic: an error will be generated if the type or class of {symbol} matches one of the type check characters in the {type-list} (see Symbol-Checking Characters below).

Symbol Checking Characters

Types

Character Meaning
S String
N Number
D Date
I Integer
E Expression
# Indicator (obsolete)
X Not an indicator (obsolete)
O Group options {}
B Group indicators {} (obsolete)
L Label

Classes

Character Meaning
c Constant
f File element
w Window (obsolete)
v Variable
G Group {options} or {indicators}

Literal Content

Character Meaning
"" Any characters in quotes. An error will be generated if the value of the argument does not match one of the strings in the quotes.

Others

Character Meaning
t Error if typed (defined)
U Error if untyped
R Argument required
. No more arguments
% Special: Changes constant number to constant integer
$ Special: Changes all windows to type string
& Special: For macros that don't call other macros

These characters are case sensitive. They work only when CAPITALIZED.

Example

An example of the #Check compiler directive is:

#Check iCount LGFCU

This example would declare a compile-time error if the symbol iCount is a label, group, file element, constant, or is untyped.

The order of the type check characters has no significance. Examples of using macros can be found in many of the package files.

Internal Information

The following information is intended for those interested in the internal workings of the macro processor and is not required to use DataFlex. These symbols are placed in the compiled program file.

Each symbol, whether constant, window, or file, is #Replaced from its symbolic name in the program source code to one that is meaningful to the DataFlex runtime system. These symbols can be identified by a vertical bar "|" in the first character of the replacement symbol. The next two characters represent the class and type of the symbol. If the symbol is a constant, the final characters are its value. If it is a field, the final characters are the file and field numbers, separated by a comma. If it is a window, the final characters are its sequential number among the windows of the program.

  • |CN0 means CONSTANT, NUMBER, Value 0
  • |WS2 means WINDOW, STRING, Window Number 2
  • |CI1 means CONSTANT, INTEGER, Value 1
  • |CS'USA' means CONSTANT, STRING, Value USA
  • |WN3 means WINDOW, NUMERIC, Window Number 3
  • |FD2,1 means FIELD, DATE, File 2, Field 1

The characters used to identify type and class in symbols are the same as those shown above in the table of Symbol-Checking Characters for types and classes.