Newsgroups: comp.lang.pascal
Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!caen!news.cs.indiana.edu!maytag!watstat.waterloo.edu!dmurdoch
From: dmurdoch@watstat.waterloo.edu (Duncan Murdoch)
Subject: Re: passing two variables
Message-ID: <1991Jun21.175817.339@maytag.waterloo.edu>
Sender: news@maytag.waterloo.edu (News Owner)
Organization: University of Waterloo
References: <1991Jun21.144356.19598@javelin.sim.es.com>
Date: Fri, 21 Jun 1991 17:58:17 GMT
Lines: 21

In article <1991Jun21.144356.19598@javelin.sim.es.com> tpehrson@javelin.sim.es.com writes:
>i would like a function to pass back two variables.  is this possible?  
>below is an example of what i'd like to accomplish:
>
>cx,cy :=checkvalid(cx+offset,cy+offset);

Not in Turbo or Standard Pascal.  The easiest way to do it is to add variables
to receive the results as var parameters, which your function (or it could
be a procedure) can modify.  You have to be a little careful of aliasing,
e.g. a declaration

  procedure checkvalid(var in1,in2:integer;var out1,out2:integer);

would likely get messed up on the call

  checkvalid(cx,cy,cx,cy);

since in1 and out1 would both refer to cx, and in2 and out2 would both refer to
cy.  Passing the input parameters by value (not using var) should work.

Duncan Murdoch
