Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!samsung!olivea!uunet!math.fu-berlin.de!fub!geminix.in-berlin.de!tertius.in-berlin.de!gaertner From: gaertner@tertius.in-berlin.de Newsgroups: comp.lang.pascal Subject: Re: passing two variables Message-ID: <1991Jun24.175745.6594@tertius.in-berlin.de> Date: 24 Jun 91 17:57:44 GMT References: <1991Jun21.144356.19598@javelin.sim.es.com> <1991Jun21.175817.339@maytag.waterloo.edu> Lines: 46 In article <1991Jun21.175817.339@maytag.waterloo.edu>, dmurdoch@watstat.waterloo.edu (Duncan Murdoch) writes: > 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 A clearer solution would be PROCEDURE checkvalid ( offset1, offset2 : INTEGER ; { pure input } VAR inout1, inout2 : INTEGER { input/output} ) ; with the call checkvalid ( offset1, offset2, cx, cy ) ; Refering to the original question: Pascal exspects a variable on the left side of an assigment, so there will never be a construct like x,y := expression ; In Algol 60 (and I think in C) it is possible to have a list of variables on the left side of an expression, but note that these variables would get the same value and not different values. Ralf -- Ralf Gaertner gaertner@venus.rz-berlin.mpg.de FHI Berlin