pascal OSErr AEOpenFiles(AppleEvent *theAppleEvent, AppleEvent *theReply, long Refcon) { AEDescList docList; AEKeyword keywd; DescType returnedType; Size actualSize; long itemsInList; FSSpec theSpec; CInfoPBRec pb; Str255 name; short i; if (AEGetParamDesc(theAppleEvent, keyDirectObject, typeAEList, &docList) != noErr) return; if (AECountItems (&docList, &itemsInList) != noErr) return; SetSelection (TEXTREC->teLength, TEXTREC->teLength); for (i = 1; i <= itemsInList; i++) { AEGetNthPtr (&docList, i, typeFSS, &keywd, &returnedType, (Ptr) &theSpec, sizeof(theSpec), &actualSize); GetFullPath(&theSpec, name); P2CStr(name); // was: pstrterm(name); if (xlload ((char *)name + 1, 1, 0) == 0) xlabort ("load error"); } macputs ("> "); PrepareForInput (); }
main(int argc, char **argv) { CONTEXT cntxt; NODE *expr; int i; osinit("XLISP version 1.6, Copyright (c) 1985, by David Betz"); xlbegin(&cntxt,64|8,(NODE *) 1); if (setjmp(cntxt.c_jmpbuf)) { printf("fatal initialization error\n"); osfinish(); exit(1); } xlinit(); xlend(&cntxt); xlbegin(&cntxt,64|8,true); if (setjmp(cntxt.c_jmpbuf) == 0) xlload("init.lsp",0,0); if (setjmp(cntxt.c_jmpbuf) == 0) for (i = 1; i < argc; i++) if (!xlload(argv[i],1,0)) xlfail("can't load file"); xlsave(&expr,(NODE **)0); while (1) { if (i = setjmp(cntxt.c_jmpbuf)) { if (i == 64) stdputstr("[ back to the top level ]\n"); ((s_evalhook)->n_info.n_xsym.xsy_value = ((NODE *)0)); ((s_applyhook)->n_info.n_xsym.xsy_value = ((NODE *)0)); xldebug = 0; xlflush(); } if (!xlread(((s_stdin)->n_info.n_xsym.xsy_value),&expr,0)) break; expr = xleval(expr); stdprint(expr); } xlend(&cntxt); osfinish (); exit (0); }
/* xload - read and evaluate expressions from a file */ LVAL xload(void) { unsigned char *name; int vflag,pflag; LVAL arg; /* get the file name */ name = getstring(xlgetfname()); /* get the :verbose flag */ if (xlgetkeyarg(k_verbose,&arg)) vflag = (arg != NIL); else vflag = TRUE; /* get the :print flag */ if (xlgetkeyarg(k_print,&arg)) pflag = (arg != NIL); else pflag = FALSE; /* load the file */ return (xlload((char *) name, vflag, pflag) ? s_true : NIL); }