I have finally gotten around to writing this. Pairs arise in SCI in several contexts, both as x,y coordinates and as far text references, but in the stock SCI language there is no such thing as a pair. However, the PMachine can be coerced into returning pairs of values from functions. Since it is a hack, you need to stow the values away immediately (and in the right order), but it can be done. This bit of code was written for the original compiler, since the Companion compiler tends to get stuck in an animation loop trying to resize the messages window; I then hex-edited it to put my hack in place (in Companion you would simply use an asm directive) - the following shows the result of a later decompilation. I therefore haven't tested it with Companion, but I know that my original works:
;;; Sierra Script 1.0 - (do not remove this comment)
(script# 935)
(include sci.sh)
(public
RetPair 0
PairFst 1
PairSnd 2
)
(procedure (RetPair param1 param2)
(== param2 param2)
(return param1)
)
(procedure (PairFst)
)
(procedure (PairSnd &tmp temp0)
(asm
pprev
sst temp0
lat temp0
ret
)
)
You can then do things like:
(procedure (WhosAPair)
(RetPair {Larry} {Patti}))
(procedure (FarTextPair)
(RetPair "This is a far text string"))
and retrieve the results with
(WhosAPair)
(= el1 (PairFst))
(= el2 (PairSnd))
(Printf "Pair (%s, %s)" el1 el2)
(FarTextPair)
(= el1 (PairFst))
(= el2 (PairSnd))
(Printf el1 el2)
I'd like to make the retrieval a bit neater, but that'll have to wait.
EDIT: :'( this does not work in SSCI. Figures. But I consider that a bug in SSCI.