10.2.5.1   Arbitrary Program Code

It is possible to embed arbitrary code into HDevelop programs. This code is ignored inside HDevelop. When you export the program to a programming language, the embedded code is passed through verbatim.

Program lines starting with # as the first character mark an arbitrary code line. The marker and the first space character following it are discarded when exporting the program. For example, the line

# Call MsgBox("Press button to continue",vbYes,"Program stop","",1000)

in HDevelop will result in

Call MsgBox("Press button to continue",vbYes,"Program stop","",1000)

in Visual Basic. The # may be followed by other special characters that further specify where the code block will be placed upon exporting. For example, the line

#^^ #define NO_EXPORT_APP_MAIN

puts the line

#define NO_EXPORT_APP_MAIN

at the very beginning of the exported program. Code lines in this format are collected from the main procedure first, followed by #^^ lines in other procedures.

The recognized special markers are summarized in table 10.1.

If you are using the operator window to enter arbitrary code lines, you will have to select the special operator export_def. Its first parameter specifies the destination of the exported code line (see the last column of table 10.1 for reference). The second parameter is the code line itself. When you submit the operator to the program window, the operator call will be converted to the special prefix characters for better readability.

Prefix Destination export_def

# The place of insertion 'in_place'
#^^ Beginning of the program 'at_file_begin'
#$$ End of the program 'at_file_end'
#^ Before the current procedure 'before_procedure'
#$ After the current procedure 'after_procedure'

Table 10.1: Embedding arbitrary code in HDevelop.