Specifications
2 COMMUNICATING WITH THE SYSTEM SCREEN
2-15
#pragma restore
GLDEF_C VOID main(VOID)
{
TEXT fSpec[P_FNAMESIZE];
UBYTE comBuf[E_MAX_COMMAND_BUFFER+1];
TEXT *pCommand;
TEXT *pAlias;
TEXT *pEndAlias;
TEXT *p;
HANDLE pId;
INT len;
p=skipStr(DatCommandPtr);
len=(*p);
pCommand=(p+1);
pAlias=skipStr(pCommand);
pEndAlias=skipStr(pAlias)-1; /* Point to end 0 */
p=p_bcpy(&comBuf[0],pCommand,pEndAlias-pCommand);
p=p_bcpy(p,&aliasInfo[0],sizeof(aliasInfo));
p_bcpy(p,pEndAlias,len-(pEndAlias-pCommand));
if ((pId=p_enter2(getWordFspec,&fSpec[0]))<0)
goto fail;
if ((pId=p_execc(&fSpec[0],&comBuf[0],len+5))<0) /* Run Word */
goto fail;
p_setpri(pId,p_getpri(p_getpid())-1);
pId=p_presume(pId); /* Won't run till I've exited */
fail:
p_exit(pId);
}
This program uses the fact that the filename of the
Word.app
application is always stored in the 78th
resource within the resource file of the shell application. (Hence the
#define
of
R_STRARRAY_APPNAMES
as
78
.) This resource actually contains an
array
of strings giving the filenames of the built-in applications,
with the filename of
Word.app
as the second element in the array.
See the chapter
Resource Files
in the
Additional System Information
chapter for background on creating
and using an instance of the
rscfile
class.
The program also analyses its own command line, and constructs a suitable one to pass on to
Word.app
.
The detailed working of the program can be followed using the information given earlier in this chapter.










