Hey guys, simple question...
Working with XLISP to write a program, but I've seemed to run into a simple fundamental problem that I can't seem to work around: perhaps someone has a quick fix.
I'm trying to write an if statement who's then-clause evaluates multiple forms and returns the value of the last.
In example:
(setq POSITION 'DINING-ROOM)
(defun LOOK (DIRECTION ROOM) ... )
(defun SETPOS (ROOM) ... )
(defun WHERE () ... )
(defun MOVE (DIRECTION)
(if (not(equal nil (LOOK DIRECTION POSITION))) ; If there is a room in that direction
( ; Then-block: Go to that room. Return where you are.
(SETPOS (LOOK DIRECTION ROOM))
(WHERE)
)
( ; Else-block: Return error
(list 'CANT 'GO 'THERE)
)
)
The logical equivalent intended is:
function Move (Direction)
{
if(Look(Direction, Room) != null)
{
SetPos(Look(Direction,Room));
return Where();
}
else
{
return "Can't go there";
}
}
(Apologies for the poor web-formatting.)
The problem I have is with:
(
(SETPOS (LOOK DIRECTION ROOM))
(WHERE)
)
I simply want to return the evaluation of WHERE, but I need to execute the SETPOS function first. XLISP doesn't like the extra parentheses: if I remove the outer set, my WHERE list becomes my else (I don't want that). If I remove the sets around SETPOS and WHERE, it treats WHERE like an argument for SETPOS; I also don't want that.
So, how do I simply evaluate the first, then the second and then return the values of the last evaluated?