Dexterity Pragma Pre-compiler directives


David Meego - Click for blog homepageMost 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);


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

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

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

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

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) Secure Link

Pragma Option suppress or turn off Dexterity Compiler String Warning Messages (KB 850877) Secure Link

How to write Dexterity source which behaves differently for different versions

 

Hope this information is handy.

David

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

Comments (0)

Skip to main content