michaelh@neon.Stanford.EDU (Mike Hennahane) (04/09/91)
I'm trying to send commands to a driver installed in memory at startup. My code works fine in the THINK pascal environment, but when I compile it into a CODE resource (so that I can call it as an external command from 4th Dimension) it bombs miserably (application unexpectedly quit (1)). The only thing that I can think of is that opening and closing the driver is changing something global that 4D needs. My question: does my code change anything global that would bomb a host application if called as a CODE resource? (I'm not supposed to do anything that relies on the A5 register or change anything like the grafport, unless I put it back when I'm done...) Thank you if you can offer ANY help or leads. Please respond via email, since I'm struggling too much with this to have time to read this group... :-) mike hennahane michaelh@neon.stanford.edu ------code follows---------- unit sendToMIC; {R-} interface function main (var theCommand: str255): str255; implementation function main (var theCommand: str255): str255; var result: OSErr; MICRefNumber: integer; command, return, temp: str255; count: longint; begin result := OpenDriver('.MIC2', MICRefNumber);(* open driver *) command := concat(theCommand, chr(13)); (* append a CR *) count := length(command); result := FSWrite(MICRefNumber, count, @command[1]);(* write *) return := ''; repeat count := 64;(* try to read as much as buffer holds *) result := FSRead(MICRefNumber, count, @temp[1]);(* read *) temp[0] := chr(count); (* set pascal length byte *) return := concat(return, temp); (* concat to what we have *) until (result = eofErr); (* eofErr signals end of return *) result := CloseDriver(MICRefNumber); (* close driver when done *) main := return; (* assign return to var param *) end; end.