Esempio n. 1
0
void exceptionobject_print(EmObject *ob, FILE *fp) {
    EmExceptionObject *eo = (EmExceptionObject *)ob;
    fprintf(fp, "[%s] %s", getstringvalue(eo->errtype),
            getstringvalue(eo->message));
    if (eo->value)
        fprintf(fp, ": %s", getstringvalue(eo->value));
}
Esempio n. 2
0
static boolean settitleverb (hdltreenode hparam1, tyvaluerecord *vreturned) {
	
	/*
	6/24/92 dmb: set the title of the object or window indicated in hparam1.
	if it's  not an external value or a window, always return false
	*/
	
	hdlwindowinfo hinfo;
	bigstring bstitle;
	boolean fl = false;
	
	if (!getwinparam (hparam1, 1, &hinfo))
		return (false);
	
	flnextparamislast = true;
	
	if (!getstringvalue (hparam1, 2, bstitle))
		return (false);
	
	if (hinfo != nil) {
		
		shellsetwindowtitle (hinfo, bstitle); // 7.24.97 dmb: was windowsettitle
		
		shellwindowmenudirty ();
		
		fl = true;
		}
	
	return (setbooleanvalue (fl, vreturned));
	} /*settitleverb*/
Esempio n. 3
0
static boolean dbgetvalueverb (hdltreenode hparam1, tyvaluerecord *vreturned) {

	/*
	4.1.1b1 dmb: fixed memory leak; push value on temp stack
	
	5.0b17 dmb: use pushtmpstackvalue to put external types returned from 
	the other odb onto our temp stack

	5.0.1 dmb: but only pushtmpstack if heapallocated
	*/
	
	tyodbrecord odbrec;
	bigstring bsaddress;
	odbValueRecord value;
	tyvaluetype type;
	
	if (!getodbvalue (hparam1, 1, &odbrec, true))
		return (false);
	
	flnextparamislast = true;
	
	if (!getstringvalue (hparam1, 2, bsaddress))
		return (false);
	
	if (odberror (odbgetvalue (odbrec.odb, bsaddress, &value)))
		return (false);
	
	type = langexternalgetvaluetype (value.valuetype);
	
	if (type == (tyvaluetype) -1) {
	
		return (setbinaryvalue (value.data.binaryvalue, value.valuetype, vreturned));
		}
	else {
		
		initvalue (vreturned, type);
		
		(*vreturned).data.binaryvalue = value.data.binaryvalue;
		
		if (langheapallocated (vreturned, nil))
			pushtmpstackvalue (vreturned); //5.0b17
		
		return (true);
		
		/*
		initvalue (&val, type);
		
		val.data.binaryvalue = value.data.binaryvalue;
		
		return (copyvaluerecord (val, vreturned));
		*/
		}
	} /*dbgetvalueverb*/
Esempio n. 4
0
static boolean tablerenameverb (hdltreenode hparam1, tyvaluerecord *v) {
	
	/*
	table.rename (address, string): boolean; rename the indicated table 
	entry to the given name
	
	12/28/91 dmb: resort the table after changing its name
	
	8/26/92 dmb: if the table is displayed in a window, use tableresort 
	to ensure clean update

	5.0a15 dmb: on success, return address of renamed value
	
	5.1.4 dmb: disallow rename if new name is already in use; generate 
	errors if item doesn't exist
	*/
	
	hdlhashtable htable;
	bigstring bs, bsname;
	hdlhashnode hnode;
	
	if (!getvarparam (hparam1, 1, &htable, bs))
		return (false);
	
	flnextparamislast = true;
	
	if (!getstringvalue (hparam1, 2, bsname))
		return (false);
	
	if (!hashtablelookupnode (htable, bs, &hnode)) {
		
		langparamerror (unknownidentifiererror, bs);
		
		return (false);
		}
	
	if (!equalidentifiers (bs, bsname)) {
		
		if (hashtablesymbolexists (htable, bsname)) {
		
			lang2paramerror (badrenameerror, bs, bsname);
			
			return (false);
			}
		
		if (!hashsetnodekey (htable, hnode, bsname))
			return (false);
		}
	
	hashresort (htable, hnode);
	
	return (setaddressvalue (htable, bsname, v));
	} /*tablerenameverb*/
Esempio n. 5
0
static int check_params(BltinmethodParamsDesc *desc, EmObject *ob) {

    int retval = 1, npparams, haskeywords;
    EmObject *keywords, *pparams;

    if (ob == &nulobj) {
        if (desc->nreq_args > 0)
            return 0;
        else
            return 1;
    }

    pparams = listobject_get(ob, 0);
    keywords = listobject_get(ob, 1);

    npparams = listobject_len(pparams);
    if (npparams > desc->nargs && desc->nargs >= 0) {
        ex_runtime("incorrect number of arguments");
        retval = 0;
    }
    if (npparams < desc->nreq_args) {
        ex_runtime("fewer arguments than required");
        retval = 0;
    }
    DECREF(pparams);

    if (keywords != &nulobj) {
        EmObject *keylist, *kw;
        keylist = hashobject_keys(keywords);
        char *match;
        int ii;
        for (ii = 0; ii < listobject_len(keylist); ii++) {
            kw = listobject_get(keylist, ii);
            match = strstr(desc->keywords, getstringvalue(kw));
            DECREF(kw);
            if (match == NULL) {
                ex_runtime("unknown keyword parameter");
                retval = 0;
            }
        }
        DECREF(keylist);
    }
    DECREF(keywords);

    return retval;
}
Esempio n. 6
0
static boolean menusetcommandkeyverb (hdltreenode hparam1, tyvaluerecord *v) {
	
	/*
	menu/op globals are set.  set the command key of the current headline
	*/
	
	bigstring bscommandkey;
	
	flnextparamislast = true;
	
	if (!getstringvalue (hparam1, 1, bscommandkey))
		return (false);
	
	mesetcmdkey (lastchar (bscommandkey), keycommand);
	
	return (setbooleanvalue (true, v));
	} /* menusetcommandkeyverb */
Esempio n. 7
0
static boolean dbnewtableverb (hdltreenode hparam1, tyvaluerecord *vreturned) {

	tyodbrecord odbrec;
	bigstring bsaddress;
	
	if (!getodbvalue (hparam1, 1, &odbrec, false))
		return (false);
	
	flnextparamislast = true;
	
	if (!getstringvalue (hparam1, 2, bsaddress))
		return (false);
	
	if (odberror (odbnewtable (odbrec.odb, bsaddress)))
		return (false);

	return (setbooleanvalue (true, vreturned));
	} /*dbnewtableverb*/
Esempio n. 8
0
static boolean dbgetmoddateverb (hdltreenode hparam1, tyvaluerecord *vreturned) {

	tyodbrecord odbrec;
	bigstring bsaddress;
	unsigned long moddate;
	
	if (!getodbvalue (hparam1, 1, &odbrec, true))
		return (false);
	
	flnextparamislast = true;
	
	if (!getstringvalue (hparam1, 2, bsaddress))
		return (false);
	
	if (odberror (odbgetmoddate (odbrec.odb, bsaddress, &moddate)))
		return (false);
	
	return (setdatevalue (moddate, vreturned));
	} /*dbgetmoddateverb*/
Esempio n. 9
0
static boolean dbcountitemsverb (hdltreenode hparam1, tyvaluerecord *vreturned) {

	tyodbrecord odbrec;
	bigstring bsaddress;
	long ctitems;
	
	if (!getodbvalue (hparam1, 1, &odbrec, true))
		return (false);
	
	flnextparamislast = true;
	
	if (!getstringvalue (hparam1, 2, bsaddress))
		return (false);
	
	if (odberror (odbcountitems (odbrec.odb, bsaddress, &ctitems)))
		return (false);
	
	return (setlongvalue (ctitems, vreturned));
	} /*dbcountitemsverb*/
Esempio n. 10
0
static boolean ccmsgverb (hdltreenode hparam1, tyvaluerecord *vreturned) {
	
	bigstring bsmsg;
	
	flnextparamislast = true;
	
	if (!getstringvalue (hparam1, 1, bsmsg))
		return (false);
	
	if (shellwindow != nil)
		shellpushrootglobals (shellwindow);
	else
		shellpushfrontrootglobals ();
	
	ccmsg (bsmsg, !processisoneshot (true));
	
	shellpopglobals ();
	
	return (setbooleanvalue (true, vreturned));
	} /*ccmsgverb*/
Esempio n. 11
0
static boolean dbsetvalueverb (hdltreenode hparam1, tyvaluerecord *vreturned) {
	
	tyodbrecord odbrec;
	bigstring bsaddress;
	odbValueRecord value;
	tyvaluerecord val;
	boolean flerror;
	
	if (!getodbvalue (hparam1, 1, &odbrec, false))
		return (false);
	
	if (!getstringvalue (hparam1, 2, bsaddress))
		return (false);
	
	flnextparamislast = true;
	
	if (!getparamvalue (hparam1, 3, &val))
		return (false);
	
	if (!copyvaluedata (&val))
		return (false);
	
	value.valuetype = (odbValueType) langexternalgettypeid (val);
	
	/*
	if (val.valuetype == binaryvaluetype)
		pullfromhandle (val.data.binaryvalue, 0L, sizeof (value.valuetype), &value.valuetype);
	*/
	
	value.data.binaryvalue = val.data.binaryvalue; /*largest field covers everything*/
	
	flerror = odberror (odbsetvalue (odbrec.odb, bsaddress, &value));
	
	disposevaluerecord (val, false);
	
	if (flerror)
		return (false);

	return (setbooleanvalue (true, vreturned));
	} /*dbsetvalueverb*/
Esempio n. 12
0
static boolean dbdefinedverb (hdltreenode hparam1, tyvaluerecord *vreturned) {

	/*
	4.1b5 dmb: new verb
	*/
	
	tyodbrecord odbrec;
	bigstring bsaddress;
	boolean fl;
	
	if (!getodbvalue (hparam1, 1, &odbrec, true))
		return (false);
	
	flnextparamislast = true;
	
	if (!getstringvalue (hparam1, 2, bsaddress))
		return (false);
	
	fl = odbdefined (odbrec.odb, bsaddress);
	
	return (setbooleanvalue (fl, vreturned));
	} /*dbdefinedverb*/
Esempio n. 13
0
static boolean dbgetnthitemverb (hdltreenode hparam1, tyvaluerecord *vreturned) {

	tyodbrecord odbrec;
	bigstring bsaddress;
	bigstring bsname;
	long n;
	
	if (!getodbvalue (hparam1, 1, &odbrec, true))
		return (false);
	
	if (!getstringvalue (hparam1, 2, bsaddress))
		return (false);
	
	flnextparamislast = true;
	
	if (!getlongvalue (hparam1, 3, &n))
		return (false);
	
	if (odberror (odbgetnthitem (odbrec.odb, bsaddress, n, bsname)))
		return (false);
	
	return (setstringvalue (bsname, vreturned));
	} /*dbgetnthitemverb*/
Esempio n. 14
0
static boolean tablepacktableverb (hdltreenode hparam1, tyvaluerecord *v) {
	
	/*
	this is really for internal use only; packes a table and creates a 
	named HASH resource that can be loaded in tablestructure
	*/
	
	hdlhashtable htable;
	bigstring bs;
	register boolean fl;
	Handle hpacked;
	boolean fldummy;
	
	if (!gettablevalue (hparam1, 1, &htable))
		return (false);
	
	flnextparamislast = true;
	
	if (!getstringvalue (hparam1, 2, bs))
		return (false);
	
	fl = hashpacktable (htable, true, &hpacked, &fldummy);
	
	if (fl) {
		
		lockhandle (hpacked);
		
		fl = filewriteresource (filegetapplicationrnum (), 'HASH', -1, bs, gethandlesize (hpacked), *hpacked);
		
		disposehandle (hpacked);
		}
	
	(*v).data.flvalue = fl;
	
	return (true);
	} /*tablepacktableverb*/
Esempio n. 15
0
boolean getwinparam (hdltreenode hfirst, short pnum, hdlwindowinfo *hinfo) {
	
	/*
	9/19/91 dmb: we now handle strings as window specifications
	
	5.0d3 dmb: allow windows to be identified by path. also, visit 
	in front-to-back order in case of identical names (like "Untitled")
	*/
	
	bigstring bsname;
	boolean fl;
	//hdlhashtable ht;
	
	disablelangerror ();
	
	fl = getwinaddressparam (hfirst, pnum, hinfo);
	
	enablelangerror ();
	
	if (fl && *hinfo)
		return (true);
	
	if (!getstringvalue (hfirst, pnum, bsname))
		return (false);
	/*
	disablelangerror ();
	
	langexpandtodotparams  (bsname, ht, bsname); // undo effect of deparsestring, bracketname
	
	enablelangerror ();
	*/
	
	shellfindnamedwindow (bsname, hinfo); /*ignore result; hinfo is what counts*/
	
	return (true);
	} /*getwinparam*/
Esempio n. 16
0
static boolean tablefunctionvalue (short token, hdltreenode hparam1, tyvaluerecord *vreturned, bigstring bserror) {
	
	/*
	bridges table.c with the language.  the name of the verb is bs, its first parameter
	is hparam1, and we return a value in vreturned.
	
	we use a limited number of support routines from lang.c to get parameters and
	to return values. 
	
	return false only if the error is serious enough to halt the running of the script
	that called us, otherwise error values are returned through the valuerecord, which
	is available to the script.
	
	if we return false, we try to provide a descriptive error message in the 
	returned string bserror.
	
	11/14/91 dmb: getcursorfunc returns address, not full path
	
	10/3/92 dmb: commented out setcolwidthfunc. (this verb still isn't "offical")
	
	4/2/93 dmb: added jettisonfunc
	
	6/1/93 dmb: when vreturned is nil, return whether or not verb token must 
	be run in the Frontier process
	
	5.1.5b11 dmb: fixed gotofunc silent failure
	*/
	
	register tyvaluerecord *v = vreturned;
	register boolean fl = false;
	WindowPtr targetwindow;
	
	if (v == nil) { /*need Frontier process?*/
		
		switch (token) {
			
			case sortbyfunc:
			case getcursorfunc:
			case getselectionfunc:
			case gotofunc:
			case gotonamefunc:
			case gofunc:
			case getdisplaysettings:
			case setdisplaysettings:
				return (true);
			
			default:
				return (false);
			}
		}
	
	setbooleanvalue (false, v); /*by default, table functions return false*/
	
	switch (token) { /*these verbs don't require an open table window*/
		
		/*
		case findfunc:
			if (!tablefindverb (hparam1, v))
				goto error;
			
			return (true);
		*/
		
		case validatefunc:
			return (tablevalidateverb (hparam1, v));
		
		case movefunc:
			return (tablemoveverb (hparam1, v));
		
		case copyfunc:
			return (tablecopyverb (hparam1, v));
		
		case renamefunc:
			return (tablerenameverb (hparam1, v));
		
		case moveandrenamefunc:
			return (tablemoveandrenameverb (hparam1, v));
		
		/*
		case lockfunc:
		case islockedfunc:
		*/
		
		case assignfunc:
			return (tableassignverb (hparam1, v));
			
		#ifdef MACVERSION
		case packtablefunc:
			return (tablepacktableverb (hparam1, v));
		#endif

		case emptytablefunc:
			return (tableemptytableverb (hparam1, v));
		
		case jettisonfunc: { /*toss an object w/out forcing it into memory. for database recovery.*/
			hdlhashtable htable;
			bigstring bs;
			
			if (!getvarparam (hparam1, 1, &htable, bs)) /*name of table*/
				return (false);
			
			pushhashtable (htable);
			
			(*v).data.flvalue = hashdelete (bs, true, false);
			
			pophashtable ();
			
			return (true);
			}
		} /*switch*/
	
	/*all other verbs require a table window in front*/
	
	if (!langfindtargetwindow (idtableprocessor, &targetwindow)) {
		
		getstringlist (tableerrorlist, notableerror, bserror);
		
		return (false);
		}
	
	shellpushglobals (targetwindow); /*following verbs assume that an table is pushed*/
	
	(*shellglobals.gettargetdataroutine) (idtableprocessor); /*set table globals*/
	
	switch (token) {
		
		/*
		case setcolwidthfunc: {
			short colnum, colwidth;
			
			if (!getintvalue (hparam1, 1, &colnum))
				break;
			
			flnextparamislast = true;
			
			if (!getintvalue (hparam1, 2, &colwidth))
				break;
			
			(*v).data.flvalue = (*(**tableformatsdata).adjustcolwidthroutine) (colnum - 1, colwidth);
			
			tablesmashdisplay ();
			
			fl = true;
			
			break;
			}
		*/
		
		case sortbyfunc: {
			bigstring bssort, bstitle;
			short ixcol;
			
			flnextparamislast = true;
			
			if (!getstringvalue (hparam1, 1, bssort))
				break;
			
			alllower (bssort);
			
			for (ixcol = namecolumn; ixcol <= kindcolumn; ++ixcol) {
				
				tablegettitlestring (ixcol, bstitle);
				
				alllower (bstitle);
				
				if (equalstrings (bssort, bstitle)) {
					
					hdlhashtable ht;
					bigstring bs;
					
					tablegetcursorinfo (&ht, bs, nil, nil);
	
					(*v).data.flvalue = tablesetsortorder (ht, ixcol);
					
					break;
					}
				}
			
			fl = true;
			
			break;
			}
		
		/*
		case centertablefunc: {
			boolean flcenter;
			
			flnextparamislast = true;
			
			if (!getbooleanvalue (hparam1, 1, &flcenter))
				break;
				
			(*v).data.flvalue = tablesetcenter (flcenter);
			
			fl = true;
			
			break;
			}
		*/
			
		case getcursorfunc: {
			hdlhashtable htable;
			bigstring bs;
			tyvaluerecord val;
			hdlhashnode hhashnode;
			
			if (!langcheckparamcount (hparam1, 0)) /*too many parameters were passed*/
				break;
			
			/*
			tablegetcursorpath (bspath);
			
			fl = setstringvalue (bspath, v);
			*/
			
			if (!tablegetcursorinfo (&htable, bs, &val, &hhashnode))
				fl = setstringvalue (zerostring, v);
			else
				fl = setaddressvalue (htable, bs, v);
			
			break;
			}
		
		case getselectionfunc:
			fl = tablegetselectionverb (hparam1, v);
			
			break;
		
		case gotofunc: {
			short row;
			hdlheadrecord hsummit;
			
			flnextparamislast = true;
			
			if (!getintvalue (hparam1, 1, &row))
				break;
			
			if (opnthsummit (row, &hsummit)) {
				
				opclearallmarks ();
				
				opmoveto (hsummit);
				
				(*v).data.flvalue = true;
				}
			
			fl = true;
			
			break;
			}
		
		case gotonamefunc: {
			hdlhashtable ht;
			bigstring bs;
			
			if (!tablegetcursorinfo (&ht, bs, nil, nil))
				ht = nil;
			
			flnextparamislast = true;
			
			if (!getstringvalue (hparam1, 1, bs))
				break;
			
			(*v).data.flvalue = tablemovetoname (ht, bs);
			
			fl = true;
			
			break;
			}
		
		case gofunc: {
			tydirection dir;
			short count;
			
			if (!getdirectionvalue (hparam1, 1, &dir))
				break;
			
			flnextparamislast = true;
			
			if (!getintvalue (hparam1, 2, &count))
				break;
			
			opsettextmode (false);
			
			if (dir == down)
				dir = flatdown;
			
			if (dir == up)
				dir = flatup;
			
			(*v).data.flvalue = opmotionkey (dir, count, false);
			
			fl = true;
			
			break;
			}
		
		case getdisplaysettings:
			fl = tablegetdisplaysettingsverb (hparam1, v);
			
			break;
		
		case setdisplaysettings:
			fl = tablesetdisplaysettingsverb (hparam1, v);
			
			break;

		case sortorderfunc: {
			hdlhashtable ht;
			bigstring bs;
			short ixcol;

			tablegetcursorinfo (&ht, bs, nil, nil);

			tablegetsortorder (ht, &ixcol);

			tablegettitlestring (ixcol, bs);

			fl = setstringvalue (bs, v);

			break;
			}
		} /*switch*/
	
	shellupdatescrollbars (shellwindowinfo);
	
	shellpopglobals ();
	
	return (fl);
	} /*tablefunctionvalue*/
Esempio n. 17
0
static boolean windowfunctionvalue (short token, hdltreenode hparam1, tyvaluerecord *vreturned, bigstring bserror) {

	//
	// 2007-07-28 creedon: added setquickscriptfunc case, set the Quick Script
	//				   window script
	//
	// 6.2a8 AR: systemstatsfunc now works for GDBs (at least partly)
	//
	// 1993-06-01 dmb: when vreturned is nil, return whether or not verb token
	//			    must be run in the Frontier process
	//
	// 1992-06-24 dmb: added gettitle, settitle verbs
	//
	// 1991-10-03 dmb: moved a couple of verbs in from shellverbs.c -- they're
	//			    the odd ones out following zoomfunc.
	//
	
	register hdltreenode hp = hparam1;
	register tyvaluerecord *v = vreturned;
	register short errornum = 0;
	
	if (v == nil) /*need Frontier process?*/
		return (true);
	
	setbooleanvalue (false, v); /*by default, window functions return true*/
	
	switch (token) {
		
		case isopenfunc:
			return (isopenverb (hp, v));
		
		case openfunc:
			return (openverb (hp, v, bserror));
		
		case isfrontfunc:
			return (isfrontverb (hp, v));
		
		case bringtofrontfunc:
			return (bringtofrontverb (hp, v));
		
		case sendtobackfunc:
			return (sendtobackverb (hp, v));
		
		case frontmostfunc:
			return (frontmostverb (hp, v));
		
		case nextfunc:
			return (nextverb (hp, v));
		
		case isvisiblefunc:
			return (isvisibleverb (hp, v));
	
		case showfunc:
			return (showhideverb (hp, true, v));
	
		case hidefunc:
			return (showhideverb (hp, false, v));
	
		case closefunc:
			return (closeverb (hp, v));
		
		case updatefunc:
			return (updateverb (hp, v));
		
		case ismenuscriptfunc:
			return (ismenuscriptverb (hp, v));
		
		case getposfunc:
			return (getboundsverb (hp, false, v));
		
		case setposfunc:
			return (setboundsverb (hp, false, v));
		
		case getsizefunc:
			return (getboundsverb (hp, true, v));
		
		case setsizefunc:
			return (setboundsverb (hp, true, v));
		
		case zoomfunc:
			return (zoomverb (hp, v));
		
		case runselectionfunc:
			if (!langcheckparamcount (hparam1, 0))
				return (false);
			
			if (!shellpushtargetglobals ())
				return (false);
			
			(*v).data.flvalue = (*shellglobals.executeroutine) ();
			
			shellpopglobals ();
			
			return (true);
		
		case scrollfunc: {
			tydirection dir;
			long count;
			
			if (!getdirectionvalue (hparam1, 1, &dir))
				return (false);
			
			flnextparamislast = true;
			
			if (!getlongvalue (hparam1, 2, &count))
				return (false);
			
			if (!shellpushtargetglobals ())
				return (false);
			
			(*v).data.flvalue = (*shellglobals.scrollroutine) (dir, false, count);
			
			shellupdatescrollbars (shellwindowinfo);
			
			shellpopglobals ();
			
			return (true);
			}
		
		case msgfunc: {
			bigstring bs;
			
			flnextparamislast = true;
			
			if (!getstringvalue (hparam1, 1, bs))
				return (false);
			
			(*v).data.flvalue = shellfrontwindowmessage (bs);
			
			return (true);
			}
		
		case systemstatsfunc:
			if (langgetparamcount (hparam1) == 0)
				dbstatsmessage (nil, true);
			else {
				hdlwindowinfo hinfo;
				hdldatabaserecord hdb;

				flnextparamislast = true;
				
				if (!getwinparam (hparam1, 1, &hinfo))
					break;
				
				if (hinfo == nil || !shellgetdatabase ((**hinfo).macwindow, &hdb)) {
					
					getstringlist (langerrorlist, badwindowerror, bserror);
					
					break;
					}

				dbstatsmessage (hdb, false);
				}

			return (setbooleanvalue (true, v));
		
		case quickscriptfunc:
			if (!langcheckparamcount (hparam1, 0))
				return (false);
			
			(*v).data.flvalue = startcmddialog ();

			return (true);
		
		case isdirtyfunc:
			return (isdirtyverb (hparam1, v));
		
		case setdirtyfunc:
			return (setdirtyverb (hparam1, v));
		
		case gettitlefunc:
			return (gettitleverb (hparam1, v));
		
		case settitlefunc:
			return (settitleverb (hparam1, v));
		
		case aboutfunc:
			if (!langcheckparamcount (hparam1, 0))
				return (false);
			
			(*v).data.flvalue = aboutcommand ();
			
			return (true);
		
		#ifdef MACVERSION
			
			case playerfunc: /*7.0b4 PBS: QuickTime Player window*/
				if (!langcheckparamcount (hparam1, 0))
					return (false);
				
				(*v).data.flvalue = playeropencommand ();
				
				return (true);
			
		#endif
		
		case getfilefunc:
			return (getfileverb (hparam1, v));
		
		case isreadonlyfunc: /*7.0b6 PBS: return true if a window is read-only*/
			return (isreadonlyverb (hparam1, v));
			
		case setquickscriptfunc: {
		
			Handle h;
			
			flnextparamislast = true;
				
			if ( ! getreadonlytextvalue ( hparam1, 1, &h ) )
				return (false);

			( *v ).data.flvalue = cmdsetstring ( h );
			
			return ( true );
			
			}
		
		default:
		
			errornum = notimplementederror;
			
			goto error;
			
		} // switch
	
	error:
	
	if (errornum != 0) /*get error string*/
		getstringlist (windowerrorlist, errornum, bserror);
	
	return (false);
	} /*windowfunctionvalue*/
Esempio n. 18
0
static boolean sysfunctionvalue (short token, hdltreenode hparam1, tyvaluerecord *vreturned, bigstring bserror) {
	
	//
	// 2006-06-28 creedon: for Mac, FSRef-ized
	//
	// 5.0b16 dmb: undo that change. it affect performance adversely if many threads do it.
	//
	// 5.0b12 dmb: in systemtaskfunc, set flresting to false to make sure we don't slow down too much
	//
	// 1/18/93 dmb: in systemtaskfunc, don't call processyield directly; use langbackgroundtask
	//
	// 8/11/92 dmb: make apprunningfunc accept a string or an ostype
	//
	// 5/20/92 dmb: do processyield directly on systemtaskfunc
	//
	// 2/12/92 dmb: do partialeventloop on systemtask & bringapptofrontfunc
	//
	
	register tyvaluerecord *v = vreturned;
	
	setbooleanvalue (false, v); /*assume the worst*/
	
	switch (token) { /*these verbs don't need any special globals pushed*/
		
		case systemversionfunc: {
			bigstring bs;
			
			getsystemversionstring (bs, nil);
			
			if (!langcheckparamcount (hparam1, 0))
				return (false);
						
			return (setstringvalue (bs, v));
			}
		
		case systemtaskfunc:
			if (!langcheckparamcount (hparam1, 0)) /*shouldn't have any parameters*/
				return (false);
			
			shellsysverbwaitroutine ();
			
			/*
			if (!processyield ())
				return (false);
			*/
			
			if (!langbackgroundtask (true))
				return (false);
			
			(*v).data.flvalue = true;
			
			return (true);
		
		case browsenetworkfunc:
		
			#ifdef MACVERSION
			
				return (langipcbrowsenetwork (hparam1, v));
				
			#endif
			
			#ifdef WIN95VERSION
			
				#pragma message ("WIN95: browsenetworkfunc - not yet implemented!")
			
				break;
				
			#endif

		case apprunningfunc: {
			OSType appid;
			bigstring bsapp;
			tyvaluerecord val;
			
			flnextparamislast = true;
			
			/*
			if (!getostypevalue (hparam1, 1, &appid))
				return (false);
			
			(*v).data.flvalue = findrunningapplication (&appid, nil);
			*/
			
			if (!getparamvalue (hparam1, 1, &val))
				return (false);
			
			if (val.valuetype == ostypevaluetype) {
				
				setemptystring (bsapp);
				
				appid = val.data.ostypevalue;
				}
			else {
				if (!coercetostring (&val))
					return (false);
				
				pullstringvalue (&val, bsapp);
				
				if (!stringtoostype (bsapp, &appid))
					appid = 0;
				}
			
			(*v).data.flvalue = findrunningapplication (&appid, bsapp, nil);
			
			return (true);
			}
		
		case frontappfunc: {
			bigstring bs;
			
			if (!langcheckparamcount (hparam1, 0))
				return (false);
			
			if (!getfrontapplication (bs, false))
				return (false);
			
			return (setstringvalue (bs, v));
			}
		
		case bringapptofrontfunc: {
			bigstring bs;
			
			flnextparamislast = true;
			
			if (!getstringvalue (hparam1, 1, bs))
				return (false);
			
			(*v).data.flvalue = activateapplication (bs);
			
			return (true);
			}
		
		case countappsfunc:
			if (!langcheckparamcount (hparam1, 0))
				return (false);
			
			return (setlongvalue (countapplications (), v));
		
		case getnthappfunc: {
			short n;
			bigstring bs;
			
			if (!getintvalue (hparam1, 1, &n))
				return (false);
			
			if (!getnthapplication (n, bs))
				setemptystring (bs);
			
			return (setstringvalue (bs, v));
			}
		
		case getapppathfunc: {
			bigstring bs;
			tyfilespec fs;
			
			flnextparamislast = true;
			
			if ( ! getstringvalue ( hparam1, 1, bs ) )
				return ( false );
			
			if ( ! getapplicationfilespec ( bs, &fs ) ) // 2006-02-17 aradke: initializes fs even if it fails
				setemptystring (bs);
				
			return ( setfilespecvalue ( &fs, v ) );
			}
		
		case memavailfunc:
			{
			unsigned long memavail;

			#ifdef WIN95VERSION
				MEMORYSTATUS meminfo;

				meminfo.dwLength = sizeof (MEMORYSTATUS);

				GlobalMemoryStatus (&meminfo);

				memavail = meminfo.dwAvailVirtual;
			#endif

			#ifdef MACVERSION
				memavail = TempFreeMem();
			#endif
			
			if (!langcheckparamcount (hparam1, 0)) /*shouldn't have any parameters*/
				return (false);
			
			return (setlongvalue (memavail, v));
			}
		
		case machinefunc:
			
			#ifdef MACVERSION
				//Code change by Timothy Paustian Friday, June 16, 2000 3:13:09 PM
				//Changed to Opaque call for Carbon
				//Carbon only runs on PPC
				#if TARGET_API_MAC_CARBON
				return (setstringvalue (machinePPC, v));
				#else
				#if GENERATINGPOWERPC
				return (setstringvalue (machinePPC, v));
				#endif
				#if GENERATING68K
				return (setstringvalue (machine68K, v));
				#endif
				#endif

				
			#endif
			
			#ifdef WIN95VERSION
				return (setstringvalue (machinex86, v));
			#endif

			break;

		case osfunc:
			return (sysos (v));
			break;

		#ifdef WIN95VERSION
			case getenvironmentvariablefunc: {
				bigstring bsenvname;
				bigstring buf;
				DWORD res;
				
				flnextparamislast = true;
				
				if (!getstringvalue (hparam1, 1, bsenvname))
					return (false);

				nullterminate(bsenvname);

				res = GetEnvironmentVariable (stringbaseaddress(bsenvname), stringbaseaddress(buf), sizeof(buf)-2);

				if (res > sizeof(buf) - 2) {
					return (setbooleanvalue (false, v));		//safety valve
					}

				setstringlength (buf, res);

				return (setstringvalue (buf, v));
				}
				break;

			case setenvironmentvariablefunc: {
				bigstring bsenvname;
				bigstring bsenvval;
				bigstring bserror, bserror2;
				boolean res;
				
				if (!getstringvalue (hparam1, 1, bsenvname))
					return (false);

				flnextparamislast = true;
				
				if (!getstringvalue (hparam1, 2, bsenvval))
					return (false);

				nullterminate(bsenvname);
				nullterminate(bsenvval);

				res = SetEnvironmentVariable (stringbaseaddress(bsenvname), stringbaseaddress(bsenvval));

				if (res) {
					return (setbooleanvalue (true, v));	
					}

				getsystemerrorstring (GetLastError(), bserror);

				nullterminate(bserror);

				wsprintf (bserror2, "Can't set environment variable \"%s\" to \"%s\" because %s", stringbaseaddress (bsenvname), stringbaseaddress (bsenvval), stringbaseaddress (bserror));

				setstringlength (bserror2, strlen(stringbaseaddress(bserror2)));

				shellerrormessage (bserror2);

				return (setbooleanvalue (false, v));	
				}
				break;
		#endif
		
		#if TARGET_API_MAC_CARBON == 1
		
			case unixshellcommandfunc: { /*7.0b51 PBS: call shell on OS X*/
			
				Handle hcommand, hreturn;
				
				flnextparamislast = true;
				
				if (!getexempttextvalue (hparam1, 1, &hcommand))
					return (false);
				
				newemptyhandle (&hreturn);
										
				if (!unixshellcall (hcommand, hreturn)) {
				
					disposehandle (hreturn);
					
					disposehandle (hcommand);
					
					return (false);
					} /*if*/
				
				disposehandle (hcommand);
					
				return (setheapvalue (hreturn, stringvaluetype, v));
				}
		
		#endif 
		
		#ifdef WIN95VERSION

			case winshellcommandfunc: {
				Handle hcommand;
				Handle houttext = nil;
				Handle herrtext = nil;
				long exitcode = 0;
				tyaddress adrexitcode, adrstderr;
				short ctconsumed = 1;
				short ctpositional = 1;
				boolean flneedexitcode, flneedstderr;
				tyvaluerecord val;
				
				if (!getexempttextvalue (hparam1, 1, &hcommand))
					return (false);
				
				if (!getoptionaladdressparam (hparam1, &ctconsumed, &ctpositional, "\x0b" "adrExitCode", &adrexitcode.ht, adrexitcode.bs))
					return (false);
				
				flnextparamislast = true;
				
				if (!getoptionaladdressparam (hparam1, &ctconsumed, &ctpositional, "\x0b" "adrStdErr", &adrstderr.ht, adrstderr.bs))
					return (false);
				
				flneedexitcode = (adrexitcode.ht != nil) || !isemptystring (adrexitcode.bs);
				
				flneedstderr = (adrstderr.ht != nil) || !isemptystring (adrstderr.bs);

				newemptyhandle (&houttext);

				if (flneedstderr)
					newemptyhandle (&herrtext);
										
				if (!winshellcall (hcommand, houttext, herrtext,
										(flneedexitcode ? &exitcode : nil))) {
				
					disposehandle (houttext);
					
					disposehandle (herrtext);
					
					disposehandle (hcommand);
					
					return (false);
					} /*if*/
				
				disposehandle (hcommand);
				
				if (flneedexitcode) {

					setlongvalue (exitcode, &val);
					
					if (!langsetsymboltableval (adrexitcode.ht, adrexitcode.bs, val))
						return (false);
					}
					
				if (flneedstderr) {

					setheapvalue (herrtext, stringvaluetype, &val);
					
					if (!langsetsymboltableval (adrstderr.ht, adrstderr.bs, val))
						return (false);
					
					exemptfromtmpstack (&val);
					}
					
				return (setheapvalue (houttext, stringvaluetype, v));
				}

		#endif //WIN95VERSION
		
		default:
			break;
		}

	getstringlist (langerrorlist, unimplementedverberror, bserror);

	return (false);
	} /*sysfunctionvalue*/
Esempio n. 19
0
static boolean threadfunctionvalue (short token, hdltreenode hparam1, tyvaluerecord *vreturned, bigstring bserror) {
	
	/*
	4.1b3 dmb: new verbs
	
	4.1b5 dmb: added thread.sleep
	
	4.1b6 dmb: make thread.sleepFor take seconds, not ticks
	
	5.0d13 dmb: added v == nil check
	*/
	
	register tyvaluerecord *v = vreturned;
	typrocessid processid;
	unsigned long ticks;
	
	if (v == nil) { /*need Frontier process?*/
		
		switch (token) {
			
			case evaluatefunc:
			case callscriptfunc:
			case sleepfunc:
			case sleepforfunc:
			case sleepticksfunc:
			case issleepingfunc:
			case wakefunc:
			case killfunc:
			/*
			case begincriticalfunc:
			case endcriticalfunc:
			*/
			case statsfunc:
				return (true);
			
			case existsfunc:
			case getcurrentfunc:
			case getcountfunc:
			case getnththreadfunc:
			case gettimeslicefunc:
			case getdefaulttimeslicefunc:
			case settimeslicefunc:
			case setdefaulttimeslicefunc:
			default:
				return (false);
			}
		}
	
	setbooleanvalue (false, v); // assume the worst
	
	processid = getcurrentprocessid ();
	
	if (!iscurrentapplication (processid)) {
		
		getstringlist (langerrorlist, cantbackgroundclipboard, bserror);	// ***
		
		return (false);
		}
	
	switch (token) {
		
		case existsfunc: {
			long id;
			
			flnextparamislast = true;
			
			if (!getlongvalue (hparam1, 1, &id))
				return (false);
			
			return (setbooleanvalue (getprocessthread (id) != nil, v));
			}
		
		case evaluatefunc: {
			Handle htext;
			hdlprocessrecord hp;
			hdlprocessthread hthread;
			
			flnextparamislast = true;
			
			if (!getexempttextvalue (hparam1, 1, &htext))
				return (false);
			
			newlyaddedprocess = nil; //process manager global
			
			if (!processruntext (htext))
				return (false);
			
			hp = newlyaddedprocess; //process.c global; will be nil if a process wasn't just added
			
			if ((hp == nil) || !scheduleprocess (hp, &hthread))
				return (setlongvalue (0, v));
			
			(**hp).processstartedroutine = &threadverbprocessstarted;

			return (setlongvalue (getthreadid (hthread), v));
			}
		
		case callscriptfunc: {

			bigstring bsscriptname;
			tyvaluerecord vparams;
			hdlhashtable hcontext = nil;
			boolean fl;
	
			if (!getstringvalue (hparam1, 1, bsscriptname))
				return (false);
	
			if (!getparamvalue (hparam1, 2, &vparams))
				return (false);
	
			if (vparams.valuetype != recordvaluetype)
				if (!coercetolist (&vparams, listvaluetype))
					return (false);
	
			if (langgetparamcount (hparam1) > 2) {
		
				flnextparamislast = true;

				if (!gettablevalue (hparam1, 3, &hcontext))
					return (false);
				}
				
			(**(getcurrentthreadglobals ())).debugthreadingcookie = token;

			fl = threadcallscriptverb (bsscriptname, vparams, hcontext, v);
			
			(**(getcurrentthreadglobals ())).debugthreadingcookie = 0;

			return (fl);
			}

		case getcurrentfunc:
			if (!langcheckparamcount (hparam1, 0))
				return (false);
			
			return (setlongvalue (getthreadid (getcurrentthread ()), v));
		
		case getcountfunc:
			if (!langcheckparamcount (hparam1, 0))
				return (false);
			
			return (setlongvalue (processthreadcount (), v));
		
		case getnththreadfunc: {
			short n;
			
			flnextparamislast = true;
			
			if (!getintvalue (hparam1, 1, &n))
				return (false);
			
			return (setlongvalue (getthreadid (nthprocessthread (n)), v));
			}
		
		case sleepfunc: {
			hdlprocessthread hthread;
			
			flnextparamislast = true;
			
			if (!getthreadvalue (hparam1, 1, &hthread))
				return (false);
			
			return (setbooleanvalue (processsleep (hthread, -1), v));
			}
		
		case sleepforfunc: {
			long n;
			boolean fl;
			
			flnextparamislast = true;
			
			if (!getlongvalue (hparam1, 1, &n))
				return (false);
			
			(**(getcurrentthreadglobals ())).debugthreadingcookie = token;

			fl = processsleep (getcurrentthread (), n * 60);
			
			(**(getcurrentthreadglobals ())).debugthreadingcookie = 0;

			return (setbooleanvalue (fl, v));
			}
		
		case sleepticksfunc: {
			long n;
			boolean fl;
			
			flnextparamislast = true;
			
			if (!getlongvalue (hparam1, 1, &n))
				return (false);
			
			(**(getcurrentthreadglobals ())).debugthreadingcookie = token;

			fl = processsleep (getcurrentthread (), n);
			
			(**(getcurrentthreadglobals ())).debugthreadingcookie = 0;

			return (setbooleanvalue (fl, v));
			}

		case issleepingfunc: {
			hdlprocessthread hthread;
			
			flnextparamislast = true;
			
			if (!getthreadvalue (hparam1, 1, &hthread))
				return (false);
			
			return (setbooleanvalue (processissleeping (hthread), v));
			}
		
		case wakefunc: {
			hdlprocessthread hthread;
			
			flnextparamislast = true;
			
			if (!getthreadvalue (hparam1, 1, &hthread))
				return (false);
			
			return (setbooleanvalue (wakeprocessthread (hthread), v));
			}
		
		case killfunc: {
			hdlprocessthread hthread;
			
			flnextparamislast = true;
			
			if (!getthreadvalue (hparam1, 1, &hthread))
				return (false);
			
			return (setbooleanvalue (killprocessthread (hthread), v));
			}
		
		case gettimeslicefunc:
			if (!langcheckparamcount (hparam1, 0))
				return (false);
			
			getprocesstimeslice (&ticks);

			return (setlongvalue (ticks, v));
		
		case settimeslicefunc:
			flnextparamislast = true;

			if (!getlongvalue (hparam1, 1, (long *) (&ticks)))
				return (false);
			
			return (setbooleanvalue (setprocesstimeslice (ticks), v));
	
		case getdefaulttimeslicefunc:
			if (!langcheckparamcount (hparam1, 0))
				return (false);
			
			getdefaulttimeslice (&ticks);

			return (setlongvalue (ticks, v));
		
		case setdefaulttimeslicefunc:
			flnextparamislast = true;

			if (!getlongvalue (hparam1, 1, (long *) (&ticks)))
				return (false);
			
			return (setbooleanvalue (setdefaulttimeslice (ticks), v));
		/*
		case begincriticalfunc:
			if (!langcheckparamcount (hparam1, 0))
				return (false);
			
			++fldisableyield;
			
			return (setbooleanvalue (true, v));
		
		case endcriticalfunc:
			if (!langcheckparamcount (hparam1, 0))
				return (false);
			
			if (fldisableyield > 0) {
			
				--fldisableyield;
				
				(*v).data.flvalue = true;
				}
			
			return (true);
		*/
		case statsfunc:
			return (threadstatsverb (hparam1, v));

		default:
			return (false);
		}
	} /*threadfunctionvalue*/
Esempio n. 20
0
static boolean launchfunctionvalue (short token, hdltreenode hparam1, tyvaluerecord *vreturned, bigstring bserror) {
	
	/*
	3/10/92 dmb: added launch.appWithDocument.  check default paths
	
	5/6/93 dmb: make sure that we return false is an oserror has occurred
	*/
	
	register tyvaluerecord *v = vreturned;
	
	setbooleanvalue (false, v); /*assume the worst*/
	
	oserror (noErr); /*clear now so we can check it at end*/
	
	switch (token) { /*these verbs don't need any special globals pushed*/
		
		#ifdef MACVERSION
		case applemenufunc: {
			bigstring bs;
			
			flnextparamislast = true;
			
			if (!getstringvalue (hparam1, 1, bs))
				return (false);
			
			(*v).data.flvalue = shellapplemenu (bs);
			
			break;
			}
		#endif
		
		case launchappfunc: {
			tyfilespec fsapp;
			
			flnextparamislast = true;
			
			if (!getfilespecvalue (hparam1, 1, &fsapp))
				return (false);
			
			(*v).data.flvalue = launchapplication (&fsapp, nil, false);
			
			break;
			}
		
		case launchappwithdocfunc: {
			tyfilespec fsapp, fsdoc;
			
			if (!getfilespecvalue (hparam1, 1, &fsapp))
				return (false);
			
			flnextparamislast = true;
			
			if (!getfilespecvalue (hparam1, 2, &fsdoc))
				return (false);
			
			(*v).data.flvalue = launchapplication (&fsapp, &fsdoc, false);
			
			break;
			}
		
		case executeresourcefunc: {
			ResType type;
			short id;
			
			if (!getostypevalue (hparam1, 1, &type))
				return (false);
			
			flnextparamislast = true;
			
			if (!getintvalue (hparam1, 2, &id))
				return (false);
			
			(*v).data.flvalue = executeresource (type, id, nil);
			
			break;
			}
		
		case anythingfunc:
			#ifdef MACVERSION
				return (filelaunchanythingverb (hparam1, v));
			#endif
			#ifdef WIN95VERSION
			#pragma message ("WIN95: anythingfunc - not yet implemented! (uses filelaunchanthingverb)")
				getstringlist (langerrorlist, unimplementedverberror, bserror);

				return (false);
			#endif
		
		default:
			getstringlist (langerrorlist, unimplementedverberror, bserror);

			return (false);
		}
	
	return (getoserror () == noErr);
	} /*launchfunctionvalue*/
Esempio n. 21
0
static boolean wpfunctionvalue (short token, hdltreenode hparam1, tyvaluerecord *vreturned, bigstring bserror) {
	
	/*
	bridges wp.c with the language.  the name of the verb is bs, its first parameter
	is hparam1, and we return a value in vreturned.
	
	we use a limited number of support routines from lang.c to get parameters and
	to return values. 
	
	return false only if the error is serious enough to halt the running of the script
	that called us, otherwise error values are returned through the valuerecord, which
	is available to the script.
	
	if we return false, we try to provide a descriptive error message in the 
	returned string bserror.
	
	12/30/91 dmb: use wpinserthandle for insertfunc
	
	5/17/92 dmb: setselectfunc now uses longs, as it should always have
	
	6/1/93 dmb: when vreturned is nil, return whether or not verb token must 
	be run in the Frontier process
	
	5.0.2b17 dmb: insert, settext get readonly handles
	*/
	
	register tyvaluerecord *v = vreturned;
	register boolean fl;
	WindowPtr targetwindow;
	short idprocessor = idwordprocessor;
	
	if (v == nil)
		return (true);
	
	errornum = 0;
	
	setbooleanvalue (false, v); /*by default, wp functions return true*/
	
	switch (token) {
		
		/*
		case packtextfunc:
			if (!wppacktextverb (hparam1, v))
				goto error;
			
			return (true);
		
		case unpacktextfunc:
			if (!wpunpacktextverb (hparam1, v))
				goto error;
			
			return (true);
		*/
		
		case intextmodefunc: /*verb that don't require wp-specific target*/
		case settextmodefunc:
			idprocessor = -1;
			
			break;
		}
	
	/*all other verbs require a wp window in front -- set wpengine.c globals*/
	
	if (!langfindtargetwindow (idprocessor, &targetwindow)) {
		
		errornum = nowperror;
		
		goto error;
		}
	
	shellpushglobals (targetwindow);
	
	(*shellglobals.gettargetdataroutine) (idprocessor); /*set wp globals*/
	
	fl = false; /*default return value*/
	
	switch (token) {
		
		case intextmodefunc: {
			WindowPtr textwindow;
			
			if (!langcheckparamcount (hparam1, 0))
				break;
			
			fl = setbooleanvalue (langfindtargetwindow (idwordprocessor, &textwindow), v);
			
			break;
			}
		
		case settextmodefunc: {
			boolean flenter;
			
			flnextparamislast = true;
			
			if (!getbooleanvalue (hparam1, 1, &flenter))
				break;
			
			fl = setbooleanvalue ((*shellglobals.settextmoderoutine) (flenter), v);
			
			break;
			}
		
		case gettextfunc: {
			Handle htext;
			
			if (!langcheckparamcount (hparam1, 0))
				break;
			
			if (!wpgettexthandle (&htext))
				break;
			
			fl = setheapvalue (htext, stringvaluetype, v);
			
			break;
			}
		
		case settextfunc: {
			Handle htext;
			
			flnextparamislast = true;
			
			if (!getreadonlytextvalue (hparam1, 1, &htext))
				break;
			
			if (!wpsettexthandle (htext))
				break;
			
			fl = setbooleanvalue (true, v);
			
			break;
			}
		
		case getseltextfunc: {
			/*
			bigstring bs;
			*/
			Handle htext;
			
			if (!langcheckparamcount (hparam1, 0))
				break;
			
			if (!wpgetseltexthandle (&htext))
				break;
			
			fl = setheapvalue (htext, stringvaluetype, v);
			
			/*
			wpgetseltext (bs);
			
			fl = setstringvalue (bs, v);
			*/
			
			break;
			}
		
		case getdisplayfunc:
			
			if (!langcheckparamcount (hparam1, 0)) /*too many parameters were passed*/
				break;
			
			(*v).data.flvalue = !(**wpdata).flinhibitdisplay;
			
			fl = true;
			
			break;
		
		case setdisplayfunc: {
			boolean fldisplay;
			
			flnextparamislast = true;
			
			if (!getbooleanvalue (hparam1, 1, &fldisplay))
				break;
			
			(*v).data.flvalue = wpsetdisplay (fldisplay);
			
			fl = true;
			
			break;
			}
		
		case getrulerfunc:
			
			if (!langcheckparamcount (hparam1, 0))
				break;
			
			(*v).data.flvalue = wpgetruler ();
			
			fl = true;
			
			break;
		
		case setrulerfunc: {
			boolean flruler;
			
			flnextparamislast = true;
			
			if (!getbooleanvalue (hparam1, 1, &flruler))
				break;
			
			(*v).data.flvalue = wpsetruler (flruler);
			
			fl = true;
			
			break;
			}
		
		case getindentfunc: {
			short indent;
			
			if (!langcheckparamcount (hparam1, 0))
				break;
			
			wpgetindent (&indent);
			
			fl = setlongvalue (indent, v);
			
			break;
			}
			
		case setindentfunc: {
			short indent;
			
			flnextparamislast = true;
			
			if (!getintvalue (hparam1, 1, &indent))
				break;
			
			(*v).data.flvalue = wpsetindent (indent);
			
			fl = true;
			
			break;
			}
			
		case getleftmarginfunc: {
			short leftmargin;
			
			if (!langcheckparamcount (hparam1, 0))
				break;
			
			wpgetleftmargin (&leftmargin);
			
			fl = setlongvalue (leftmargin, v);
			
			break;
			}
			
		case setleftmarginfunc: {
			short leftmargin;
			
			flnextparamislast = true;
			
			if (!getintvalue (hparam1, 1, &leftmargin))
				break;
			
			(*v).data.flvalue = wpsetleftmargin (leftmargin);
			
			fl = true;
			
			break;
			}
			
		case getrightmarginfunc: {
			short rightmargin;
			
			if (!langcheckparamcount (hparam1, 0))
				break;
			
			wpgetrightmargin (&rightmargin);
			
			fl = setlongvalue (rightmargin, v);
			
			break;
			}
			
		case setrightmarginfunc: {
			short rightmargin;
			
			flnextparamislast = true;
			
			if (!getintvalue (hparam1, 1, &rightmargin))
				break;
			
			(*v).data.flvalue = wpsetrightmargin (rightmargin);
			
			fl = true;
			
			break;
			}
		
		case setspacingfunc: {
			short spacing;
			
			flnextparamislast = true;
			
			if (!getintvalue (hparam1, 1, &spacing))
				break;
			
			(**wpwindowinfo).selectioninfo.leading = spacing;
			
			fl = setbooleanvalue (wpsetleading (), v);
			
			break;
			}
		
		case setjustificationfunc: {
			short justification;
			
			flnextparamislast = true;
			
			if (!getintvalue (hparam1, 1, &justification))
				break;
			
			(**wpwindowinfo).selectioninfo.justification = (tyjustification) (justification - 1);
			
			fl = setbooleanvalue (wpsetjustify (), v);
			
			break;
			}
		
		case settabfunc: {
			short pos;
			short type;
			char fill;
			
			if (!getintvalue (hparam1, 1, &pos))
				break;
			
			if (!getintvalue (hparam1, 2, &type)) /*1 for left tab; 2 center; etc.*/
				break;
			
			flnextparamislast = true;
			
			if (!getcharvalue (hparam1, 3, &fill))
				break;
			
			fl = setbooleanvalue (wpsettab (pos, type - 1, fill), v);
			
			break;
			}
		
		case cleartabsfunc: {
			if (!langcheckparamcount (hparam1, 0))
				break;
			
			fl = setbooleanvalue (wpcleartabs (), v);
			
			break;
			}
		
		case getselectfunc: {
			long startsel, endsel;
			
			wpgetselection (&startsel, &endsel);
			
			if (!langsetlongvarparam (hparam1, 1, startsel))
				return (false);
			
			flnextparamislast = true;
			
			if (!langsetlongvarparam (hparam1, 2, endsel))
				return (false);
			
			(*v).data.flvalue= true;
			
			fl = true;
			
			break;
			}
		
		case setselectfunc: {
			long startsel, endsel;
			
			if (!getlongvalue (hparam1, 1, &startsel))
				break;
			
			flnextparamislast = true;
			
			if (!getlongvalue (hparam1, 2, &endsel))
				break;
			
			wpsetselection (startsel, endsel);
			
			(*v).data.flvalue= true;
			
			fl = true;
			
			break;
			}
		
		case insertfunc: {
			Handle x;

			flnextparamislast = true;
			
			if (!getreadonlytextvalue (hparam1, 1, &x))
				break;
			
			wptrimhiddentext ();
			
			if (!wpinserthandle (x))
				break;
			
			(*v).data.flvalue = true;
			
			fl = true;
			
			break;
			}
		
		/*
		case findfunc: {
			bigstring bs;
			
			flnextparamislast = true;
			
			if (!getstringvalue (hparam1, 1, bs))
				break;
			
			(*v).data.flvalue = wpsearch (bs, false, false, false, false);
			
			fl = true;
			
			break;
			}
		
		case replacefunc:
			if (!langcheckparamcount (hparam1, 0))
				break;
			
			(*v).data.flvalue = wpinsert (searchparams.bsreplace);
			
			fl = true;
			
			break;
		*/
		
		#if false
		
		case writetofilefunc: {
			bigstring bs;
			
			flnextparamislast = true;
			
			if (!getstringvalue (hparam1, 1, bs))
				break;
			
			(*v).data.flvalue = wpwritetofile (bs);
			
			fl = true;
			
			break;
			}
			
		case readfromfilefunc: {
			bigstring bs;
			
			flnextparamislast = true;
			
			if (!getstringvalue (hparam1, 1, bs))
				break;
			
			(*v).data.flvalue = wpreadfromfile (bs);
			
			fl = true;
			
			break;
			}
		
		case readfromtextfilefunc: {
			bigstring bs;
			
			flnextparamislast = true;
			
			if (!getstringvalue (hparam1, 1, bs))
				break;
			
			(*v).data.flvalue = wpreadfromtextfile (bs);
			
			fl = true;
			
			break;
			}
		
		case writetotextfilefunc: {
			bigstring bs;
			
			flnextparamislast = true;
			
			if (!getstringvalue (hparam1, 1, bs))
				break;
			
			(*v).data.flvalue = wpwritetotextfile (bs);
			
			fl = true;
			
			break;
			}
		
		#endif
		
		#ifdef flvariables
		
		case newvariablefunc: {
			bigstring bs, bsvalue;
			
			if (!getstringvalue (hparam1, 1, bs))
				break;
			
			flnextparamislast = true;
			
			if (!getstringvalue (hparam1, 2, bsvalue))
				break;
			
			(*v).data.flvalue = wpnewvariable (bs, bsvalue);
			
			fl = true;
			
			break;
			}
		
		case deletevariablefunc: {
			bigstring bs;
			
			flnextparamislast = true;
			
			if (!getstringvalue (hparam1, 1, bs))
				break;
			
			(*v).data.flvalue = wpdeletevariable (bs);
			
			fl = true;
			
			break;
			}
		
		case getnthvariablefunc: {
			short ix;
			bigstring bs;
			
			flnextparamislast = true;
			
			if (!getintvalue (hparam1, 1, &ix))
				break;
			
			if (!wpgetnthvariable (ix, bs))
				setemptystring (bs);
			
			fl = setstringvalue (bs, v);
			
			break;
			}
		
		case setvariablevaluefunc: {
			bigstring bs, bsvalue;
			
			if (!getstringvalue (hparam1, 1, bs))
				break;
			
			flnextparamislast = true;
			
			if (!getstringvalue (hparam1, 2, bsvalue))
				break;
			
			(*v).data.flvalue = wpsetvariablevalue (bs, bsvalue);
			
			fl = true;
			
			break;
			}
		
		case getvariablevaluefunc: {
			bigstring bs, bsvalue;
			
			flnextparamislast = true;
			
			if (!getstringvalue (hparam1, 1, bs))
				break;
			
			if (!wpgetvariablevalue (bs, bsvalue))
				setemptystring (bsvalue);
			
			fl = setstringvalue (bsvalue, v);
			
			break;
			}
		
		case insertvariablefunc: {
			bigstring bs;
			
			flnextparamislast = true;
			
			if (!getstringvalue (hparam1, 1, bs))
				break;
			
			(*v).data.flvalue = wpinsertvariable (bs);
			
			fl = true;
			
			break;
			}
		
		case getevalfunc:
			if (!langcheckparamcount (hparam1, 0))
				break;
			
			(*v).data.flvalue = wpgetevaluate ();
			
			fl = true;
			
			break;
		
		case setevalfunc: {
			boolean flexpand;
			
			flnextparamislast = true;
			
			if (!getbooleanvalue (hparam1, 1, &flexpand))
				break;
			
			(*v).data.flvalue = wpsetevaluate (flexpand);
			
			fl = true;
			
			break;
			}
		
		case hilitevariablesfunc: {
			boolean flhilite;
			
			flnextparamislast = true;
			
			if (!getbooleanvalue (hparam1, 1, &flhilite))
				break;
			
			(*v).data.flvalue = wphilitevariables (flhilite);
			
			fl = true;
			
			break;
			}
		
		#endif
		
		case rulerlengthfunc:
			if (!langcheckparamcount (hparam1, 0))
				break;
			
			fl = setlongvalue (wpavailwidth (), v);
			
			break;
		
		case gofunc: {
			tydirection dir;
			long dist;
			
			if (!getdirectionvalue (hparam1, 1, &dir))
				break;
			
			flnextparamislast = true;
			
			if (!getlongvalue (hparam1, 2, &dist))
				break;
			
			fl = setbooleanvalue (wpgo (dir, dist), v);
			
			break;
			}
		
		case selectwordfunc:
			if (!langcheckparamcount (hparam1, 0))
				break;
			
			fl = setbooleanvalue (wpselectword (), v);
			
			break;
		
		case selectlinefunc:
			if (!langcheckparamcount (hparam1, 0))
				break;
			
			fl = setbooleanvalue (wpselectline (), v);
			
			break;
		
		case selectparafunc:
			if (!langcheckparamcount (hparam1, 0))
				break;
			
			fl = setbooleanvalue (wpselectpara (), v);
			
			break;
		
		} /*switch*/
	
	shellupdatescrollbars (shellwindowinfo);
	
	shellsetselectioninfo (); /*force ruler update*/
	
	shellpopglobals ();
	
	return (fl);
	
	error:
	
	if (errornum != 0) /*get error string*/
		getstringlist (wperrorlist, errornum, bserror);
	
	return (false);
	} /*wpfunctionvalue*/
Esempio n. 22
0
static boolean deletemenucommandverb (hdltreenode hparam1, boolean flsubmenu, tyvaluerecord *v) {
	
	/*
	menu/op globals are _not_ set.  delete a menu item or submenu from a 
	menubar, depending on the parameters specified.
	
	5.0a4 dmb: call ophassubheads with menu's outline globals pushed
	*/
	
	register hdltreenode hp1 = hparam1;
	register hdloutlinerecord ho;
	register hdlmenurecord hm;
	hdlheadrecord hnode;
	hdlmenurecord hmenurecord;
	bigstring bsmenu;
	bigstring bsitem;
	hdlwindowinfo hinfo;
	tyfindinfo findinfo;
	boolean flchanged;
	
	if (!getmenuparaminmemory (hparam1, &hmenurecord))
		return (false);
	
	if (flsubmenu)
		flnextparamislast = true;
	
	if (!getstringvalue (hp1, 2, bsmenu))
		return (false);
	
	if (!flsubmenu) {
		
		flnextparamislast = true;
		
		if (!getstringvalue (hp1, 3, bsitem))
			return (false);
		}
	
	/*
	move headline to menu headline
	*/
	
	hm = hmenurecord;
	
	ho = (**hm).menuoutline;
	
	findinfo.pfind = bsmenu;
	
	hnode = (**ho).hsummit;
	
	if (opsiblingvisiter (hnode, false, &findheadlinevisit, &findinfo)) /*didn't find the menu*/
		return (true);
	
	hnode = findinfo.hfound;
	
	/*
	move headline to item headline
	*/
	
	if (!flsubmenu) {
		
		if (!isemptystring (bsitem)) {
			
			findinfo.pfind = bsitem;
			
			if (oprecursivelyvisit (hnode, 1, &findheadlinevisit, &findinfo)) /*didn't find the item*/
				return (true);
			
			hnode = findinfo.hfound;
			}
		}
	
	/*
	delete the menu item
	*/
	
	if (shellfinddatawindow ((Handle) hm, &hinfo)) {
		
		shellpushglobals ((**hinfo).macwindow);
		
		pushundoaction (0); /*no undo*/
		}
	else
		mepushmenudata (hm);
	
	if (ophassubheads (hnode) && !flsubmenu) /*it's not a single command*/
		flchanged = false;
	
	else {
		
		(**ho).fldirty = true; /*dirty the menubar outline*/
		
		deletemenunode (hnode);
		
		flchanged = true;
		}
	
	if (hinfo != nil)
		shellpopglobals ();
	else
		mepopmenudata ();
	
	if (flchanged)
		langexternalsetdirty ((hdlexternalvariable) rootvariable, true); /*make sure changes are flagged*/
	
	/*
	if (htable == menubartable)
		langsymbolchanged (htable, bs, true);
	*/
	
	(*v).data.flvalue = flchanged;
	
	return (true);
	} /*deletemenucommandverb*/
Esempio n. 23
0
static boolean addmenucommandverb (hdltreenode hparam1, boolean flsubmenu, tyvaluerecord *v) {
	
	/*
	menu/op globals are _not_ set.  add a new menu item or submenu to a menubar, 
	or replace the script of any existing item, depending on the parameters 
	specified.
	
	9/11/92 dmb: when adding a submenu, delete existing item with same name
	
	9/28/92 dmb: move to the newly-deposited node
	
	2.1b4 dmb: set outlinesignature of newly-created scripts to 'LAND'
	*/
	
	register hdltreenode hp1 = hparam1;
	register hdloutlinerecord ho;
	register hdlmenurecord hm;
	hdlheadrecord hnode;
	hdlheadrecord hdelete = nil;
	hdlmenurecord hmenurecord;
	bigstring bsmenu;
	bigstring bsitem;
	bigstring bsscript;
	tydirection dir;
	hdlwindowinfo hinfo;
	boolean fl;
	hdlheadrecord hsubmenu;
	boolean flmainmenu = false;
	tyfindinfo findinfo;
	
	fl = false; /*default return*/
	
	if (!getmenuparaminmemory (hp1, &hmenurecord)) /*the menu to be changed*/
		return (false);
	
	if (!getstringvalue (hp1, 2, bsmenu)) /*the title of the menu to add to*/
		return (false);
	
	if (flsubmenu) {
		
		flnextparamislast = true;
		
		if (!getsubmenuvalue (hp1, 3, &hsubmenu)) /*the submenu to be inserted*/
			return (false);
		
		flmainmenu = isemptystring (bsmenu); /*caller wants this to be a main menu*/
		
		if (flmainmenu)
			opgetheadstring (hsubmenu, bsmenu);
		else
			opgetheadstring (hsubmenu, bsitem);
		}
	else {
		
		if (!getstringvalue (hp1, 3, bsitem)) /*the item in the menu to add, or replace*/
			return (false);
		
		flnextparamislast = true;
		
		if (!getstringvalue (hp1, 4, bsscript)) /*the text of the script to be set*/
			return (false);
		}
	
	/*
	set up globals
	*/
	
	hm = hmenurecord;
	
	ho = (**hm).menuoutline;
	
	if (shellfinddatawindow ((Handle) hm, &hinfo)) {
		
		shellpushglobals ((**hinfo).macwindow);
		
		pushundoaction (0); /*no undo*/
		}
	else
		mepushmenudata (hm);
	
	/*
	move headline to menu headline, creating it if necessary
	*/
	
	findinfo.pfind = bsmenu;
	
	hnode = (**ho).hsummit;
	
	dir = down;
	
	if (!opsiblingvisiter (hnode, false, &findheadlinevisit, &findinfo)) { /*found the menu*/
		
		hnode = findinfo.hfound;
		
		if (flmainmenu) { /*delete it so it can be replaced*/
			
			hdelete = hnode;
			
			goto gotposition;
			}
		}
	else {
		
		hnode = oprepeatedbump (down, longinfinity, hnode, false);
		
		if (flmainmenu)
			goto gotposition;
		
		if (!opaddheadline (hnode, down, bsmenu, &hnode))
			goto exit;
		}
	
	/*
	move headline to item headline, creating it if necessary
	*/
	
	findinfo.pfind = bsitem;
	
	if (!oprecursivelyvisit (hnode, 1, &findheadlinevisit, &findinfo)) { /*found the item*/
		
		hnode = findinfo.hfound;
		
		if (flsubmenu) /*delete it so it can be replaced*/
			hdelete = hnode;
		}
	else {
		
		if (ophassubheads (hnode)) {
			
			hnode = oprepeatedbump (down, longinfinity, (**hnode).headlinkright, false);
			
			dir = down;
			}
		else
			dir = right;
		
		if (flsubmenu)
			goto gotposition;
		
		if (!opaddheadline (hnode, dir, bsitem, &hnode))
			goto exit;
		}
	
	gotposition:
	
	if (flsubmenu) {
		/*
		insert the submenu
		*/
		
		opdeposit (hnode, dir, hsubmenu);
		
		opresetlevels (hsubmenu);
		
		opfastcollapse (hsubmenu);
		
		if (hdelete != nil) /*delete old item*/
			deletemenunode (hdelete);
		
		opexpandto (hsubmenu);
		}
	else { 
		/*
		set up the script
		*/
	
		if (isemptystring (bsscript))
			ho = nil;
		
		else {
			hdloutlinerecord houtline;
			hdlheadrecord hsummit;
			Handle hscript;
			
			if (!newtexthandle (bsscript, &hscript))
				goto exit;
			
			if (!newoutlinerecord (&houtline)) {
				
				disposehandle (hscript);
				
				goto exit;
				}
			
			ho = houtline; /*copy script outline into register*/
			
			if (!opnewstructure (hscript, &hsummit)) {
				
				opdisposeoutline (ho, false);
				
				goto exit;
				}
			
			(**ho).outlinesignature = 'LAND';
			
			(**ho).fontnum = (**hm).defaultscriptfontnum;
			
			(**ho).fontsize = (**hm).defaultscriptfontsize;
			
			opsetsummit (ho, hsummit);
			
			oppushoutline (ho);
			
			opsetdisplaydefaults (ho);
			
			oppopoutline ();
			}
		
		/*
		connect it
		*/
		
		detachscript (hm, hnode);
		
		attachscript (hm, hnode, ho);
		
		opexpandto (hnode);
		}
	
	oprefreshdisplay ();
	
	// now done by oprefreshdisplay - opsetctexpanded (outlinedata); /*re-compute in case we deposited to expanded node*/
	
	opdirtyoutline (); /*dirty the menubar outline*/
	
	langexternalsetdirty ((hdlexternalvariable) rootvariable, true); /*make sure changes are flagged*/
	
	/*
	if (htable == menubartable)
		langsymbolchanged (htable, bs, true);
	*/
	
	fl = true;
	
	exit:
	
	if (hinfo != nil)
		shellpopglobals ();
	else
		mepopmenudata ();
	
	(*v).data.flvalue = fl;
	
	return (fl);
	} /*addmenucommandverb*/
Esempio n. 24
0
static boolean frontierfunctionvalue (short token, hdltreenode hparam1, tyvaluerecord *vreturned, bigstring bserror) {
#pragma unused (bserror)

	/*
	6/5/92 dmb: added isruntime func
	
	6/1/93 dmb: when vreturned is nil, return whether or not verb token must 
	be run in the Frontier process
	*/
	
	register tyvaluerecord *v = vreturned;
	
	if (v == nil) { /*need Frontier process?*/
		
		switch (token) {
			
			case requesttofrontfunc:
				return (true);
			
			default:
				return (false);
			}
		}
	
	setbooleanvalue (false, v); /*assume the worst*/
	
	switch (token) { /*these verbs don't need any special globals pushed*/
		
		case programpathfunc: {
			
			if (!langcheckparamcount (hparam1, 0))
				return (false);
			
			return (setfilespecvalue (&programfspec, v));
			
			}
		
		case filepathfunc: {
			tyfilespec fs;
			
			if (!langcheckparamcount (hparam1, 0))
				return (false);
			
			#if flruntime
			
			fs = currentfile.fspec;
			
			#else
			
			shellpushfrontrootglobals ();
			
			windowgetfspec (shellwindow, &fs);
			
			shellpopglobals ();
			
			#endif
			
			return (setfilespecvalue (&fs, v));
			}
		
		#if !flruntime
		
		case agentsenablefunc: {
			boolean fl;
			
			flnextparamislast = true;
			
			if (!getbooleanvalue (hparam1, 1, &fl))
				return (false);
			
			(*v).data.flvalue = setagentsenable (fl);
			
			return (true);
			}
		
		#endif
		
		case requesttofrontfunc: {
			bigstring bsmessage;
			
			flnextparamislast = true;
			
			if (!getstringvalue (hparam1, 1, bsmessage))
				return (false);

			#ifdef MACVERSION		
				(*v).data.flvalue = shellisactive () || notifyuser (bsmessage);
			#endif

			#ifdef WIN95VERSION
			#pragma message ("WIN95: case requesttofrontfunc,  windows case currently forced.")
				(*v).data.flvalue = shellisactive() || SetForegroundWindow (hwndActive);
			#endif

			return (true);
			}
		
		case isruntimefunc: {
			if (!langcheckparamcount (hparam1, 0))
				return (false);
			
			#if flruntime
			
			(*v).data.flvalue = true;
			
			#endif
			
			return (true);
			}
		
		case countthreadsfunc: {
			if (!langcheckparamcount (hparam1, 0))
				return (false);
			
			return (setlongvalue (processthreadcount (), v));
			}
		
		case isnativefunc:
			#if __powerc || __GNUC__
				(*v).data.flvalue = true;
			#else
			
				(*v).data.flvalue = false;
			#endif
			
			return (true);
		
		case reclaimmemoryfunc: {
			long ctbytes = longinfinity;

			if (!langcheckparamcount (hparam1, 0))
				return (false);
			
			hashflushcache (&ctbytes);

			return (setlongvalue (longinfinity - ctbytes, v));
			}
		
		case frontierversionfunc:
			return (frontierversion (v));
		
		case hashstatsfunc:{
			if (!langcheckparamcount (hparam1, 0))
				return (false);

			return (hashstatsverb (v));
			}

		case gethashloopcountfunc:{
			long myx;

			if (!langcheckparamcount (hparam1, 0))
				return (false);
				
			myx = fullpathloopcount;

			fullpathloopcount = 0;

			return (setlongvalue (myx, v));
			}

		case hideapplicationfunc: { /*7.1b9 PBS: minimize to system tray*/
			
			#ifdef WIN95VERSION
				
				releasethreadglobals ();

				ShowWindow (shellframewindow, SW_HIDE);

				grabthreadglobals ();
			
			#endif

			return (setbooleanvalue (true, v));
			}

		case isvalidserialnumberfunc: { /*7.1b34 dmb: expose the functionality as a verb*/
			bigstring bssn;
			
			flnextparamislast = true;
			
			if (!getstringvalue (hparam1, 1, bssn))
				return (false);

			(*v).data.flvalue = isvalidserialnumber (bssn);

			return (true);
			}
		
		case showapplicationfunc: {	/*2004-11-28 aradke: re-emerge from system tray*/

			#ifdef WIN95VERSION
				
				releasethreadglobals ();

				ShowWindow (shellframewindow, SW_SHOW);

				grabthreadglobals ();
			
			#endif

			return (setbooleanvalue (true, v));
			}

		default:
			return (false);
		}
	} /*frontierfunctionvalue*/