Dexterity Pragma Pre-compiler directives

David Meego - Click for blog homepageThis is a reposting of an article I originally wrote on my Developing for Dynamics GP blog.

Most Dexterity developers would have seen the pragma(disable warning LiteralStringUsed) command used at some stage to avoid literal string warnings when hard coded strings are needed as part of a script. This can often be the case when building SQL where clauses or pass through SQL, sanScript or macro code.

However this is only one of the pragma pre-compiler directives available. The information below has been “borrowed” from the Dexterity help file. I wanted to highlight the other pragma commands which can be used to remove warnings when they are not needed.

One example I have found useful is when the parameters of a procedure or function are not all used in your trigger handling script.  Using the UnusedVariable pragma can remove the warnings generated.

Pragma reference
The following is a list of the pragmas available to control warnings generated by the sanScript compiler. Each warning can be disabled by the following code:

pragma(disable warning constant);

The warning is re-enabled by the following code:

pragma(enable warning constant);

The LiteralStringUsed pragma setting turns off the warning generated by using literal strings in scripts. The following example shows this setting.

local string error_string;

{Turn off the warning for literal strings}
pragma(disable warning LiteralStringUsed);

error_string = "This is an invalid user name.";

{Turn the literal string warning back on}
pragma(enable warning LiteralStringUsed);

The PossibleInfiniteLoop pragma setting turns off the warning generated when a possible infinite loop is detected.The following example shows this setting.

pragma(disable warning PossibleInfiniteLoop);
while true do

  if 'Result' = true then
    exit while;
  end if;

end while;
pragma(enable warning PossibleInfiniteLoop);

The TypeMismatch pragma setting turns off the warning generated when a possible loss of data is detected when performing assignments. The following example shows this setting.

local integer int_val;
local long long_val;

pragma(disable warning TypeMismatch);

int_val = long_val;

pragma(enable warning TypeMismatch);

The UnusedVariable pragma setting turns off the warning generated when an unused variable or parameter is detected.The following example shows this setting.

local integer unused;

pragma(disable warning UnusedVariable);

Note: The UnusedVariable setting should not be enabled again before the end of the script. It will apply only to the current script. This option is handy when parameters for procedure and function trigger handling scripts are not used.  For trigger handling scripts, you have to match all the parameters even if you don’t use them all.

For more information on handling Literal Strings and other pre-compiler directives and commands see the following articles:

Information about how to handle literal string warnings by using messages in Dexterity in Microsoft Dynamics GP (KB 943178)

How to write Dexterity source which behaves differently for different versions


Hope this information is handy.


02-Feb-2011: Add note about the UnusedVariable setting and trigger handlers scripts for functions and procedures.

This article was originally posted on the Developing for Dynamics GP Blog and has been reposted on

Please post feedback or comments

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.