Path: utzoo!utgpu!watmath!iuvax!pur-ee!pur-phy!murphy From: murphy@pur-phy (William J. Murphy) Newsgroups: comp.lang.pascal Subject: Re: function returning a record? Message-ID: <2016@pur-phy> Date: 1 Mar 89 14:03:04 GMT References: <2012@pur-phy> <790@rpi.edu> Reply-To: murphy@newton.physics.purdue.edu.UUCP (William J. Murphy) Organization: Purdue Univ. Physics Dept., W. Lafayette, IN Lines: 34 In article <790@rpi.edu> fargo@pawl.rpi.edu (Ethan M. Young) writes: >It's not that Turbo Pascal won't allow you to return a record, it's that your >method was slightly off. Try this: > >FUNCTION Complex_Add(z1,z2 : complex) : comples; > >VAR > temp : complex; { Temporary variable } > >BEGIN > temp.x := z1.x + z2.x; > temp.y := z1.y + z2.y; > Complex_Add := temp; >END; > >The method you were using wouldn't work as the function returns a record, but >is not itself a record. Thus, using the '.' operator on it is invalid. Though I understand what you are getting at, a posting just previous to yours points out that the function may not be anything other than simple types and pointers. So what that means is that your solution is still not a solution. In Fact, before posting this, I tried what you suggested with Turbo Pasacl 4.0 and it correctly barfs and gags on the declaration of the function as complex. The error message for this problem correctly points out that you cannot declare a function as returning anything other than simple types and pointers. In light of the conversation in this group a few weeks ago about splitting the group into PC/Turbo Pascal and others, I wished to get an answer to this question (above) in the broader scope of knowledge about Pascal. The only Pascal compiler I use is Turbo Pascal. Bill Murphy murphy@newton.physics.purdue.edu