Standard Variable Reference

The following list shows each variable with its name and data type. The r/w column indicates whether the variable can be read (r) or written to (w). Some are are read-only. You are not prevented from altering variables that are specified as read only, and you may be able to achieve special effects by altering some of them. However, there is no guarantee the variables will behave in the same way in future versions of DP4.

Variable name Type r/w Use for Values
abandon_changes Y3 w For a private database, same as selecting Abandon changes on the exit menu Set to TRUE to discard changes
attach_field I3 w Specify a field for attaching a pop-up map (if Field left blank for Attach output method) Field number
break Y3 w Allowing a program that has no input or output to be interrupted Default is FALSE
Set to TRUE to allow interrupts
broken Y3 w Check if network server is running. Application should reset to FALSE to continue TRUE if attempt to access server fails
changed Y3 w Test if a value has been entered, for non clearfirst fields only. (Provided for backwards compatibility.) Set to FALSE before the procedure. TRUE if a value was changed
clock T5 r Obtain current time Time in the format specified in user preferences
commit_frequency I3 w Controlling update frequency Default is 1.
1 = Commit the changes after every update.
10 = Commit the changes after every 10 updates.
dbname U8 r Reading the name of the database being used If DATADB is used, the name returned is of the data database
debug I3 w Set debug level for testing specific procedures. 0 = No debug
decommit Y3 w Same as abandon_changes decommit the changes.  
end_key I3 w Read the value of the last selected function key for Combined menu/entry procedures. Set this variable to select an option 1 = F1
2 = F2
12 = F12
fail_code I3 r Read the result of an attempted update 0 = Successful
3 = Commit failure
5 = Lock failure
field_nr I3 r Read the current field number  
file_name U12 w Read the current output filename. You can set up the filename, provided this is done before printer selection Filename
first_item Y3 r Check if first cycle through a batch procedure TRUE if first time through
first_time Y3 r Same as first_item  
force_option I3 w Forces an option on a menu to be executed Same as the link option number of the procedure
ip_source I3 r Read the number of the subdevice which provided the last input 1−16 for input device
jump Y3 w Check if <Tab> was pressed to move past the current screen. You can set this variable to FALSE to prevent moving past the current screen TRUE if <Tab> pressed (this is set to FALSE at the start of a procedure)
last_return_value I3 r Obtain the return value of the last procedure body 0 = Successful completion,
>0 = Function key or menu selection,
−1 = Escape pressed,
−3 = Record deleted
line_nr I3 r Read the current line number (for pagination in printing programs)  
logged_on Y3 r Checking whether a user is logged on (perhaps via a different DP4 program) TRUE if a user is logged on
math_error_mode I3 w Controlling behaviour on a divide by zero error See pr_error_mode
new_item Y3 r Check if record is a new record (a record is new until it has been posted to and re read from the database) TRUE if new record
next_option I3 w Set up the default menu option for the next menu to be displayed Number of option.
no_grey Y3 r Prevent default greying out of menu options OR with condition to enter for the procedure  
now T5 r same as clock  
option_nr I3 r Obtain the value of the menu option selected in the calling procedure (above the current procedure in the tree)  
output_device I3 w Select output device combination add/subtract device selection 1 = Screen
2 = Printer
4 = File
page_depth I3 r Check page length of current output device  
page_number I3 r Check current page number when printing  
pagewidth I r Page width of print device, as set up in DFSETUP  
pr_error_mode I3 w Set up program response if a printer error occurs Modes: (default is 0)
0 = Report error and terminate
1 = Report error and continue
2 = Ignore error
print_error I3 r Check if print was successful 0 = Successful
<>0 = Unsuccessful
qcheck_flags I3 w Read or modify the flags passed to db_update() in procedures that secure changes 8192 = Reset to previous value on exiting this part of the procedure tree. Other values as specified in dp4dbflg.h . Setting this to 0 will allow a private database program to update the database using a commit() instead of a checkpoint(). This may improve performance considerably, but you need to make sure that it is safe to do so.
qeatfunckeys Y w Control function key shortcuts in QA Build programs If this is TRUE (it is initially FALSE) it prevents a function key that is pressed in once procesure from causing a short cut through a menu in a subsequent procedure. Setting this TRUE can help prevent unexpected behaviour being caused by function keys.
qerror_text1
qerror_text2
C255 r/w Add additional information to QAB error messages

These variables can be used to add custom information to error messages. For example you could add information such as the range of permited values if a validation condition for an entry field verified that the entered value was between two values. (e.g. by using numtochar() to set up Qerror_text1 and Qerror_text2. The custom information of Qerror_text1 is only displayed if the error message has an (output only) edit field or embedded data item numbered 101, and the information for Qerror_text2 is only displayed if field/embedded data item 102 is present. Typically you will set up these variables in field processing just prior to the field with the validation condition. For entry conditions the fields will need to be set up in a prior procedure body.

You can only use these values in messages that are considered to be "error" messages, so they are not displayed in messages such as update/delete confirmation messages, or scan dialogs etc.

These variables were added to 4.623 on May 15th 2008, and are only supported in 32 bit versions of QAB, not in legacy versions.

qexitcode I5 r (From 4.623) Return code from last command run by a "Run another program" procedure body that specifies %WAIT. This variable is NOT set if %WAIT is not specified. On NT based operating systems it is also not set if a 16 bit Windows program is executed.
qhot_fieldnr I3 r Obtain the number of the mapfield processed when the key was pressed >0 = Number of mapfield
<0 = Number of field in a window
qkey_used Y3 w Check if a hot key selected an option. If set, the function key is not passed back to the calling procedure FALSE before the hot key procedure. TRUE if an option was selected
qkill_flags I3 w Check/modify the flags passed to kill() 8192 = Reset to previous value, n Other values as specified in dp4dbflg.h
qmenu_escape_ok Y3 w Check/define whether escape enabled initially set by DFSETUP question Allow user to escape from DP4 menu TRUE = Enable user to escape, FALSE = Disable escape
qpick_flags I4 w (From 4.525/4.621) Modify the flags passed to pick_record() in Window processing. 2048 = NEW_NORMAL. Allows the "New Item" line to be treated like other lines in the Window. Without this flag you cannot select the "New Item" line using a function key.
qpost_flags I3 w Check/modify the flags passed to post() 8192 = Reset to previous value, Other values as specified in dp4dbflg.h
qprdevice I w

Introduced from 4.623. Equivalent to C global variable pr_device. If you set this variable to the device number of one of the devices on the system database prior to a device select/ print procedure that uses the "default printer" device the corresponding printer will be be used to do printing instead of the default printer.

 
qprhotkey I w Hot key option to be executed of check_printer() finds print_error is non-zero with pr_error_mode set to 3  
qprog_description C76 r Obtain the description of the currently running QA Build program or overlay Program description as defined in PROGMAKE
qprog_name U8 r Obtain the name of the currently running QA Build program or overlay Program name as set up in PROGMAKE
qshow_disabled I1 w Modifies appearance of controls that are input fields, but which are currently disabled. Available from 4.622 and as an enhancement for 4.621 If 0, then there is no visible indication a control is disabled.
If 1, then the control's appearance will be updated to show it is not available if the user tries to navigate to it but it cannot be changed because the prevent change flag is set, or an input/output condition is FALSE. The behaviour for qshow_disabled=2 is currently the same as for show_disabled=1, but it is intended that in future QAB will attempt to update the screen whenever the value of an input/output condition changes as a result of user input in an earlier field.
qsmart_position Y3 w Controls how Window access behaves when a non unique secondary index is used. Setting the variable TRUE will usually give better results. qsmart_position is initially FALSE to maintain compatibility with previous releases. If FALSE, then the Window will always highlight the first record with a matching key (assuming there is one)
If TRUE, then the Window will highlight an exactly matching record if there is one, and but fall back on the first matching record if there is no such record.
read_access I3 r Obtain user access level 0 99
return I3 r Same as end_key As for last_return_value
reverse_window Y3 w Reverse the order in which records are displayed in a selection window  
start_date D11 r Date program was loaded  
start_time T5 r Time program was loaded  
sys_clock T5 r Same as clock  
sys_date D11 r Current date Date in format specified in user preferences
there Y3 r Indicates whether the record exists or not for the table containing the field. In a condition on a table, use table.role.there. In the formula for the field, you can use if there then .. TRUE if record exists
today D11 r Same as sys_date  
user_language I3 r Use as an additional key component for storing language specific information on the database Returns the language number currently in use
user_name U8 r Read user name  
write_access I3 r Obtain user write access level 0 99