Path: utzoo!utgpu!news-server.csri.toronto.edu!rutgers!cs.utexas.edu!uunet!philmtl!altitude!pascal From: pascal@altitude.CAM.ORG (Pascal Gosselin) Newsgroups: comp.sys.mac.programmer Subject: Re: Converting COMP to EXTENDED to STRING Keywords: SANE CONVERSION FUNCTION PASCAL MPW Message-ID: <1990Jul23.221417.24424@altitude.CAM.ORG> Date: 23 Jul 90 22:14:17 GMT References: <1990Jul22.180337.17771@altitude.CAM.ORG> <1861@krafla.rhi.hi.is> Distribution: comp Organization: None Lines: 58 aries@rhi.hi.is (Reynir Hugason) writes: >>FUNCTION Number2Str(var ExtendedNumber:Extended):DecStr; > ^^^ >Your headache lies in the VAR part of your function declaration. The >Pascal compiler can easily transform an INTEGER or a COMP to an >Extended, but transforming an EXTENDED to an INTEGER is a bit harder >than that. If that's what you want to do you'll have to use SANE's >Num2Integer or Num2Comp. >--- >Mimir (aries@rhi.hi.is) - Aries, Inc. No, I am trying to convert COMP to EXTENDED and INTEGER TO EXTENDED. I then take the EXTENDED and convert it into a STRING. I have the function working right now, but in the following formats.... FUNCTION Comp2Str(var CompNumber:Comp):DecStr; .... add code here for conversion... etc.... and to covert from Integer to the string.... FUNCTION Integer2Str(var IntegerNumber:Integer):DecStr; ... again, code to do the conversion.... I find it bothersome to have to code a function for EVERY type of REAL (integer,real,longint,comp,extended) since the MPW Pascal 3.0 manual states the following: Page 326, Appendix G The SANE Library "Remember that any function with a formal parameter of any real types can be passed a value of any realinteger type. Floating-point value parameters in MPW3.0 Pascal will accept expressions and variables of the following types: Integer,longit,real(single),double,comp or extended. We abbreviate the list with the term numeric argument in the explantory text below." Now, I figure that this means that you can pass just about anything to a function of the form FUNCTION Convert(var x:extended):real; ... Right? I AM returning a string from the function, but I can't see why the compiler would complain of an "Invalid parameter substitution" whenever my program passes an Integer or Comp value to it.... Still searching for an answer.... -- +--------------------------------------------------------------------+ | Pascal Gosselin | Internet: pascal@altitude.CAM.ORG | | Gest-Mac Inc. Apple VAR | (514) 939-1127 CIS: 72757,1570 | +--------------------------------------------------------------------+