Pragma Directives

From Real Software Documentation

Jump to: navigation, search
Method

Used to suspend and/or override actions to improve code execution times, issue warnings or error messages, and change/modify other normal operations. When a pragma directive is used to disable an automatic task, the task remains off until the end of the method in which it is called (or is enabled by calling it again and specifying True)), but not in other methods that might be called within the original method.


Syntax

#pragma Directive
OR
#pragma Directive True or False

Directive Description
BackgroundTasks
Introduced 5.0
Enables or disables auto-yield to background threads.

In addition to the pragma directive, specify True or False. Setting this directive to False is the same as using DisableBackgroundTasks.

BoundsChecking
Introduced 5.0
Enables or disables bounds checking.

In addition to the pragma directive, specify True or False. Specifying False is the same as using DisableBoundsChecking.

BreakOnExceptions
Introduced 2009r2
Used to override the BreakOnExceptions menu item in the IDE. The possible values are: On, Off, and Default. BreakOnExceptions also accepts the values of True and False. They are equivalent to On and Off.
DisableAutoWaitCursor Used to disable the automatic display of the wait cursor (or watch cursor).

The scope of this pragma is local. The wait cursor will be disabled in the method that calls the pragma until the method ends. For example, if DisableAutoWaitCursor is called in a Pushbutton that runs a loop, the wait cursor will be disabled only until the loop runs and the Action event has completed.

DisableBackgroundTasks Used to disable calls to the framework inside of loop iterations to see if it needs to switch threads or perform other tasks (such as polling the debugger socket in a debug build). It is specific to the scope the pragma is in and does not affect other methods you may call from your method. It also does not disable preemptive thread switching in the OS itself.

Using this pragma can speed up very processor-intensive operations.

DisableBoundsChecking Used to turn off array bounds checking on array index values in code after the #pragma.
Error
Introduced 2008r4
Used to generate an error manually, i.e.,
#Pragma Error "stringLiteral".
NilObjectChecking
Introduced 5.0
Controls whether to automatically check objects for Nil before accessing properties and calling methods.

In addition to the pragma directive, specify True or False.

StackOverflowChecking
Introduced 5.0
Controls whether to check for stack overflows.

In addition to the pragma directive, specify True or False.

Unused VariableName

New in 2008r5

Controls whether Analyze Project will test for the passed unused variable. VariableName can be a local variable, method parameter, or event parameter. You must pass the variable or parameter you do not want to test. The pragma can be used only after the variable has been declared. Also, you cannot pass a list of variables. Use a separate #pragma statement for each variable. You can also turn off checking within the Issues pane by clicking the Type Filter button In the Issues toolbar and deselecting the checks for unknown local variable, method parameter, or event parameter.
Warning
Introduced 2008r4
Used to issue a warning manually, i.e.,
#Pragma Warning "stringLiteral".
X86CallingConvention
Introduced 2005R5
Accepts either StdCall or CDecl, not True or False. Allows you to determine which calling convention a method will be compiled with on x86.

This allows you to write callback functions on Windows, which typically require the StdCall calling convention.

Notes

Four pragma directives require that you pass True or False to turn the option on or off. Since these pragmas can be enabled or disabled, you can now do things like disable background tasks for an inner loop, but leave them enabled for the outer loop:

For y = 0 To Height
#pragma BackgroundTasks False
For x = 0 To Width
//...process some pixels...
Next
#pragma BackgroundTasks True
Next


The following example shows how the BreakOnExceptions pragma can be used to turn off the feature for a particular code snippet.

#pragma BreakOnExceptions Off
Try
Dim f as FolderItem
f.visible = True
Catch err as NilObjectException
end Try
// Reset to its default state
#pragma BreakOnExceptions Default
Personal tools