Topic 3.5

Compile Commands

Looking into Compile Time Instructions

Compile Cmds

All commands beginning with an exclamation point (!) are compile time commands which means they're processed at compile time; long before your program can execute (which is also refered to as at runtime). So all commands starting with an exclamation point are mostly used to tell the compiler which lines are okay to compile through certain conditions. Let's look at the following code snippet.

;= Reads AppInfo.ini for version information.
;= Sets ${PACKAGE_VERSION} to hold the value of whatever 'PackageVersion' is.
!searchparse /noerrors /file ${PACKAGE}\App\AppInfo\appinfo.ini `PackageVersion=` PACKAGE_VERSION

;= The following will compile only if certain conditions are met.
	!if ! ${PACKAGE_VERSION} == ""
		VIProductVersion	${PACKAGE_VERSION}
		VIAddVersionKey /LANG=${LANG_ENGLISH} FileVersion      ${PACKAGE_VERSION}
		!error "The key 'PackageVersion' in AppInfo.ini needs a value! (i.e."
	!error "The key 'PackageVersion' in AppInfo.ini is missing!"

Okay, lets walk you through what's going on in the above code; line 4 just reads AppInfo.ini for the application's version number. This is only executed as the compiler is running. Remember, commands with ! are not used in the finished executable file's codebase. Next, line 8 tells the compiler if ${PACKAGE_VERSION} is defined then compile all the intructions inside the !ifdef statement, which ends at line 15 with the !else statement. If it is defined (which it should be if the key exists from line 4) and it's not empty (line 9) then compile lines 10 and 11. Otherwise, compile line 13 which stops the compiler with an !error command. Finally, if ${PACKAGE_VERSION} wasn't defined then compile line 16 which, like line 13, throws an error and stops compiling.