#Define

Prev Next Home Home Table Of Contents Index

#Define (Name)

MarxMenu supports conditional compilation. This allows you to hide or unhide sections of code from MarxComp based on defining key control words using the #Define command. Defining a name sets it to true and this lets you control what code the MarxMenu compiler sees when it is compiling your menu. Multiple names can be defined on one line.

By using #If, #Else, and #Endif, MarxMenu lets you control the code the compiler produces. Unlike If, Else, and Endif, these new commands are evaluated at compile time rather than run time. Thus, it allows you to produce smaller and faster runtime code.


Example:

#Define A B

#If A #Define C #If B Writeln 1 #Else Writeln 2 #Endif #Else #If B Writeln 3 #Else Writeln 4 #Endif #Endif

#If C Writeln 'C' #Endif

The #Define command supports referrences to environment variables. This allows you to control what is compiled based on the environment variables you have set. That way you can, for example, compile different code based on what fileserver you are on. This allows you to compile smaller and faster menus. Suppose you have an environment variable set for the file server name SERVER=BOSTON:


Example:
#Define %Server% #If Boston ... #Endif

If the environment variable is set to a value that contains multiple words separated by spaces, then all the words will be defined.


Example:
SET USERS=TOM DICK HARRY Your menu contains: #Define %Users% This causes TOM, DICK, and HARRY to be defined.

See Also: #If

Category: Conditional

Prev Next Home Home Table Of Contents Index

Sponsors
Shopping
Forum
Forum
email
EMail
Index
Index
Home
Home