Contents | Index | < Browse | Browse >

7.12.  Miscellaneous Routines

     These routines are	placed here for	 lack  of  a  better
place to put them.


$say	( $say str1 str2 ... ) -> No return  value.   Prints
	the messages str1 str2 ... on the screen.  Note	that
	ADL automatically "word-wraps" strings so that	they
	fit  within the	right margin as	closely	as possible.
	Therefore, it is not necessary for the ADL  program-
	mer  to	 take  great care in formatting	the messages
	passed to $say.	 If the	programmer desires that	 the
	current	 line  be  terminated, and output start	on a
	new line, the  character  sequence  "n"  should  be
	embedded  in  the  string.   Note  that	each str may
	actually be an expression such	as  ($name  foo)  or
	($num @Score).

	Example:
		     ($say "Hi!	 My name is " @MyName "! How are you today?n")
		     Note that MyName is assumed to contain a string ID.



$arg	( $arg num ) ->	Returns	the numth  argument  of	 the
	current	 routine.   It is basically the	same as	%num
	except that in	this  case  num	 may  be  a  numeric
	expression,  not  just a numeric constant.  ($arg 0)
	returns	the number of arguments	passed to this invo-
	cation of the current routine.

	Example:
		     { Print all of the	arguments to this routine }
		     ($setg i 1)
		     (WHILE ($le @i %0)	DO
			     ($say "Arg	" @i " = " ($arg @i) "n")
		     )



$exit	( $exit	code ) -> Doesn't return to the	current	rou-
	tine.	$exit  terminates  execution  of the current
	phase.	If code	is 0, control  passes  to  the	next
	phase.	 If  code is 1,	control	passes to the outer-
	most loop.  If code is 2, control passes to the	 top
	of  the	 Dobj loop.  If	code is	3, control passes to
	the parser which attempts to complete a	partial	sen-
	tence.	 See the diagram in Chapter 4 for a complete
	definition.

	Example:
		     take(PREACT) =
			     (IF ($ne ($loc @Dobj) ($loc .ME)) THEN
				     ($say "You	don't see that here!n")
				     { Skip the	rest of	the phases }
				     ($exit 1)
			     )
		     ;
		     safe(ACTION) =
			     (IF ($eq @Verb take) THEN
				     ($say "You	can't budge the	safe.n")
				     { Go on to	the rest of the	Dobjs }
				     ($exit 2)
			     )
		     ;
		     ball(ACTION) =
			     (IF ($prop	ball BROKEN) THEN
				     { Rely on the default verb	ACTION }
				     ($exit 0)
			     )
			     ($say "The	ball bounces nicely.n")
		     ;
		     NOVERB(PREACT) =
			     ($say "What do you	want me	to do with the "
			     ($say ($name @Dobj) "?n")
			     { Re-parse	the sentence }
			     ($exit 3)
		     ;



$return	( $return expr ) -> Doesn't return  to	the  current
	routine.   Evaluates  expr and returns the result to
	the current routine's  caller.	 Note  that  in	 the
	absence	 of an explicit	$return, the return value of
	a routine is the same  as  the	value  of  the	last
	statement executed.

	Example:
		     Increment = ($return ($plus %1 1))

		     ($say "Increment( 3 ) = " (Increment 3) "n")
			     Increment(	3 ) = 4



$val	( $val expr ) ->  Evaluates  expr  and	returns	 the
	result.	  Expr	may be a routine call, a constant, a
	string,	or anything  that  yields  a  16-bit  value.
	This  routine  is most useful in conditional expres-
	sions.

	Example:
		     Signum =
			     (IF ($lt %1 0) THEN
				     ($val -1)
			      ELSEIF ($eq %1 0)	THEN
				     ($val 0)
			      ELSE
				     ($val 1)
			     )
		     ;



$phase	( $phase )  ->	Returns	 the  number  of  the  phase
	currently  executing.	This  number is	0 during the
	START phase, 1 during the Daemon phase,	2 during the
	Actor ACTION, 3	during the Verb	PREACT,	4 during the
	Iobj ACTION, 5 during the Dobj ACTION, 6 during	 the
	Verb ACTION, and 7 during the Room ACTION.

	Example:
			     (IF ($eq ($phase) 2) THEN
				     ($say "This is the	Actor ACTIONn")
			      ELSEIF ($eq ($phase) 4) THEN
				     ($say "This is the	Iobj ACTIONn")
			      ELSEIF ($eq ($phase) 5) THEN
				     ($say "This is the	Dobj ACTIONn")
			     )