mxmora@unix.SRI.COM (Matt Mora) (11/10/90)
I'm trying to get the newline mode to work with PBread but I am having no luck. in IM it states: "Note: Advanced programmers: Bit 7 of ioPosmode is the newline flag; it's set if read operations should terminate at a newline character. The ASCII code of the newline character is specified in the high-order byte of ioPosMode. If the newline flag is set, the data will be read, one byte at a time unitl the newline character is encountered, ioReqCount bytes have been read, or the end-of-file is reached." This is what I tried : posmode := $0D00; {set the highorder byte to CR } BitSet(@PosMode, 0); {set bit 7 } while error = noerr do begin with myPB do begin ioCompletion := nil; ioRefNum := refnum; ioBuffer := buf^; ioReqCount := 100; {set to 100 because CR is before 100 bytes } ioPosMode := PosMode; {in the test file } end; error := PBRead(@mypb, false); After the read, myPB.ioActCount = 100 and buf is filled with 100 bytes of data. What the hell am I doing wrong? Thanks -- ___________________________________________________________ Matthew Mora | my Mac Matt_Mora@sri.com SRI International | my unix mxmora@unix.sri.com ___________________________________________________________
urlichs@smurf.sub.org (Matthias Urlichs) (11/10/90)
In comp.sys.mac.programmer, article <18094@unix.SRI.COM>,
mxmora@sri-unix.sri.com (Matt Mora) writes:
< I'm trying to get the newline mode to work with PBread
< but I am having no luck. [...]
<
< This is what I tried :
<
< posmode := $0D00; {set the highorder byte to CR }
< BitSet(@PosMode, 0); {set bit 7 }
Now posmode will end up being set to $8D00, which is probably not what you
want. Replace these two lines with
posmode := $0D80;
and it should work.
--
Matthias Urlichs -- urlichs@smurf.sub.org -- urlichs@smurf.ira.uka.de /(o\
Humboldtstrasse 7 - 7500 Karlsruhe 1 - FRG -- +49+721+621127(0700-2330) \o)/
russotto@eng.umd.edu (Matthew T. Russotto) (11/11/90)
In article <18094@unix.SRI.COM> mxmora@sri-unix.sri.com (Matt Mora) writes: >I'm trying to get the newline mode to work with PBread >but I am having no luck. in IM it states: > >"Note: Advanced programmers: Bit 7 of ioPosmode is the newline flag; >it's set if read operations should terminate at a newline character. The >ASCII code of the newline character is specified in the high-order byte of >ioPosMode. If the newline flag is set, the data will be read, one byte at a >time unitl the newline character is encountered, ioReqCount bytes have been >read, or the end-of-file is reached." > >This is what I tried : > >posmode := $0D00; {set the highorder byte to CR } I think you also need to add FSFromStart. > BitSet(@PosMode, 0); {set bit 7 } Nope. This sets the wrong bit. This sets bit 15, not 7. Try PosMode := bor(PosMode, $0080); if you have 'bor'. (BitSet is inefficient). If you don't, BitSet(@PosMode, 8); ought to do it. -- Matthew T. Russotto russotto@eng.umd.edu russotto@wam.umd.edu Tax the rich, and feed the poor -- until there are, rich no more.
oster@well.sf.ca.us (David Phillip Oster) (11/13/90)
In article <1990Nov10.193723.19603@eng.umd.edu> russotto@eng.umd.edu (Matthew T. Russotto) writes: >In article <18094@unix.SRI.COM> mxmora@sri-unix.sri.com (Matt Mora) writes: >>but I am having no luck. in IM it states: >>"Note: Advanced programmers: Bit 7 of ioPosmode is the newline flag; >>it's set if read operations should terminate at a newline character. The >>ASCII code of the newline character is specified in the high-order byte of >>ioPosMode. If the newline flag is set, the data will be read, one byte at a >>time unitl the newline character is encountered, ioReqCount bytes have been >>read, or the end-of-file is reached." This is the easy way: posmode := $0D80; {set the highorder byte to CR } { and the newLine flag all in one go } Note: One of the blinding stupidities of the Macintosh is that newLine mode is NOT implemented by the serial driver, so you can't get the operating system to directly simulate unix line mode i/o (yes you can do it, but it isn't built-in.) -- -- David Phillip Oster - Note new signature. Old one has gone Bye Bye. -- oster@well.sf.ca.us = {backbone}!well!oster