[comp.sys.mac.programmer] LSP 2.0 dies with low-level file manager calls???

alexis@ccnysci.UUCP (Alexis Rosen) (05/11/89)

I have a small application that I wrote for turnkey systems which must boot
a program off of a network volume. I set startup to this application, and
then this application launches another app it finds on the remote disk.

Today I tried rewriting this program to work with programs not in the root
directory of the remote volume. Since _Launch only takes files which are in
the current directory, that means I have to set it first. I have tried using
SetVol, PBHSetVol, and when neither worked, I used PBOpenWD and then tried
both types of SetVol on the working directory.

This brought up another worse problem. I cannot seem to make LSP work with
PBOpenWD, no matter what I do. It fails with some other low-level calls as
well. It hangs in a two-command infinite loop in FlushEvents+370 (or
thereabouts), according to MacsBug.

Finally in sheer frustration (we're talking about a 3K program here, it
shouldn't take more than ten minutes to do) I wrote the following program:

Program LSPBomber;
 Var
  err, vrn: Integer;
  aName: String;
  fi: FInfo;
  mypb: WDPBPtr;

Begin
 aName := 'Hard Disk:';
 err := SetVol(@aName, 0);
 If err <> noErr Then
  ExitToShell;
 err := GetVol(@aName, vrn);
 aName := ':Empty Folder:';
 With mypb^ Do Begin
  ioNamePtr := @aName;
  ioVRefNum := vrn;
  ioWDProcID := LongInt('ERIK');   { since my ultimate goal is to sub-launch }
  ioWDDirID := 0    { when this is zero, it should be ignored }
 End;
 err := PBOpenWD(mypb, false)
End.

As you can see this is not your basic million-line program. If you trace it
in LSP it will hang in the last line, but if you compile it to an app it will
run fine some times and bomb on others.

I'd love to know what's going on- I can't imagine that I'm the only one to
have ever done PBOpenWD in LSP, but I traced through this in MacsBug with the
compiled version and everything seems to be okay- the file manager call returns
zero in D0, which is noErr.

The only thing I saw which was even slightly suspicious was indexing off of
A3 without ever setting it up first, but I would guess that it gets initialized
in the auto-generated preamble.

While I'm asking questions, I'd like to know if there's anything about using
_Launch that isn't in the tech notes. I've read them all, and they (#126 in
particular) show the use of an extended parameter block, which is never fully
described anywhere that I know of.

Before anybody suggests it, I can't use SFGetFile to make the WD for me. This
has to be completely turnkey, so that novices can just turn on the machine
and get to work.

Thanks in advance,
---
Alexis Rosen
alexis@ccnysci.{uucp,bitnet}
alexis@rascal.ics.utexas.edu  (last resort)

alexis@ccnysci.UUCP (Alexis Rosen) (05/12/89)

Okay, Earle Horton has been kind enough to point out just how stupid I
was, so the rest of you don't need to bother. I even figured out that
A3 wasn't being set up and I _still_ didn't realize what I was doing
wrong, which was not making a paramblock and setting "mypb^" to it. I
cut the source from another program which was already working, and
missed that part, but still that's no excuse.

On the other hand, my followup questions about _Launch and Working
Directories still stand. Also, let it be said that despite my grousing,
I think LSP is a truly wonderful environment for the small projects
that I do in Pascal- such as the following:

Program Penance;
  Var i:LongInt;

Begin
For i:= 1 To 1000000 Do
  Writeln('I will not use pointers without first allocating storage!')
End.

---
Alexis Rosen
alexis@ccnysci.{uucp,bitnet}
alexis@rascal.ics.utexas.edu  (last resort)