[comp.sys.apple] ORCA/C question

hartkopf@tramp.Colorado.EDU (Jeff Hartkopf) (08/05/89)

I'm having a problem in loading/starting Standard File from an NDA with Orca/C.
I previously wrote the code to do this in TML Pascal, and it worked, so I just
translated that as much as I could into C, but now it doesn't work.  I know
there is an error somewhere in the code below, but I'm not sure where--maybe
someone could look at it and see if they can spot an (or more than one?) error.
I marked one place with a comment where I wasn't sure if that line was right,
but since there were no examples of this on the Orca/C samples disk, I'm
not sure.  Thanks very much for any help.


/* in the NDA Open function: */

    handle  toolsZeroPage;
    int     toolErr;
    BOOLEAN NDAStartedSF = FALSE;   /* records if this NDA started SF or not */
    BOOLEAN NDALoadedSF = FALSE;    /* records if this NDA loaded SF or not */
    word    memID;
    int     btn;
    if (!SFLoaded())    /* SFLoaded() code is shown below */
    {
        memID = MMStartUp();
        /* possibly error in following line? */
        toolsZeroPage = NewHandle(256, memID, attrBank + attrPage +
                attrFixed + attrLocked);
        do

            LoadOneTool(23, 0);
            toolErr = toolerror();
            if (toolErr)
            {
                btn = TLMountVolume(100, 40, "Error loading tools",
                          "Insert System Disk", "OK", "Cancel");
                if (btn != 1)
                    SysFailMgr(toolErr, "Unable to load tools");
            }
        }
        while (toolErr);
        NDALoadedSF = TRUE;
    }
    if (!SFStarted())    /* SFStarted() code is shown below */
    {
        SFStartUp(memID, *toolsZeroPage);
        NDAStartedSF = TRUE;
    }

/* ... some actions, etc. */

    if (NDAStartedSF)
        SFShutDown();
    if (NDALoadedSF)
    {
        UnloadOneTool(23);
        DisposeHandle(toolsZeroPage);
    }



/* SFLoaded() and SFStarted(): */

BOOLEAN SFLoaded(void)
/* returns TRUE if Standard File is loaded, otherwise FALSE */
{
    SFStatus();
    if (toolerror())    /* not loaded */
        return (FALSE);
    else                /* loaded */
        return (TRUE);
}

BOOLEAN SFStarted(void)
/* returns TRUE if Standard File is started, otherwise FALSE */
{
    int started;

    started = SFStatus();
    if (toolerror())      /* not even loaded, so not started */
        return (FALSE);
    else if (!started)    /* not started */
        return (FALSE);
    else
        return (TRUE);    /* started */
}



Also, is anyone else having problems running Orca/C from System Software 5.0?
I have 1.25 meg of memory, and when I run it from my hard drive, and try to
compile something, I generally get a strange empty dialog box and the system
hangs.  Is this a memory problem, or just an incompatibility problem, with
5.0?  Thanks for any suggestions.


Jeff Hartkopf

Internet:
hartkopf@tramp.Colorado.EDU

dlyons@Apple.COM (David Lyons) (08/05/89)

In article <10502@boulder.Colorado.EDU> hartkopf@tramp.Colorado.EDU (Jeff Hartkopf) writes:
>I'm having a problem in loading/starting Standard File from an NDA with Orca/C.

(I can't tell for sure from your code fragments, but be sure you never give
control back to the main application with Standard File started if it wasn't
already started by the app.  That could crash some apps.)

>/* in the NDA Open function: */
>        toolsZeroPage = NewHandle(256, memID, attrBank + attrPage +
>                attrFixed + attrLocked);

The "256" looks like a problem to me, *unless* you have a function prototype
for NewHandle() so that the compiler knows a long (4-byte) integer is
required for that parameter rather than a regular 2-byte one.  Use "256L"
or "(long) 256" instead.

>BOOLEAN SFLoaded(void)
>/* returns TRUE if Standard File is loaded, otherwise FALSE */
>{
>    SFStatus();
>    if (toolerror())    /* not loaded */
>        return (FALSE);
>    else                /* loaded */
>        return (TRUE);
>}

You ought to be able to do it shorter like this, I think:

BOOLEAN SFLoaded(void)
{
  SFStatus();
  return(!toolerror());
}

>BOOLEAN SFStarted(void)
>/* returns TRUE if Standard File is started, otherwise FALSE */
>{
>    int started;
>
>    started = SFStatus();
>    if (toolerror())      /* not even loaded, so not started */
>        return (FALSE);
>    else if (!started)    /* not started */
>        return (FALSE);
>    else
>        return (TRUE);    /* started */
>}

Again, that looks fine, but it can be shortened:

BOOLEAN SFStarted(void)
{
  int started = SFStatus();
  if(toolerror())
      return(FALSE);
  return(started);
}


 --Dave Lyons, Apple Computer, Inc.          |   DAL Systems
   AppleLink--Apple Edition: DAVE.LYONS      |   P.O. Box 875
   AppleLink--Personal Edition: Dave Lyons   |   Cupertino, CA 95015-0875
   GEnie: D.LYONS2 or DAVE.LYONS         CompuServe: 72177,3233
   Internet/BITNET:  dlyons@apple.com    UUCP:  ...!ames!apple!dlyons

   My opinions are my own, not Apple's.

dlyons@Apple.COM (David Lyons) (08/05/89)

In article <10502@boulder.Colorado.EDU> hartkopf@tramp.Colorado.EDU (Jeff Hartkopf) writes:
>[...]
>/* in the NDA Open function: */
>        toolsZeroPage = NewHandle(256, memID, attrBank + attrPage +
>                attrFixed + attrLocked);

Whoops!  I missed a couple of things in my first reply.  NewHandle() needs
a fourth parameter at the end: 0L or NULL.

>                btn = TLMountVolume(100, 40, "Error loading tools",
>                          "Insert System Disk", "OK", "Cancel");
>                if (btn != 1)
>                    SysFailMgr(toolErr, "Unable to load tools");

You don't really need to bother with that--GS/OS will already put up a
volume-mount dialog; you can override that using SetSysPrefs, but there's
no need.  Under 5.0 there is the option of removing the Cancel button
from the dialog, which is sometimes appropriate.  (You really shouldn't
kill the system with SysFailMgr from an NDA, by the way!)

>        SFStartUp(memID, *toolsZeroPage);

Not sure what ORCA/C will do with this, but I'd cast the second parameter to
an integer, like this:

         SFStartUp(memID, (int)(*toolsZeroPage));


 --Dave Lyons, Apple Computer, Inc.          |   DAL Systems
   AppleLink--Apple Edition: DAVE.LYONS      |   P.O. Box 875
   AppleLink--Personal Edition: Dave Lyons   |   Cupertino, CA 95015-0875
   GEnie: D.LYONS2 or DAVE.LYONS         CompuServe: 72177,3233
   Internet/BITNET:  dlyons@apple.com    UUCP:  ...!ames!apple!dlyons

   My opinions are my own, not Apple's.

fadden@cory.Berkeley.EDU (Andy McFadden) (08/25/89)

If I purchase ORCA/C, will it work within APW (i.e., can I copy the files into
the appropriate directories on my hard drive and have it work just like APW C)?

Thanks...


-- 
fadden@cory.berkeley.edu (Andy McFadden)
...!ucbvax!cory!fadden

gwyn@smoke.BRL.MIL (Doug Gwyn) (08/28/89)

In article <16547@pasteur.Berkeley.EDU> fadden@cory.Berkeley.EDU (Andy McFadden) writes:
>If I purchase ORCA/C, will it work within APW (i.e., can I copy the files into
>the appropriate directories on my hard drive and have it work just like APW C)?

I think Orca/C requires version 1.1 of the shell, which APDA has not released
yet.  However, I don't understand your concern.  The Orca environment is
essentially a superset of APW.  I quit using APW entirely when I got Orca/C.