Path: utzoo!attcan!uunet!munnari.oz.au!uniwa!vax7!nlewispn From: Lewis_P@cc.curtin.edu.au (Peter Lewis) Newsgroups: comp.sys.mac.programmer Subject: Re: Free Inc/Decrement routines in Pascal Message-ID: <4121.271e1381@cc.curtin.edu.au> Date: 18 Oct 90 12:41:36 GMT References: <1990Oct17.205801.2454@fennel.cc.uwa.oz.au> Organization: Curtin University of Technology Lines: 38 In article <1990Oct17.205801.2454@fennel.cc.uwa.oz.au>, a_dent@fennel.cc.uwa.oz.au writes: > G'day all Pascal programmers who handle pointer arithmetic. I recently did a > job in which I became heartily sick of writing: > aPtr:=ptr(ord4(aPtr)+1); > > so - here's a unit full of increment and decrement functions and procedures, > for Integer, Ptr and Longint type variables. Just stick in your project and > enter ptrTools in your 'uses' clause. > > [...] > > unit ptrTools; > > [lots of functions] > procedure incL (var l: longint); > [lots of functions/procedures] > procedure incP (var p: ptr); By using a little known feature of THINK Pascal v2.0,v3.0, as well as in MPW Pascal, these and many of the other routines can be combined to procedure inc(var l:UNIV longint); using exactly the same inline codes as describe previously. The UNIV qualifier turns off type checking for that parameter, as long as the sizes are the same. This also means that any pointer can be passed, irrespective of what it points to (you don't have to cast it to a PTR). Note that since UNIV turns off type checking it should be used with caution. Have fun, Peter & Darko. Disclaimer:Curtin & I have an agreement:Neither of us listen to either of us. *-------+---------+---------+---------+---------+---------+---------+-------* Internet: Lewis_P@cc.curtin.edu.au I Peter Lewis ACSnet: Lewis_P@cc.cut.oz.au I NCRPDA, Curtin University Bitnet: Lewis_P%cc.curtin.edu.au@cunyvm.bitnet I GPO Box U1987 UUCP: uunet!munnari.oz!cc.curtin.edu.au!Lewis_P I Perth, WA, 6001, AUSTRALIA "!thgir s'ti naem t'nseod yaw taht ti seod enoyreve esuaceb tsuJ"