Re: Inform: Disappointment in new manual


26 Nov 1995 21:01:17 GMT

"Sam Hulick" <shulick@guava.ucs.indiana.edu> wrote:
> Basically, I made my own file, library/myutils.h which has a default
> help menu. In case I ever distribute this .h file, I allow the user
> to define a CreditRoutine() for the game credits. If it's not defined
> anywhere,it won't be included in the menu. How can I achieve this
> effect?

Use the `Ifdef' directive:

[ menu;
! code here is always compiled
#Ifdef CreditRoutine;
! code here is compiled if CreditRoutine is defined
#Else;
! code here is compiled if CreditRoutine is not defined
#Endif;
];

Note that this requires CreditRoutine to be defined before your library
is included.

Another possibility is to pass the address of CreditRoutine as an
(optional) parameter:

[ menu creditroutine;
if (creditroutine == 0) {
! do something
} else {
! do something else
}
];

and then in the code that calls `menu':

menu(#r$CreditRoutine);

-- 
Gareth Rees