Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!swrinde!sdd.hp.com!hplabs!hpda!hpcuhc!hpcupt3!defaria@hpcupt3.cup.hp.com From: defaria@hpcupt3.cup.hp.com (Andy DeFaria) Newsgroups: comp.lang.pascal Subject: Re: passing two variables Message-ID: <45670024@hpcupt3.cup.hp.com> Date: 24 Jun 91 22:35:26 GMT References: <1991Jun21.144356.19598@javelin.sim.es.com> Organization: Hewlett Packard, Cupertino Lines: 44 >/ hpcupt3:comp.lang.pascal / tpehrson@javelin.sim.es.com (Tim Clinkenpeel) / 7:43 am Jun 21, 1991 / >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); I'll take a stab here. Assuming that the function name checkvalid is to indeed check if something is valid then why not: function checkvalid (var parm1 : integer; var parm2 : integer) : boolean; Then you could: if not checkvalid (foo, bar) then begin writeln ('Error has occured'); halt end; else { Other processing } This allows you to return a result specifying whether things are OK as well as modify the parameters. Ah I see where your probably having problems! You trying to pass an expression and the compiler doesn't allow var parameters to be expressions - it want a bonified variable that it can modify. You'll need to: var cx : integer; cy : integer; cxnew : integer; cynew : integer; begin ... cxnew := cx + offset; cynew := cy + offset; if checkvalid (cxnew, cynew) then { process } else writeln ('Error');