[comp.sys.mac.programmer] SFGetFile Problems in THINK Pascal 3.0.1

msanford@umaxc.weeg.uiowa.edu (Michael Sanford) (05/02/91)

I am a novice Mac programmer so pardon the simplistic question.  

I am using THINK Pascal 3.0.1 and a want to open a text file.  I use
the SFGetFile procedure however, after I press the cancel button or
open a file I get a system bomb ranging from Illegal Insturction,
Bus Error, and Coprosser not installed.  I am running on a IIci.  
This happens under Finder or Multifinder. HERE's the catch: The program
runs fine under in the interpreter, but bombs in the compiled appliaction.

Suggestions, thoughts, ideas, or comments.  (I have a project due at the
end of the semester, which is next week and I NEED to have it compile
correctly)  HELP PLEASE!
--
+===========================================================================+
| Mike Sanford, University of Iowa, 319-339-1689                            |
| msanford@umaxc.weeg.uiowa.edu                                             |
+===========================================================================+

gtephx (Mike Pflueger) (05/04/91)

In article <5831@ns-mx.uiowa.edu>, msanford@umaxc.weeg.uiowa.edu (Michael Sanford) writes:
> I am a novice Mac programmer so pardon the simplistic question.  
> 
> I am using THINK Pascal 3.0.1 and a want to open a text file.  I use
> the SFGetFile procedure however, after I press the cancel button or
> open a file I get a system bomb ranging from Illegal Insturction,
> Bus Error, and Coprosser not installed.  I am running on a IIci.  
> This happens under Finder or Multifinder. HERE's the catch: The program
> runs fine under in the interpreter, but bombs in the compiled appliaction.

I just encountered a somewhat similar problem, which happens to be shortly
after an SFGetFile - but not after "cancel".  If I say OK, my program then
does a "reset(file, filename);" to open the file read-only. Interactively,
running within THINK Pascal, it works OK.  When built and run as an
application, I get a "runtime error" on the "reset".

I'm not really up on the 680x0 processors, but what i've found so far is
it appears that the return code from some routine THINK adds to my program
(inline code for the "reset" function?) is being tested for a non-zero
result (BNE), and if so, traps to the debugger (Macsbug).  The next
assembler instruction is a trap to ExitToShell. I also recompiled with all
options (Debug, Names, oVerflow, Range) turned off for that piece of code
- problem still occurs.

Stranger yet, the code was originally written under TP version 2.03, and
it all worked fine under there.  Just recompiling (no code change) under
3.01 introduced the problem.

And yes, the file exists and all.  I went back and ran the 2.03-compiled
version of my program (opening the same file and executing the same code,
of course) and it works OK.  And as I said, it works running within THINK
Pascal 3.01.

I'm still digging, but any help would be appreciated.

Mike
-- 
Mike Pflueger @ AG Communication Systems (formerly GTE Comm. Sys.), Phoenix, AZ
  UUCP: {...!ames!ncar!noao!asuvax | uunet!hrc | att}!gtephx!pfluegerm
  Work: 602-582-7049        FAX: 602-582-7624     Home: 602-439-1978
Packet: WD8KPZ @ KB7TV.AZ.USA.NA  Internet: gtephx!pfluegerm@asuvax.eas.asu.edu

kmork@ulrik.uio.no (Knut Mork) (05/05/91)

Try to avoid using "reset" commands and other high-level pascal file managing
commands in mac applications.  If you do, make sure of the following things:
1) You use "runtime.lib" and NOT "mruntime.lib"
2) THE FILE YOU CHOOSE IN THE SFGETFILE BOX IS IN THE SAME FOLDER AS THE
APPLICATION!!!!!

This Is IMPORTANT!! Reset and Rewrite have no searching capabilities.  They
just check the folder you're in for the files.

So if you need files available from other folders, use the File Manager!
I'd be more than happy to help you all with it, if you need it.

--Knut Mork, kmork@ulrik.uio.no
-- 
| /  |\  /|   Knut Mork
|/   | \/ |   "The Master"
|\   |    |   aka Duthyn, Kaiser Knut, TRAP-R-JON-1, Forian
| \  |    |   kmork@ulrik.uio.no