langverbs.c

Go to the documentation of this file.
00001 
00002 /*  $Id: langverbs.c 1260 2006-04-13 06:13:10Z sethdill $    */
00003 
00004 /******************************************************************************
00005 
00006     UserLand Frontier(tm) -- High performance Web content management,
00007     object database, system-level and Internet scripting environment,
00008     including source code editing and debugging.
00009 
00010     Copyright (C) 1992-2004 UserLand Software, Inc.
00011 
00012     This program is free software; you can redistribute it and/or modify
00013     it under the terms of the GNU General Public License as published by
00014     the Free Software Foundation; either version 2 of the License, or
00015     (at your option) any later version.
00016 
00017     This program is distributed in the hope that it will be useful,
00018     but WITHOUT ANY WARRANTY; without even the implied warranty of
00019     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00020     GNU General Public License for more details.
00021 
00022     You should have received a copy of the GNU General Public License
00023     along with this program; if not, write to the Free Software
00024     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00025 
00026 ******************************************************************************/
00027 
00028 #include "frontier.h"
00029 #include "standard.h"
00030 
00031 #ifdef MACVERSION
00032 #include "langxcmd.h"
00033 #endif
00034 
00035 #ifdef WIN95VERSION
00036 #include "htmlcontrol.h"
00037 #endif
00038 
00039 #include "memory.h"
00040 #include "frontierconfig.h"
00041 #include "cursor.h"
00042 #include "dialogs.h"
00043 #include "error.h"
00044 #include "font.h"
00045 #include "kb.h"
00046 #include "mouse.h"
00047 #include "ops.h"
00048 #include "quickdraw.h"
00049 #include "resources.h"
00050 #include "sounds.h"
00051 #include "strings.h"
00052 #include "frontierwindows.h"
00053 #include "shell.h"
00054 #include "shellhooks.h"
00055 #include "oplist.h"
00056 #include "lang.h"
00057 #include "langinternal.h"
00058 #include "langexternal.h"
00059 #include "langipc.h"
00060 #include "langwinipc.h"
00061 #include "langdll.h"
00062 #include "langsystem7.h"
00063 #include "langtokens.h"
00064 #include "BASE64.H"
00065 #include "tablestructure.h"
00066 #include "tableverbs.h"
00067 #include "process.h"
00068 #include "processinternal.h"
00069 #include "kernelverbdefs.h"
00070 #include "WinSockNetEvents.h"
00071 #include "notify.h"
00072 #include "timedate.h"
00073 #include "langpython.h"
00074 
00075 #ifdef WIN95VERSION
00076     #include "winregistry.h"
00077 #endif
00078 
00079 static byte nametargetval [] = "\x08" "_target_";
00080 
00081 static byte semaphorewhen [] = "\x04" "when";
00082 
00083 static byte semaphorewho [] = "\x03" "who";
00084 
00085 
00086 
00087 typedef enum tylangtoken { /*verbs that are processed by langverbs.c*/
00088     
00089     /*lang*/
00090     
00091         killscriptfunc,
00092         
00093         newfunc,
00094         
00095         disposefunc,
00096         
00097         #if !flruntime
00098         
00099         editfunc,
00100         
00101         closefunc,
00102         
00103         #endif
00104         
00105         timecreatedfunc,
00106         
00107         timemodifiedfunc,
00108         
00109         settimecreatedfunc,
00110         
00111         settimemodifiedfunc,
00112         
00113         booleanfunc, 
00114         
00115         charfunc,
00116         
00117         intfunc,
00118         
00119         longfunc,
00120         
00121         datefunc,
00122         
00123         directionfunc,
00124         
00125         ostypefunc,
00126         
00127         stringfunc,
00128         
00129         displaystringfunc,
00130         
00131         addressfunc,
00132         
00133         binaryfunc,
00134         
00135         getbinarytypefunc,
00136         
00137         setbinarytypefunc,
00138         
00139         pointfunc,
00140         
00141         rectfunc,
00142         
00143         rgbfunc,
00144         
00145         patternfunc,
00146         
00147         fixedfunc,
00148         
00149         singlefunc,
00150         
00151         doublefunc,
00152         
00153         filespecfunc,
00154         
00155         aliasfunc,
00156         
00157         listfunc,
00158         
00159         recordfunc,
00160         
00161         enumfunc,
00162         
00163         memavailfunc,
00164         
00165         flushmemfunc,
00166         
00167         randomfunc,
00168         
00169         evaluatefunc,
00170         
00171         evaluatethreadfunc,
00172         
00173         beachballfunc,
00174         
00175         absfunc,
00176         
00177         seteventtimeoutfunc,
00178         
00179         seteventtransactionidfunc,
00180         
00181         seteventinteractionlevelfunc,
00182         
00183         geteventattrfunc,
00184         
00185         coerceappleitemfunc,
00186         
00187         getlistitemfunc,
00188         
00189         putlistitemfunc,
00190         
00191         countlistitemsfunc,
00192         
00193         systemeventfunc,
00194         
00195         microsofteventfunc,
00196         
00197         transactioneventfunc,
00198         
00199         msgfunc,
00200         
00201         callxcmdfunc,
00202         
00203         calldllfunc,
00204         
00205         packwindowfunc,
00206         
00207         unpackwindowfunc,
00208 
00209         callscriptfunc,
00210         
00211     /*clock*/
00212     
00213         timefunc,
00214         
00215         settimefunc,
00216         
00217         sleepfunc,
00218         
00219         tickcountfunc,
00220         
00221         millisecondcountfunc,
00222         
00223         delayfunc,
00224         
00225         delaysixtiethsfunc,
00226         
00227     
00228     /*date*/
00229         
00230         getdatefunc,
00231         
00232         setdatefunc,
00233 
00234         abbrevstringfunc,
00235 
00236         dayofweekfunc,
00237 
00238         daysinmonthfunc,
00239 
00240         daystringfunc,
00241 
00242         firstofmonthfunc,
00243 
00244         lastofmonthfunc,
00245 
00246         longstringfunc,
00247 
00248         nextmonthfunc,
00249 
00250         nextweekfunc,
00251 
00252         nextyearfunc,
00253 
00254         prevmonthfunc,
00255 
00256         prevweekfunc,
00257 
00258         prevyearfunc,
00259 
00260         shortstringfunc,
00261 
00262         tomorrowfunc,
00263 
00264         weeksinmonthfunc,
00265 
00266         yesterdayfunc,
00267     
00268         getcurrenttimezonefunc,
00269         
00270         netstandardstringfunc, //AR 07/07/1999
00271         
00272         monthtostringfunc, //AR 07/07/1999
00273         
00274         dayofweektostringfunc, //AR 07/07/1999
00275         
00276         dateversionlessthanfunc, //AR 07/07/1999
00277         
00278         datedayfunc,    // SMD 2005-04-07
00279         
00280         datemonthfunc,  // SMD 2005-04-07
00281         
00282         dateyearfunc,   // SMD 2005-04-07
00283         
00284         datehourfunc,   // SMD 2005-04-07
00285         
00286         dateminutefunc, // SMD 2005-04-07
00287         
00288         datesecondsfunc,    // SMD 2005-04-07
00289     
00290     /*dialog*/
00291         
00292         alertdialogfunc,
00293         
00294         rundialogfunc,
00295         
00296         #if !flruntime
00297         
00298         runmodelessfunc,
00299         
00300         #endif
00301         
00302         runcardfunc,
00303         
00304         runmodalcardfunc,
00305         
00306         ismodalcardfunc,
00307         
00308         setmodalcardtimeoutfunc,
00309         
00310         getdialogvaluefunc,
00311         
00312         setdialogvaluefunc,
00313         
00314         setdialogitemenablefunc,
00315         
00316         showdialogitemfunc,
00317         
00318         hidedialogitemfunc,
00319     
00320         twowaydialogfunc,
00321         
00322         threewaydialogfunc,
00323         
00324         askdialogfunc,
00325         
00326         getintdialogfunc,
00327 
00328         notifytdialogfunc,
00329 
00330         getuserinfodialogfunc,
00331         
00332         askpassworddialogfunc,
00333 
00334     /*kb*/
00335     
00336         optionkeyfunc,
00337         
00338         cmdkeyfunc,
00339         
00340         shiftkeyfunc,
00341         
00342         controlkeyfunc,
00343     
00344     /*mouse*/
00345         
00346         #if !flruntime
00347         
00348         mousebuttonfunc,
00349         
00350         mouselocationfunc,
00351         
00352         #endif
00353     
00354     
00355     /*point*/
00356         
00357         getpointfunc,
00358         
00359         setpointfunc,
00360         
00361     
00362     /*rectangle*/
00363         
00364         getrectfunc,
00365         
00366         setrectfunc,
00367         
00368     
00369     /*rgb*/
00370         
00371         getrgbfunc,
00372         
00373         setrgbfunc,
00374         
00375     
00376     /*speaker*/
00377     
00378         sysbeepfunc,
00379         
00380         soundfunc,
00381         
00382         playsoundfunc,
00383     
00384     
00385     /*target*/
00386         
00387         #if !flruntime
00388         
00389         gettargetfunc,
00390         
00391         settargetfunc,
00392         
00393         cleartargetfunc,
00394         
00395         #endif
00396         
00397     
00398     /*bit*/
00399         
00400         getbitfunc,
00401         
00402         setbitfunc,
00403         
00404         clearbitfunc,
00405 
00406         bitandfunc,
00407 
00408         bitorfunc,
00409 
00410         bitxorfunc,
00411 
00412         bitshiftleftfunc,
00413 
00414         bitshiftrightfunc,
00415 
00416     /*semaphore*/
00417     
00418         lockfunc,
00419         
00420         unlockfunc,
00421     
00422     /*base64*/
00423         
00424         base64encodefunc,
00425         
00426         base64decodefunc,
00427 
00428     /*winsock - netevents - tcp*/
00429     
00430         netaddressdecode,
00431         netaddressencode,
00432         netaddresstoname,
00433         netnametoaddress,
00434         netmyaddress,
00435         netabortstream,
00436         netclosestream,
00437         netcloselisten,
00438         netopenaddrstream,
00439         netopennamestream,
00440         netreadstream,
00441         netwritestream,
00442         netlistenstream,
00443         netstatusstream,
00444         netgetpeeraddress,
00445         netgetpeerport,
00446         netwritestringtostream,
00447         netwritefiletostream,
00448         netreadstreamuntil,
00449         netreadstreambytes,
00450         netreadstreamuntilclosed,
00451         netstatus,
00452         netcountconnections, /*7.0b37 PBS*/
00453 
00454     /*dll*/
00455 
00456         dllcallfunc,
00457 
00458         dllloadfunc,
00459 
00460         dllunloadfunc,
00461 
00462         dllisloadedfunc,
00463 
00464     /*python*/
00465         
00466         pythondoscriptfunc,
00467 
00468     /*htmlcontrol - 08/26/00 by RAB*/
00469 
00470         htmlcontrolbackfunc,
00471 
00472         htmlcontrolforwardfunc,
00473 
00474         htmlcontrolrefreshfunc,
00475 
00476         htmlcontrolhomefunc,
00477 
00478         htmlcontrolstopfunc,
00479 
00480         htmlcontrolnavigatefunc,
00481 
00482         htmlcontrolisofflinefunc,
00483 
00484         htmlcontrolsetofflinefunc,
00485 
00486     /*statusbar -- 7.0b21 PBS -- Bob's verbs*/
00487         
00488         statusbarmsgfunc,
00489 
00490         statusbarsetsectionsfunc,
00491 
00492         statusbargetsectionsfunc,
00493 
00494         statusbargetsectiononefunc,
00495 
00496         statusbargetmessagefunc,
00497 
00498     /*winRegistry -- Radio 7.0.2b1 PBS*/
00499         
00500         winregistrydeletefunc,
00501 
00502         winregistryreadfunc,
00503 
00504         winregistrygettypefunc,
00505 
00506         winregistrywritefunc,
00507 
00508     numberoflangtokens
00509     } tylangtoken;
00510 
00511 
00512 
00513 static boolean gettimesverb (hdltreenode hparam1, long *timecreated, long *timemodified) {
00514     
00515     /*
00516     get the creation date and modification date of the object indicated in hparam1
00517     */
00518     
00519     hdlhashtable htable;
00520     bigstring bs;
00521     tyvaluerecord v;
00522     hdlhashnode hnode;
00523     
00524     flnextparamislast = true;
00525     
00526     if (!getvarvalue (hparam1, 1, &htable, bs, &v, &hnode))
00527         return (false);
00528     
00529     *timecreated = 0;
00530     
00531     *timemodified = 0;
00532     
00533     if (v.valuetype == externalvaluetype)
00534         return (langexternalgettimes ((hdlexternalvariable) v.data.externalvalue, timecreated, timemodified, hnode));
00535     
00536     return (false);
00537     } /*gettimesverb*/
00538 
00539 
00540 static boolean settimesverb (tylangtoken token, hdltreenode hparam1, tyvaluerecord *vreturned) {
00541     
00542     /*
00543     get the creation date and modification date of the object indicated in hparam1
00544     */
00545     
00546     hdlhashtable htable;
00547     bigstring bs;
00548     tyvaluerecord v;
00549     hdlexternalvariable hv;
00550     unsigned long timecreated = 0;
00551     unsigned long timemodified = 0;
00552     unsigned long newtime;
00553     hdlhashnode hnode;
00554     
00555     if (!getvarvalue (hparam1, 1, &htable, bs, &v, &hnode))
00556         return (false);
00557     
00558     flnextparamislast = true;
00559     
00560     if (!getdatevalue (hparam1, 2, &newtime))
00561         return (false);
00562     
00563     if (v.valuetype != externalvaluetype)
00564         return (setbooleanvalue (false, vreturned));
00565     
00566     hv = (hdlexternalvariable) v.data.externalvalue;
00567     
00568     if (!langexternalgettimes (hv, (long *)(&timecreated), (long *)(&timemodified), hnode))
00569         return (false);
00570     
00571     if (token == settimecreatedfunc)
00572         timecreated = newtime;
00573     else
00574         timemodified = newtime;
00575     
00576     return (setbooleanvalue (langexternalsettimes (hv, timecreated, timemodified, hnode), vreturned));
00577     } /*settimesverb*/
00578 
00579 
00580 static boolean keyboardmodifierverb (tylangtoken token) {
00581     
00582     /*
00583     return true iff the indicated modifier key is down.
00584     */
00585     
00586     tykeystrokerecord kb;
00587     
00588     keyboardpeek (&kb);
00589     
00590     switch (token) {
00591         
00592         case optionkeyfunc: 
00593             return (kb.floptionkey);
00594         
00595         case cmdkeyfunc: 
00596             return (kb.flcmdkey);
00597         
00598         case shiftkeyfunc: 
00599             return (kb.flshiftkey);
00600         
00601         case controlkeyfunc:
00602             return (kb.flcontrolkey);
00603         
00604         default:
00605             return (false);
00606         } /*switch*/
00607     
00608     } /*keyboardmodifierverb*/
00609     
00610 /*
00611 static boolean presskeyverb (char ch) {
00612     
00613     register OSErr err;
00614     long size;
00615     EvQEl ev;
00616     short fl;
00617     short keycode;
00618     short keychar;
00619     
00620     keycode = 0x7b;
00621     
00622     keychar = chleftarrow;
00623     
00624     err = PPostEvent (keyDown, (keycode << 8) + keychar, &ev);
00625     
00626     //ev.evtQModifiers = btnState; /%the mouse is up%/
00627     
00628     return (err == noErr);
00629     } /%presskeyverb%/
00630 */
00631 
00632 
00633 #if !flruntime
00634 
00635 static boolean langclosehiddenwindow (tyvaluerecord val) {
00636     
00637     /*
00638     2.1b3 dmb: don't close hidden window if its globals are current
00639 
00640     5.0a22 dmb: don't generate runtime errors trying to clear the target
00641 
00642     5.1.4 dmb: note: we return true is val is a val is a valid 
00643     address of an existing item.
00644     */
00645     
00646     hdlhashtable htable;
00647     bigstring bsname;
00648     hdlwindowinfo hinfo;
00649     boolean fl;
00650     hdlhashnode hnode;
00651     
00652     assert (val.valuetype == addressvaluetype); /*08/04/2000 AR*/
00653 
00654     disablelangerror ();
00655 
00656     fl = getaddressvalue (val, &htable, bsname);
00657     
00658     if (fl)
00659         fl = langsymbolreference (htable, bsname, &val, &hnode);
00660     
00661     enablelangerror ();
00662     
00663     if (!fl)
00664         return (false);
00665     
00666     if (langexternalwindowopen (val, &hinfo)) {
00667         
00668         if (((**hinfo).flhidden) && (hinfo != shellwindowinfo))
00669             shellclosewindow ((**hinfo).macwindow);
00670         }
00671     
00672     return (true);
00673     } /*langclosehiddenwindow*/
00674 
00675 
00676 static boolean copyexemptvalue (const tyvaluerecord *v, tyvaluerecord *vcopy) {
00677     
00678     /*
00679     5.0a22 dmb: this was more compilcated before, but it's still shared code
00680     */
00681 
00682     boolean fl;
00683     
00684     fl = copyvaluerecord (*v, vcopy);
00685     
00686     if (fl)
00687         exemptfromtmpstack (vcopy);
00688     
00689     return (fl);
00690     } /*copyexemptvalue*/
00691 
00692 
00693 boolean langcleartarget (tyvaluerecord *prevtarget) {
00694     
00695     /*
00696     5.0a22 dmb: added prevtarget parameter
00697     */
00698     
00699     tyvaluerecord val;
00700     boolean fl = true;
00701     hdlhashnode hnode;
00702     
00703     if (prevtarget != nil)
00704         setnilvalue (prevtarget);
00705 
00706     pushouterlocaltable ();
00707     
00708     if (hashlookup (nametargetval, &val, &hnode)) {
00709         
00710         if (langclosehiddenwindow (val))
00711             if (prevtarget != nil)
00712                 copyexemptvalue (&val, prevtarget);
00713         
00714         if (fl)
00715             fl = hashdelete (nametargetval, true, true);
00716         }
00717     else
00718         fl = false;
00719     
00720     pophashtable ();
00721     
00722     return (fl);
00723     } /*langcleartarget*/
00724 
00725 
00726 boolean langsettarget (hdlhashtable htable, bigstring bsname, tyvaluerecord *prevtarget) {
00727     
00728     /*
00729     6/22/91 dmb: if existing target is open but hidden, close the window 
00730     so the script doesn't accumulate a jillion hidden window (or so).
00731 
00732     5.0a22 dmb: added prevtarget parameter
00733 
00734     5.1.4 dmb: if the old target isn't valid (langclosehiddenwindow returns false), 
00735     set prevtarget to nil
00736     */
00737     
00738     tyvaluerecord val, oldval;
00739     boolean flhadtarget;
00740     boolean fl;
00741     hdlhashnode hnode;
00742     
00743     if (!setaddressvalue (htable, bsname, &val))
00744         return (false);
00745     
00746     pushouterlocaltable ();
00747     
00748     flhadtarget = langgetsymbolval (nametargetval, &oldval, &hnode);
00749     
00750     if (flhadtarget) { /*we're smashing existing target*/
00751         
00752         if (!equalhandles ((Handle) val.data.addressvalue, (Handle) oldval.data.addressvalue)) /*changing*/
00753             if (!langclosehiddenwindow (oldval))
00754                 setnilvalue (&oldval);
00755         
00756         if (prevtarget != nil)
00757             copyexemptvalue (&oldval, prevtarget);
00758         }
00759     else {
00760         if (prevtarget != nil)
00761             setnilvalue (prevtarget);
00762         }
00763     
00764     fl = hashassign (nametargetval, val);
00765     
00766     pophashtable ();
00767     
00768     if (!fl)
00769         return (false);
00770     
00771     exemptfromtmpstack (&val);
00772     
00773     return (true);
00774     } /*langsettarget*/
00775 
00776 
00777 static boolean langgettarget (hdlhashtable *htable, bigstring bsname) {
00778     
00779     tyvaluerecord val;
00780     boolean fl;
00781     hdlhashnode hnode;
00782     
00783     pushouterlocaltable ();
00784     
00785     fl = langgetsymbolval (nametargetval, &val, &hnode);
00786     
00787     pophashtable ();
00788     
00789     if (!fl)
00790         return (false);
00791     
00792     if (val.valuetype != addressvaluetype) /*not an address*/
00793         return (false);
00794     
00795     return (getaddressvalue (val, htable, bsname));
00796     } /*langgettarget*/
00797 
00798 
00799 static boolean langunsettarget (hdlhashtable htable, bigstring bsname) {
00800     
00801     /*
00802     if table, name is the current target, clear the target and return true.
00803     
00804     otherwise, return false
00805     */
00806     
00807     hdlhashtable htargettable;
00808     bigstring bstargetname;
00809     
00810     if (langgettarget (&htargettable, bstargetname)) { /*a target is set*/
00811         
00812         if ((htable == htargettable) && equalidentifiers (bsname, bstargetname))
00813             return (langcleartarget (nil));
00814         }
00815     
00816     return (false);
00817     } /*langunsettarget*/
00818 
00819 #endif
00820 
00821 
00822 static boolean newvaluefunc (hdltreenode hparam1, tyvaluerecord *vreturned) {
00823     
00824     /*
00825     10/4/91 dmb: create heap-based values properly
00826     
00827     4.1b2 dmb: don't use getvarparam for the address param; it's too soft
00828     and can mistakenly wipe out a value that can't be coerced to an address 
00829     as expected. use getaddressparam instead
00830 
00831     5.0a22 dmb: new tables are local if creatdd in a local table
00832     */
00833     
00834     hdlhashtable htable;
00835     bigstring bs;
00836     OSType typeid;
00837     tyvaluetype type;
00838     tyvaluerecord val;
00839     boolean fl;
00840     hdlhashtable newtable;
00841     
00842     if (!getostypevalue (hparam1, 1, &typeid))
00843         return (false);
00844     
00845     flnextparamislast = true;
00846     
00847 //  if (!getvarparam (hparam1, 2, &htable, bs))
00848     if (!getaddressparam (hparam1, 2, &val) || !getaddressvalue (val, &htable, bs))
00849         return (false);
00850     
00851     if (htable == nil) { /*4.1b7 dmb*/
00852         
00853         if (isemptystring (bs)) {
00854             
00855             langerror (niladdresserror);
00856             
00857             return (false);
00858             }
00859         
00860         langsearchpathlookup (bs, &htable);
00861         }
00862     
00863     type = langgetvaluetype (typeid);
00864     
00865     if ((type >= outlinevaluetype) && (type <= pictvaluetype)) {
00866         
00867         if (!langexternalnewvalue ((tyexternalid) (type - outlinevaluetype), nil, &val))
00868             return (false);
00869 
00870         if ((type == tablevaluetype) && langexternalvaltotable (val, &newtable, HNoNode))
00871             (**newtable).fllocaltable = (**htable).fllocaltable;
00872         }
00873     else {
00874         initvalue (&val, novaluetype); /*nil all data*/
00875         
00876         if (!coercevalue (&val, type)) /*should only fail on low-mem*/
00877             return (false);
00878         }
00879     
00880     fl = langsetsymboltableval (htable, bs, val);
00881     
00882     if (fl)
00883         exemptfromtmpstack (&val);
00884     
00885     else {
00886         
00887         disposevaluerecord (val, true);
00888         
00889         return (false);
00890         }
00891     
00892     (*vreturned).data.flvalue = true;
00893     
00894     return (true);
00895     } /*newvaluefunc*/
00896 
00897 
00898 static boolean disposevaluefunc (hdltreenode hparam1, tyvaluerecord *vreturned) {
00899     
00900     /*
00901     dispose (address): boolean; completely dispose the indicated table value
00902     
00903     12/17/91 dmb: make sure item isn't the target
00904     
00905     2.1b2 dmb: use new deletevalue for arrays
00906     */
00907     
00908     register hdltreenode hp1 = hparam1;
00909     hdlhashtable htable;
00910     bigstring bs;
00911     
00912     if (!langcheckparamcount (hp1, 1))
00913         return (false);
00914     
00915     if ((**hp1).nodetype == addressofop)
00916         hp1 = (**hp1).param1;
00917     
00918     if ((**hp1).nodetype == arrayop)
00919         return (deletevalue (hp1, vreturned));
00920     
00921     if (!getvarparam (hparam1, 1, &htable, bs)) /*use original hparam1, not hp1*/
00922         return (false);
00923     
00924     #if !flruntime
00925     
00926     langunsettarget (htable, bs); /*make sure it's not still the target*/
00927     
00928     #endif
00929     
00930     (*vreturned).data.flvalue = hashtabledelete (htable, bs);
00931     
00932     return (true);
00933     } /*disposevaluefunc*/
00934 
00935 
00936 #if !flruntime
00937 
00938 boolean langzoomvalwindow (hdlhashtable htable, bigstring bs, tyvaluerecord val, boolean flmakevisible) {
00939     
00940     /*
00941     7/4/91 dmb: langexternalzoom now takes table/name pair instead 
00942     of full path.
00943     */
00944     
00945     Rect rzoom;
00946     
00947     if (flmakevisible)
00948         rzoom.top = -1; /*visible window; accept default rect*/
00949     else
00950         rzoom.top = -2; /*invisible window; don't zoom yet*/
00951     
00952     return (langexternalzoomfrom (val, htable, bs, &rzoom));
00953     } /*langzoomvalwindow*/
00954 
00955 
00956 boolean langfindtargetwindow (short id, WindowPtr *targetwindow) {
00957     
00958     /*
00959     find the target window for a verb; id is the external id for the EFP 
00960     that supports the verb (-1 for a shell verb)
00961     
00962     if we find a target address in the local stack, we return the corresponding 
00963     window if it supports the verb type.  for now, we require that the window 
00964     be open.
00965     
00966     otherwise, we call the shell to locate the best target
00967     
00968     10/3/91 dmb: tightened default logic.  we're no longer willing to 
00969     look byond the first eligable window for a window that is willing 
00970     to set up globals for id.  so if no target is set, we pass -1 to 
00971     shellfindtargetwindow instead of id; then we see if the window returned 
00972     will actually support this kind of verb.
00973     */
00974     
00975     hdlhashtable htable;
00976     bigstring bsname;
00977     tyvaluerecord val;
00978     hdlwindowinfo hinfo;
00979     register WindowPtr w;
00980     hdlhashnode hnode;
00981     
00982     if (!langgettarget (&htable, bsname)) { /*no target set; try default window*/
00983         
00984         if (!shellfindtargetwindow (-1, targetwindow)) /*should never fail*/
00985             return (false);
00986         
00987         return (shellgettargetdata (id, *targetwindow));
00988         }
00989     
00990     if (!langsymbolreference (htable, bsname, &val, &hnode))
00991         return (false);
00992     
00993     if (!langexternalwindowopen (val, &hinfo)) {
00994         
00995         if (!langzoomvalwindow (htable, bsname, val, false))
00996             return (false);
00997         
00998         if (!langexternalwindowopen (val, &hinfo)) {
00999             
01000             shellinternalerror (idwindowzoombug, BIGSTRING ("\x23" "windowzoom/windowopen inconsistency"));
01001             
01002             return (false);
01003             }
01004         }
01005     
01006     w = (**hinfo).macwindow; /*move into register*/
01007     
01008     if (!shellgettargetdata (id, w))
01009         return (false);
01010     
01011     *targetwindow = w;
01012     
01013     return (true);
01014     } /*langfindtargetwindow*/
01015 
01016 
01017 static boolean editvalue (hdltreenode hparam1, tyvaluerecord *vreturned) {
01018     
01019     hdlhashtable htable;
01020     bigstring bsname;
01021     tyvaluerecord val;
01022     hdlhashnode hnode;
01023     
01024     flnextparamislast = true;
01025     
01026     if (!getvarvalue (hparam1, 1, &htable, bsname, &val, &hnode))
01027         return (false);
01028     
01029     if (val.valuetype == externalvaluetype) {
01030         
01031         if (!langzoomvalwindow (htable, bsname, val, true))
01032             return (false);
01033         
01034         langsettarget (htable, bsname, nil); /*for future editing verbs*/
01035         }
01036     else {
01037         if (!tablezoomtoname (htable, bsname))
01038             return (false);
01039         }
01040     
01041     setbooleanvalue (true, vreturned);
01042     
01043     return (true);
01044     } /*editvalue*/
01045 
01046 
01047 static boolean closevalue (hdltreenode hparam1, tyvaluerecord *vreturned) {
01048     
01049     /*
01050     if the indicated value has it's window open, close it.  also, if it is 
01051     the current target, clear the target.
01052     
01053     set the return value to true if either change occurs.
01054     
01055     7.23.97 dmb: use shellclose, not shellclosewindow, to handle file
01056     objects.
01057     */
01058     
01059     hdlhashtable htable;
01060     bigstring bsname;
01061     tyvaluerecord val;
01062     hdlwindowinfo hinfo;
01063     Handle hdata;
01064     boolean fl = false;
01065     hdlhashnode hnode;
01066     
01067     flnextparamislast = true;
01068     
01069     if (!getvarvalue (hparam1, 1, &htable, bsname, &val, &hnode))
01070         return (false);
01071     
01072     if (langexternalwindowopen (val, &hinfo))
01073         if ((**hinfo).parentwindow != nil || shellgetexternaldata (hinfo, &hdata))
01074             fl = shellclose ((**hinfo).macwindow, false);
01075     
01076     if (langunsettarget (htable, bsname))
01077         fl = true;
01078     
01079     return (setbooleanvalue (fl, vreturned));
01080     } /*closevalue*/
01081 
01082 
01083 static boolean langgettargetfunc (hdltreenode hparam1, tyvaluerecord *vreturned) {
01084     
01085     /*
01086     5.0a22 dmb: if there's no explicit or implicit target, return nil
01087     */
01088 
01089     hdlhashtable htable;
01090     bigstring bsname;
01091     boolean fl;
01092     
01093     if (!langcheckparamcount (hparam1, 0))
01094         return (false);
01095     
01096     fl = langgettarget (&htable, bsname);
01097 
01098     if (!fl) {
01099         
01100         WindowPtr target;
01101         hdlexternalvariable hvariable;
01102         
01103         htable = nil;
01104         
01105         setemptystring (bsname);
01106         
01107         if (langfindtargetwindow (-1, &target)) {
01108             
01109             shellpushglobals (target);
01110             
01111             if ((*shellglobals.getvariableroutine) (&hvariable))
01112                 fl = langexternalfindvariable (hvariable, &htable, bsname);
01113             
01114             shellpopglobals ();
01115             }
01116         }
01117     
01118     if (fl)
01119         return (setaddressvalue (htable, bsname, vreturned));
01120     else
01121         return (setnilvalue (vreturned));
01122     } /*langgettargetfunc*/
01123 
01124 
01125 static boolean langsettargetfunc (hdltreenode hparam1, tyvaluerecord *vreturned) {
01126     
01127     /*
01128     8/21/91 dmb: don't generate error if type isn't external; just return false
01129     
01130     6/23/92 dmb: open target window now, instead of waiting for an editing 
01131     verb to trigger it via findtargetwindow.  this allows window verbs to 
01132     operator on it.
01133 
01134     5.0a22 dmb: if there's an error zooming, don't leave target value set.
01135                 if called with nil, clear the target
01136     */
01137     
01138     hdlhashtable htable;
01139     bigstring bsname;
01140     tyvaluerecord val;
01141     hdlhashnode hnode;
01142     
01143     setbooleanvalue (false, vreturned); /*default return*/
01144     
01145     flnextparamislast = true;
01146     
01147     if (!getvarvalue (hparam1, 1, &htable, bsname, &val, &hnode))
01148         return (false);
01149     
01150     if (val.valuetype != externalvaluetype) {
01151         
01152         if (val.valuetype == novaluetype) { // 5.0a22
01153             
01154             if (langcleartarget (vreturned))
01155                 pushtmpstackvalue (vreturned);
01156 
01157             return (true);
01158             }
01159 
01160         langparamerror (externalvaluerequirederror, bsname);
01161         
01162         return (false);
01163         }
01164     
01165     if (!langsettarget (htable, bsname, vreturned))
01166         return (false);
01167     
01168     if (!langzoomvalwindow (htable, bsname, val, false)) {
01169         
01170         disposevaluerecord (*vreturned, false);
01171         
01172         disablelangerror ();
01173         
01174         langcleartarget (nil);
01175         
01176         enablelangerror ();
01177         
01178         return (false);
01179         }
01180     
01181 //  5.0a22 dmb: vretured is already set now. was - setbooleanvalue (true, vreturned);
01182     
01183     pushtmpstackvalue (vreturned);
01184     
01185     return (true);
01186     } /*langsettargetfunc*/
01187 
01188 #endif
01189 
01190 static boolean getuserinfofunc (hdltreenode hparam1, tyvaluerecord *vreturned) {
01191     
01192     bigstring bsvarname, bsvarinitials, bsvarorg, bsvaremail;
01193     bigstring bsname, bsinitials, bsorg, bsemail;
01194     hdlhashtable htable;
01195     register boolean fl;
01196     
01197     if (!getvarparam (hparam1, 1, &htable, bsvarname)) 
01198         return (false);
01199 
01200     if (!getvarparam (hparam1, 2, &htable, bsvarinitials)) 
01201         return (false);
01202 
01203     if (!getvarparam (hparam1, 3, &htable, bsvarorg)) 
01204         return (false);
01205     
01206     flnextparamislast = true;
01207     
01208     if (!getvarparam (hparam1, 4, &htable, bsvaremail)) 
01209         return (false);
01210     
01211     idstringvalue (htable, bsvarname, bsname); /*not an error if string is undefined*/
01212     
01213     if (fllangerror) /*probably a bad array reference*/
01214         return (false);
01215     
01216     idstringvalue (htable, bsvarinitials, bsinitials); /*not an error if string is undefined*/
01217     
01218     if (fllangerror) /*probably a bad array reference*/
01219         return (false);
01220     
01221     idstringvalue (htable, bsvarorg, bsorg); /*not an error if string is undefined*/
01222     
01223     if (fllangerror) /*probably a bad array reference*/
01224         return (false);
01225     
01226     idstringvalue (htable, bsvaremail, bsemail); /*not an error if string is undefined*/
01227     
01228     if (fllangerror) /*probably a bad array reference*/
01229         return (false);
01230     
01231     #ifdef WIN95VERSION
01232         fl = userinfodialog (bsname, bsinitials, bsorg, bsemail);
01233     #endif
01234         
01235     #ifdef MACVERSION
01236         fl = false;  //not supported on this platform
01237     #endif
01238 
01239     setbooleanvalue (fl, vreturned);
01240     
01241     if (fl) { /*user pressed OK*/
01242         
01243         pushhashtable (htable);
01244         
01245         langsetstringval (bsvarname, bsname);
01246 
01247         langsetstringval (bsvarinitials, bsinitials);
01248 
01249         langsetstringval (bsvarorg, bsorg);
01250         
01251         langsetstringval (bsvaremail, bsemail);
01252         
01253         pophashtable ();
01254         
01255         return (true);
01256         }
01257         
01258     return (true);
01259     } /*getuserinfofunc*/
01260 
01261 
01262 static boolean askfunc (hdltreenode hparam1, tyvaluerecord *vreturned, boolean flPassword) {
01263     
01264     bigstring bsprompt, bsvarname, bsanswer;
01265     hdlhashtable htable;
01266     register boolean fl;
01267     
01268     if (!getstringvalue (hparam1, 1, bsprompt))
01269         return (false);
01270     
01271     flnextparamislast = true;
01272     
01273     if (!getvarparam (hparam1, 2, &htable, bsvarname)) 
01274         return (false);
01275     
01276     idstringvalue (htable, bsvarname, bsanswer); /*not an error if string is undefined*/
01277     
01278     if (fllangerror) /*probably a bad array reference*/
01279         return (false);
01280     
01281     if (flPassword)
01282         fl = askpassword (bsprompt, bsanswer);
01283     else
01284         fl = askdialog (bsprompt, bsanswer);
01285     
01286     setbooleanvalue (fl, vreturned);
01287     
01288     if (fl) { /*user pressed OK*/
01289         
01290         pushhashtable (htable);
01291         
01292         langsetstringval (bsvarname, bsanswer);
01293         
01294         pophashtable ();
01295         
01296         return (true);
01297         }
01298         
01299     return (true);
01300     } /*askfunc*/
01301 
01302 
01303 static boolean getintfunc (hdltreenode hparam1, tyvaluerecord *vreturned) {
01304     
01305     bigstring bsprompt, bsvarname, bsanswer;
01306     hdlhashtable htable;
01307     register boolean fl;
01308     short n;
01309     long longn;
01310     tyvaluerecord val;
01311     
01312     if (!getstringvalue (hparam1, 1, bsprompt))
01313         return (false);
01314     
01315     flnextparamislast = true;
01316     
01317     if (!getvarparam (hparam1, 2, &htable, bsvarname)) 
01318         return (false);
01319     
01320     idstringvalue (htable, bsvarname, bsanswer); /*not an error if string is undefined*/
01321     
01322     if (fllangerror) /*probably a bad array reference*/
01323         return (false);
01324     
01325     stringtonumber (bsanswer, &longn);
01326 
01327     n = (short) longn;
01328 
01329     fl = intdialog (bsprompt, &n);
01330     
01331     setbooleanvalue (fl, vreturned);
01332     
01333     if (fl) { /*user pressed OK*/
01334         
01335         setintvalue (n, &val);
01336         
01337         langsetsymboltableval (htable, bsvarname, val);
01338         
01339         return (true);
01340         }
01341         
01342     return (true);
01343     } /*getintfunc*/
01344 
01345 
01346 static boolean twowayfunc (hdltreenode hparam1, tyvaluerecord *v) {
01347 
01348     bigstring bsprompt, bs1, bs2;
01349     
01350     if (!getstringvalue (hparam1, 1, bsprompt))
01351         return (false);
01352     
01353     if (!getstringvalue (hparam1, 2, bs1))
01354         return (false);
01355     
01356     flnextparamislast = true;
01357     
01358     if (!getstringvalue (hparam1, 3, bs2))
01359         return (false);
01360     
01361     (*v).data.flvalue = twowaydialog (bsprompt, bs1, bs2);
01362     
01363     return (true);
01364     } /*twowayfunc*/
01365 
01366 
01367 static boolean threewayfunc (hdltreenode hparam1, tyvaluerecord *v) {
01368 
01369     bigstring bsprompt, bs1, bs2, bs3;
01370     
01371     if (!getstringvalue (hparam1, 1, bsprompt))
01372         return (false);
01373     
01374     if (!getstringvalue (hparam1, 2, bs1))
01375         return (false);
01376     
01377     if (!getstringvalue (hparam1, 3, bs2))
01378         return (false);
01379     
01380     flnextparamislast = true;
01381     
01382     if (!getstringvalue (hparam1, 4, bs3))
01383         return (false);
01384     
01385     return (setintvalue (threewaydialog (bsprompt, bs1, bs2, bs3), v));
01386     } /*threewayfunc*/
01387 
01388 
01389 #if MACVERSION && TARGET_API_MAC_OS8
01390 
01391 #if !TARGET_RT_MAC_CFM
01392         
01393     #define xcmdcallbackUPP ((UniversalProcPtr) &xcmdcallback)
01394         
01395 #else
01396     enum {
01397         XCmdProcInfo = kPascalStackBased
01398              | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(XCmdPtr)))
01399     };
01400     
01401     enum {
01402         xcmdcallbackProcInfo = kPascalStackBased
01403     };
01404     
01405     static RoutineDescriptor xcmdcallbackDesc = BUILD_ROUTINE_DESCRIPTOR (xcmdcallbackProcInfo, xcmdcallback);
01406     
01407     #define xcmdcallbackUPP (&xcmdcallbackDesc)
01408 #endif
01409 
01410 static boolean callxcmdverb (hdltreenode hparam1, tyvaluerecord *vreturned) {
01411     
01412     /*
01413     5/4/92 dmb: created.
01414     
01415     7/8/92 dmb: don't rely on temp stack for handle disposal; will overflow
01416                 push/popport on frontwindow; some XCMDs may expect this
01417     
01418     7/14/92 dmb: different return values for XCMDs & XFCNs when they return nothing
01419     
01420     10/3/92 dmb: must set plangxcmdrec for the callback routine
01421     
01422     7.0b48: calling an XCMD or XFCN on OS X is an error.
01423     */
01424     
01425     register hdltreenode hp1 = hparam1;
01426     short ctparams = langgetparamcount (hp1) - 1;
01427     hdlhashtable htable;
01428     bigstring bsxcmd;
01429     tyvaluerecord val;
01430     Handle hxcmd;
01431     struct XCmdBlock xcb;
01432     short i;
01433     Handle x;
01434     OSType xtype;
01435     boolean fl = false;
01436     hdlhashnode hnode;
01437         
01438     if (!getvarvalue (hp1, 1, &htable, bsxcmd, &val, &hnode))
01439         return (false);
01440     
01441     if (val.valuetype != binaryvaluetype) {
01442         
01443         langparamerror (notxcmderror, bsxcmd);
01444         
01445         return (false);
01446         }
01447         
01448     hxcmd = val.data.binaryvalue; /*copy into register*/
01449     
01450     xtype = getbinarytypeid (hxcmd);
01451     
01452     if ((xtype != 'XCMD') && (xtype != 'XFCN')) {
01453         
01454         langparamerror (notxcmderror, bsxcmd);
01455         
01456         return (false);
01457         }
01458     
01459     if (ctparams > 16) { /*max number of XCMD params is 16*/
01460         
01461         langparamerror (toomanyparameterserror, bsfunctionname);
01462         
01463         return (false);
01464         }
01465     
01466     clearbytes (&xcb, longsizeof (xcb));
01467     
01468     for (i = 0; i < ctparams; ++i) {
01469         
01470         if (!getexempttextvalue (hp1, i + 2, &x))
01471             goto exit;
01472         
01473         xcb.params [i] = x;
01474         
01475         if (!enlargehandle (x, 1, zerostring))
01476             goto exit;
01477         }
01478     
01479     xcb.paramCount = ctparams;
01480     
01481     xcb.passFlag = false;
01482     
01483     xcb.entryPoint = xcmdcallbackUPP;
01484     
01485     lockhandle (hxcmd);
01486     //Code change by Timothy Paustian Monday, August 21, 2000 4:24:28 PM
01487     //We cannot pass a window ptr to push port
01488     {
01489     CGrafPtr    thePort;
01490     #if TARGET_API_MAC_CARBON == 1
01491     thePort = GetWindowPort(getfrontwindow ());
01492     #else
01493     thePort = (CGrafPtr)getfrontwindow ();
01494     #endif
01495         
01496     pushport (thePort); /*checks for nil*/
01497     }
01498     plangxcmdrec = &xcb; /*set global*/
01499     
01500     //Code change by Timothy Paustian Wednesday, June 14, 2000 9:06:07 PM
01501     //No CFM for Carbon
01502     #if TARGET_RT_MAC_CFM
01503         
01504     {
01505         #if TARGET_API_MAC_CARBON == 1
01506         (*(pascal void (*)(XCmdPtr)) ((OSType *) *hxcmd + 1)) (&xcb);
01507         #else
01508         
01509         UniversalProcPtr upp = NewRoutineDescriptor ((ProcPtr) ((OSType *) *hxcmd + 1), XCmdProcInfo, kM68kISA);
01510         
01511         CallUniversalProc (upp, XCmdProcInfo, &xcb);
01512         
01513         DisposeRoutineDescriptor (upp);
01514         #endif
01515         
01516     }
01517     #else
01518     
01519         (*(pascal void (*)(XCmdPtr)) ((OSType *) *hxcmd + 1)) (&xcb);
01520     
01521     #endif
01522     plangxcmdrec = nil; /*clear it*/
01523     
01524     popport ();
01525     
01526     unlockhandle (hxcmd);
01527     
01528     if (xcb.returnValue == nil) { /*no explicit return value*/
01529         
01530         if (xtype == 'XCMD')
01531             fl = setbooleanvalue (true, vreturned);
01532         else
01533             fl = setstringvalue (zerostring, vreturned);
01534         }
01535     else {
01536         
01537         truncatecstringhandle (xcb.returnValue); /*strip zero terminator*/
01538         
01539         fl = setheapvalue (xcb.returnValue, stringvaluetype, vreturned);
01540         }
01541     
01542     exit:
01543     
01544     for (i = 0; i < ctparams; ++i) {
01545         
01546         register Handle x = xcb.params [i];
01547         
01548         if (x != xcb.returnValue) /*some xcmds return a parameter as the result*/
01549             disposehandle (x);
01550         }
01551     
01552     return (fl);
01553     } /*callxcmdverb*/
01554 
01555 #endif
01556 
01557 
01558 static boolean callscriptverb (hdltreenode hparam1, tyvaluerecord *vreturned) {
01559     
01560     /*
01561     3/29/98 rab: created.
01562     */
01563     
01564     register hdltreenode hp1 = hparam1;
01565     bigstring bsscriptname;
01566     tyvaluerecord vparams;
01567     hdlhashtable hcontext = nil;
01568     boolean fl;
01569     
01570     if (!getstringvalue (hp1, 1, bsscriptname))
01571         return (false);
01572     
01573     if (!getparamvalue (hp1, 2, &vparams))
01574         return (false);
01575     
01576     if (vparams.valuetype != recordvaluetype)
01577         if (!coercetolist (&vparams, listvaluetype))
01578             return (false);
01579     
01580     if (langgetparamcount (hparam1) > 2) {
01581         
01582         flnextparamislast = true;
01583 
01584         if (!gettablevalue (hparam1, 3, &hcontext))
01585             return (false);
01586         }
01587     
01588     fl = langrunscript (bsscriptname, &vparams, hcontext, vreturned);
01589     
01590     return (fl);
01591     } /*callscriptverb*/
01592 
01593 
01594 static boolean getbitparams (hdltreenode hparam1, unsigned long *bits, unsigned short *bitnum, short ixerror) {
01595     
01596     if (!getlongvalue (hparam1, 1, (long *) bits))
01597         return (false);
01598     
01599     flnextparamislast = true;
01600     
01601     if (!getintvalue (hparam1, 2, (short *) bitnum))
01602         return (false);
01603     
01604     if (*bitnum > 31) {
01605         
01606         langerror (ixerror);
01607         
01608         return (false);
01609         }
01610     
01611     return (true);
01612     } /*getbitparams*/
01613     
01614     
01615 static boolean getbitnumparams (hdltreenode hparam1, unsigned long *bits1, unsigned long *bits2) {
01616     
01617     if (!getlongvalue (hparam1, 1, (long *) bits1))
01618         return (false);
01619     
01620     flnextparamislast = true;
01621     
01622     if (!getlongvalue (hparam1, 2, (long *) bits2))
01623         return (false);
01624     
01625     return (true);
01626     } /*getbitnumparams*/
01627     
01628     
01629 static boolean bitgetverb (hdltreenode hparam1, tyvaluerecord *vreturned) {
01630     
01631     unsigned long bits;
01632     unsigned short bitnum;
01633     
01634     if (!getbitparams (hparam1, &bits, &bitnum, bitindexerror))
01635         return (false);
01636     
01637     return (setbooleanvalue ((bits >> bitnum) & 1, vreturned));
01638     } /*bitgetverb*/
01639     
01640 
01641 static boolean bitsetverb (hdltreenode hparam1, tyvaluerecord *vreturned) {
01642     
01643     unsigned long bits;
01644     unsigned short bitnum;
01645     
01646     if (!getbitparams (hparam1, &bits, &bitnum, bitindexerror))
01647         return (false);
01648     
01649     return (setlongvalue (bits | ((unsigned long) 1 << bitnum), vreturned));
01650     } /*bitsetverb*/
01651 
01652 
01653 static boolean bitclearverb (hdltreenode hparam1, tyvaluerecord *vreturned) {
01654     
01655     unsigned long bits;
01656     unsigned short bitnum;
01657     
01658     if (!getbitparams (hparam1, &bits, &bitnum, bitindexerror))
01659         return (false);
01660     
01661     return (setlongvalue (bits & (~((unsigned long) 1 << bitnum)), vreturned));
01662     } /*bitclearverb*/
01663 
01664 
01665 static boolean bitandverb (hdltreenode hparam1, tyvaluerecord *vreturned) {
01666     
01667     unsigned long bits1;
01668     unsigned long bits2;
01669     
01670     if (!getbitnumparams (hparam1, &bits1, &bits2))
01671         return (false);
01672     
01673     return (setlongvalue (bits1 & bits2, vreturned));
01674     } /*bitandverb*/
01675 
01676 
01677 static boolean bitorverb (hdltreenode hparam1, tyvaluerecord *vreturned) {
01678     
01679     unsigned long bits1;
01680     unsigned long bits2;
01681     
01682     if (!getbitnumparams (hparam1, &bits1, &bits2))
01683         return (false);
01684     
01685     return (setlongvalue (bits1 | bits2, vreturned));
01686     } /*bitorverb*/
01687 
01688 
01689 static boolean bitxorverb (hdltreenode hparam1, tyvaluerecord *vreturned) {
01690     
01691     unsigned long bits1;
01692     unsigned long bits2;
01693     
01694     if (!getbitnumparams (hparam1, &bits1, &bits2))
01695         return (false);
01696     
01697     return (setlongvalue (bits1 ^ bits2, vreturned));
01698     } /*bitxorverb*/
01699 
01700 
01701 static boolean bitshiftleftverb (hdltreenode hparam1, tyvaluerecord *vreturned) {
01702     
01703     unsigned long bits;
01704     unsigned short bitdist;
01705     
01706     if (!getbitparams (hparam1, &bits, &bitdist, bitshiftdisterror))
01707         return (false);
01708     
01709     return (setlongvalue (bits << bitdist, vreturned));
01710     } /*bitshiftleftverb*/
01711 
01712 
01713 static boolean bitshiftrightverb (hdltreenode hparam1, tyvaluerecord *vreturned) {
01714     
01715     unsigned long bits;
01716     unsigned short bitdist;
01717     
01718     if (!getbitparams (hparam1, &bits, &bitdist, bitshiftdisterror))
01719         return (false);
01720     
01721     return (setlongvalue (bits >> bitdist, vreturned));
01722     } /*bitshiftrightverb*/
01723 
01724 
01725 static boolean locksemaphoreverb (hdltreenode hparam1, tyvaluerecord *vreturned) {
01726     
01727     /*
01728         on lock (semaphorename, timeoutticks)
01729             local (adr = @semaphores.values [semaphorename])
01730             local (startticks = clock.ticks ())
01731             while defined (adr^)
01732                 sys.systemtask () «give up the processor
01733                 if (clock.ticks () - startticks) > timeoutticks  «waited more than timeoutticks, get out
01734                     scriptError ("Semaphore timer expired after " + timeoutticks + " sixtieths of a second.")
01735             new (booleantype, adr) «claim the semaphore
01736             return (true)
01737     */
01738     
01739     bigstring bssemaphorename;
01740     long timeoutticks;
01741     long startticks = gettickcount ();
01742     bigstring bsticks;
01743     tyvaluerecord val;
01744     #ifdef version5orgreater
01745         hdllistrecord hlist;
01746     #endif
01747     
01748     if (!getstringvalue (hparam1, 1, bssemaphorename))
01749         return (false);
01750     
01751     flnextparamislast = true;
01752     
01753     if (!getlongvalue (hparam1, 2, &timeoutticks))
01754         return (false);
01755     
01756     while (hashtablesymbolexists (semaphoretable, bssemaphorename)) {
01757         
01758         if (!langbackgroundtask (true))
01759             return (false);
01760         
01761         if (gettickcount () - startticks >= (unsigned long) timeoutticks) {
01762         
01763             numbertostring (timeoutticks, bsticks);
01764             
01765             langparamerror (semaphoretimeouterror, bsticks);
01766             
01767             return (false);
01768             }
01769         }
01770     
01771     #ifdef version5orgreater
01772         if (!opnewlist (&hlist, true))
01773             return (false);
01774         
01775         setdatevalue (timenow(), &val);
01776         
01777         if (!langpushlistval (hlist, semaphorewhen, &val))
01778             goto error;
01779         
01780         setlongvalue ((long) (**getcurrentthreadglobals()).idthread, &val);
01781         
01782         if (!langpushlistval (hlist, semaphorewho, &val))
01783             goto error;
01784         
01785         if (!setheapvalue ((Handle) hlist, recordvaluetype, &val))
01786             return (false);
01787     #else
01788         setdatevalue (timenow(), &val);
01789     #endif
01790     
01791     if (!hashtableassign (semaphoretable, bssemaphorename, val))
01792         return (false);
01793     
01794     exemptfromtmpstack (&val);
01795     
01796     return (setbooleanvalue (true, vreturned));
01797     
01798     #ifdef version5orgreater
01799         error:
01800             opdisposelist (hlist);
01801             
01802             return (false);
01803     #endif
01804     } /*locksemaphoreverb*/
01805 
01806 
01807 static boolean unlocksemaphoreverb (hdltreenode hparam1, tyvaluerecord *vreturned) {
01808     
01809     /*
01810         on unlock (semaphorename)
01811             local (adr = @semaphores.values [semaphorename])
01812             if defined (adr^) << added 9/10/95 MAH - checks for semaphore before deleting
01813                 delete (adr) <<release the semaphore
01814             return (true)
01815     */
01816 
01817     bigstring bssemaphorename;
01818     boolean fl;
01819     
01820     flnextparamislast = true;
01821     
01822     if (!getstringvalue (hparam1, 1, bssemaphorename))
01823         return (false);
01824     
01825     if (isemptystring (bssemaphorename))
01826         fl = langreleasesemaphores (nil);
01827 
01828     else {
01829 
01830         pushhashtable (semaphoretable);
01831         
01832         fl = hashsymbolexists (bssemaphorename) && hashdelete (bssemaphorename, true, true);
01833         
01834         pophashtable ();
01835         }
01836     
01837     return (setbooleanvalue (fl, vreturned));
01838     } /*unlocksemaphoreverb*/
01839 
01840 
01841 static boolean releasesemaphorevisit (hdlhashnode hnode, ptrvoid idthread) {
01842     
01843     tyvaluerecord val = (**hnode).val;
01844     tyvaluerecord vwho;
01845     
01846     if (val.valuetype == recordvaluetype) {
01847     
01848         if (langgetlistitem (&val, -1, semaphorewho, &vwho)) {
01849             
01850             if (vwho.data.longvalue == (long) idthread)
01851                 hashdelete ((**hnode).hashkey, true, false);
01852             
01853             disposevaluerecord (vwho, false);
01854             }
01855         }
01856     
01857     return (true); // continue traversal
01858 } /*releasesemaphorevisit*/
01859 
01860 
01861 boolean
01862 langreleasesemaphores (hdlprocessrecord xxxhp)
01863 {
01864 #pragma unused(xxxhp)
01865 
01866     pushhashtable (semaphoretable); // for visit's hashdelete
01867 
01868     hashtablevisit (semaphoretable, &releasesemaphorevisit, (ptrvoid) (**getcurrentthreadglobals()).idthread);
01869     
01870     pophashtable ();
01871     
01872     return (true);
01873     } /*langreleasesemaphores*/
01874 
01875 
01876 static boolean langfunctionvalue (short token, hdltreenode hparam1, tyvaluerecord *vreturned, bigstring bserror) {
01877     
01878     /*
01879     9/26/91 dmb: use getdatevalue for time/date verbs so that string coercion 
01880     can be performed.  reimplemented absfunc so that it handles (and maintains) 
01881     arbitrary types.  also, set default return value for all verbs to false.
01882     
01883     2/14/92 dmb: evaluate & runstring no longer use bigstrings
01884     
01885     5/29/92 dmb: scripterror (killscriptfunc) must always return false to ensure 
01886     proper termination
01887     
01888     6/24/92 dmb: added countlistitemsfunc
01889     
01890     8/17/92 dmb: setbinarytypefunc -- set table's dirty flag
01891     
01892     9/4/92 dmb: generate oserror for numeric scriptError
01893     
01894     9/11/92 dmb: sleepfunc: accept verb when a dialog is running
01895     
01896     10/3/92 dmb: comment out runstringfunc
01897     
01898     6/1/93 dmb: when vreturned is nil, return whether or not verb token must 
01899     be run in the Frontier process
01900     
01901     2.1b12 dmb: runcardfunc and runmodalcardfunc must run in frontier process
01902     
01903     3.0.4b8 dmb: msgfunc requires a window
01904 
01905     6.1d13 AR: Added netwritestringtostream, netreadstreamuntil, netreadstreambytes.
01906     
01907     6.2b10 AR: Added netwritefiletostream.
01908     */
01909     
01910     register tyvaluerecord *v = vreturned;
01911     register boolean fl;
01912     bigstring bs;
01913     
01914     if (vreturned == nil) { /*need Frontier process?*/
01915         
01916         switch (token) {
01917             
01918             #if !flruntime
01919             
01920             case editfunc:
01921             case gettargetfunc:
01922             case settargetfunc:
01923             case cleartargetfunc:
01924             
01925             #endif
01926             
01927             case msgfunc:           // 3.0.4b8 dmb
01928             case runmodelessfunc:   // 4.1b3 dmb
01929             /*
01930             case runcardfunc:
01931             case runmodalcardfunc:
01932             */
01933                 return (true);
01934             
01935             default:
01936                 return (false);
01937             }
01938     }
01939 
01940     setbooleanvalue (false, v); /*by default, lang functions return false*/
01941 
01942     switch (token)
01943     {
01944         case killscriptfunc:
01945         {
01946             tyvaluerecord val;
01947             boolean lfl;
01948 
01949             flnextparamislast = true;
01950 
01951             if (!getparamvalue (hparam1, 1, &val))
01952                 return (false);
01953 
01954             if (val.valuetype == longvaluetype)
01955             {
01956                 langgetmiscstring (unknownstring, bs);
01957 
01958                 setoserrorparam (bs);
01959 
01960                 lfl = oserror (val.data.longvalue);
01961             }
01962             else
01963             {
01964                 if (!coercetostring (&val))
01965                     return (false);
01966 
01967                 pullstringvalue (&val, bs);
01968 
01969                 lfl = langerrormessage (bs);
01970             }
01971 
01972             /*
01973             if (!getstringvalue (hparam1, 1, bs))
01974                 return (false);
01975             */
01976 
01977             (*v).data.flvalue = lfl;
01978 
01979             return (false);
01980         }
01981 
01982         case newfunc:
01983             return (newvaluefunc (hparam1, v));
01984         
01985         case disposefunc:
01986             return (disposevaluefunc (hparam1, v));
01987         
01988         #if !flruntime
01989         
01990         case editfunc:
01991             return (editvalue (hparam1, v));
01992         
01993         case closefunc:
01994             return (closevalue (hparam1, v));
01995         
01996         case gettargetfunc:
01997             return (langgettargetfunc (hparam1, v));
01998         
01999         case settargetfunc:
02000             return (langsettargetfunc (hparam1, v));
02001         
02002         case cleartargetfunc:
02003             if (!langcheckparamcount (hparam1, 0))
02004                 return (false);
02005             
02006             setbooleanvalue (langcleartarget (nil), v);
02007             
02008             return (true);
02009         
02010         #endif
02011         
02012         case booleanfunc:
02013             flnextparamislast = true;
02014             
02015             return (getbooleanparam (hparam1, 1, v));
02016         
02017         case charfunc:
02018             flnextparamislast = true;
02019             
02020             return (getcharparam (hparam1, 1, v));
02021         
02022         case intfunc:
02023             flnextparamislast = true;
02024             
02025             return (getintparam (hparam1, 1, v));
02026         
02027         case longfunc:
02028             flnextparamislast = true;
02029             
02030             return (getlongparam (hparam1, 1, v));
02031         
02032         case timefunc: {
02033             
02034             if (!langcheckparamcount (hparam1, 0))
02035                 return (false);
02036             
02037             return (setdatevalue (timenow (), v));
02038             }
02039         
02040         #if !TARGET_API_MAC_CARBON
02041 
02042             case settimefunc: {
02043                 unsigned long time;
02044                 
02045                 flnextparamislast = true;
02046                 
02047                 if (!getdatevalue (hparam1, 1, &time))
02048                     return (false);
02049                 
02050                 setbooleanvalue (setsystemclock (time), v);
02051                 
02052                 return (true);
02053                 }
02054             
02055         #endif
02056         
02057         case datefunc:
02058             flnextparamislast = true;
02059             
02060             return (getdateparam (hparam1, 1, v));
02061         
02062         case setdatefunc: {
02063             short day, month, year, hour, minute, second;
02064             unsigned long date;
02065             
02066             if (!getintvalue (hparam1, 1, &day))
02067                 return (false);
02068             
02069             if (!getintvalue (hparam1, 2, &month))
02070                 return (false);
02071             
02072             if (!getintvalue (hparam1, 3, &year))
02073                 return (false);
02074             
02075             if (!getintvalue (hparam1, 4, &hour))
02076                 return (false);
02077             
02078             if (!getintvalue (hparam1, 5, &minute))
02079                 return (false);
02080             
02081             flnextparamislast = true;
02082             
02083             if (!getintvalue (hparam1, 6, &second))
02084                 return (false);
02085             
02086             date = datetimetoseconds (day, month, year, hour, minute, second);
02087             
02088             return (setdatevalue (date, v));
02089             }
02090         
02091         case getdatefunc: {
02092             unsigned long secs;
02093             short day, month, year, hour, minute, second;
02094             
02095             if (!langcheckparamcount (hparam1, 7)) /*preflight before changing values*/
02096                 return (false);
02097             
02098             if (!getdatevalue (hparam1, 1, &secs))
02099                 return (false);
02100             
02101             secondstodatetime (secs, &day, &month, &year, &hour, &minute, &second);
02102             
02103             if (!setintvarparam (hparam1, 2, day))
02104                 return (false);
02105             
02106             if (!setintvarparam (hparam1, 3, month))
02107                 return (false);
02108             
02109             if (!setintvarparam (hparam1, 4, year))
02110                 return (false);
02111             
02112             if (!setintvarparam (hparam1, 5, hour))
02113                 return (false);
02114             
02115             if (!setintvarparam (hparam1, 6, minute))
02116                 return (false);
02117             
02118             if (!setintvarparam (hparam1, 7, second))
02119                 return (false);
02120             
02121             (*v).data.flvalue = true;
02122             
02123             return (true);
02124             }
02125         
02126         case datedayfunc:       /* SMD 2005-04-07 */
02127         case datemonthfunc:
02128         case dateyearfunc:
02129         case datehourfunc:
02130         case dateminutefunc:
02131         case datesecondsfunc: {
02132             tyvaluerecord vsecs;
02133             short ctconsumed = 0;
02134             short ctpositional = 0;
02135             short day, month, year, hour, minute, second;
02136             
02137             initvalue (&vsecs, datevaluetype);
02138 
02139             flnextparamislast = true;
02140             
02141             if (!getoptionalparamvalue (hparam1, &ctconsumed, &ctpositional, BIGSTRING ("\x07" "theDate"), &vsecs)) 
02142                 return (false);
02143             
02144             if (!vsecs.data.datevalue) {
02145                 if (!setdatevalue (timenow(), &vsecs))
02146                     return (false);
02147                 }
02148             
02149             secondstodatetime (vsecs.data.datevalue, &day, &month, &year, &hour, &minute, &second);
02150             
02151             switch (token) {
02152                 case datedayfunc:
02153                     return (setintvalue (day, v));
02154                 case datemonthfunc:
02155                     return (setintvalue (month, v));
02156                 case dateyearfunc:
02157                     return (setintvalue (year, v));
02158                 case datehourfunc:
02159                     return (setintvalue (hour, v));
02160                 case dateminutefunc:
02161                     return (setintvalue (minute, v));
02162                 case datesecondsfunc:
02163                     return (setintvalue (second, v));
02164                 }
02165             }
02166 
02167         case abbrevstringfunc: {
02168             unsigned long date;
02169 
02170             flnextparamislast = true;
02171             
02172             if (!getdatevalue (hparam1, 1, &date))
02173                 return (false);
02174 
02175             abbrevdatestring (date, bs);
02176 
02177             return (setstringvalue (bs, v));
02178             }
02179 
02180         case dayofweekfunc: {
02181             unsigned long date;
02182             short day;
02183 
02184             flnextparamislast = true;
02185             
02186             if (!getdatevalue (hparam1, 1, &date))
02187                 return (false);
02188 
02189             secondstodayofweek (date, &day);
02190 
02191             return (setintvalue (day, v));
02192             }
02193 
02194         case daysinmonthfunc: {
02195             unsigned long date;
02196             short day, month, year, hour, minute, second;
02197 
02198             flnextparamislast = true;
02199             
02200             if (!getdatevalue (hparam1, 1, &date))
02201                 return (false);
02202 
02203             secondstodatetime (date, &day, &month, &year, &hour, &minute, &second);
02204 
02205             day = daysInMonth (month, year);
02206 
02207             return (setintvalue (day, v));
02208             }
02209 
02210         case daystringfunc: {
02211             unsigned long date;
02212             short dayofweek;
02213 
02214             flnextparamislast = true;
02215             
02216             if (!getdatevalue (hparam1, 1, &date))
02217                 return (false);
02218 
02219             secondstodayofweek (date, &dayofweek);
02220 
02221             getdaystring (dayofweek, bs, true);
02222 
02223             return (setstringvalue (bs, v));
02224             }
02225 
02226         case firstofmonthfunc: {
02227             unsigned long date;
02228 
02229             flnextparamislast = true;
02230             
02231             if (!getdatevalue (hparam1, 1, &date))
02232                 return (false);
02233 
02234             date = firstofmonth(date);
02235 
02236             return (setdatevalue (date, v));
02237             }
02238 
02239         case lastofmonthfunc: {
02240             unsigned long date;
02241 
02242             flnextparamislast = true;
02243             
02244             if (!getdatevalue (hparam1, 1, &date))
02245                 return (false);
02246 
02247             date = lastofmonth(date);
02248 
02249             return (setdatevalue (date, v));
02250             }
02251 
02252         case longstringfunc: {
02253             unsigned long date;
02254 
02255             flnextparamislast = true;
02256             
02257             if (!getdatevalue (hparam1, 1, &date))
02258                 return (false);
02259 
02260             longdatestring (date, bs);
02261 
02262             return (setstringvalue (bs, v));
02263             }
02264 
02265         case nextmonthfunc: {
02266             unsigned long date;
02267 
02268             flnextparamislast = true;
02269             
02270             if (!getdatevalue (hparam1, 1, &date))
02271                 return (false);
02272 
02273             date = nextmonth(date);
02274 
02275             return (setdatevalue (date, v));
02276             }
02277 
02278         case nextweekfunc: {
02279             unsigned long date;
02280 
02281             flnextparamislast = true;
02282             
02283             if (!getdatevalue (hparam1, 1, &date))
02284                 return (false);
02285 
02286             date = date + (7L*24L*60L*60L);
02287 
02288             return (setdatevalue (date, v));
02289             }
02290 
02291         case nextyearfunc: {
02292             unsigned long date;
02293 
02294             flnextparamislast = true;
02295             
02296             if (!getdatevalue (hparam1, 1, &date))
02297                 return (false);
02298 
02299             date = nextyear(date);
02300 
02301             return (setdatevalue (date, v));
02302             }
02303 
02304         case prevmonthfunc: {
02305             unsigned long date;
02306 
02307             flnextparamislast = true;
02308             
02309             if (!getdatevalue (hparam1, 1, &date))
02310                 return (false);
02311 
02312             date = prevmonth(date);
02313 
02314             return (setdatevalue (date, v));
02315             }
02316 
02317         case prevweekfunc: {
02318             unsigned long date;
02319 
02320             flnextparamislast = true;
02321             
02322             if (!getdatevalue (hparam1, 1, &date))
02323                 return (false);
02324 
02325             date = date - (7L*24L*60L*60L);
02326 
02327             return (setdatevalue (date, v));
02328             }
02329 
02330         case prevyearfunc: {
02331             unsigned long date;
02332 
02333             flnextparamislast = true;
02334             
02335             if (!getdatevalue (hparam1, 1, &date))
02336                 return (false);
02337 
02338             date = prevyear(date);
02339 
02340             return (setdatevalue (date, v));
02341             }
02342 
02343         case shortstringfunc: {
02344             unsigned long date;
02345 
02346             flnextparamislast = true;
02347             
02348             if (!getdatevalue (hparam1, 1, &date))
02349                 return (false);
02350 
02351             shortdatestring (date, bs);
02352 
02353             return (setstringvalue (bs, v));
02354             }
02355 
02356         case tomorrowfunc: {
02357             unsigned long date;
02358 
02359             flnextparamislast = true;
02360             
02361             if (!getdatevalue (hparam1, 1, &date))
02362                 return (false);
02363 
02364             date = date + (24L*60L*60L);
02365 
02366             return (setdatevalue (date, v));
02367             }
02368 
02369         case weeksinmonthfunc: {
02370             unsigned long date;
02371             short day, month, year, hour, minute, second, dayoffset;
02372 
02373             flnextparamislast = true;
02374             
02375             if (!getdatevalue (hparam1, 1, &date))
02376                 return (false);
02377 
02378             date = firstofmonth (date);
02379 
02380             secondstodatetime (date, &day, &month, &year, &hour, &minute, &second);
02381 
02382             day = daysInMonth (month, year);
02383 
02384             secondstodayofweek (date, &dayoffset);
02385             --dayoffset; /* set ot 0 to 6 */
02386 
02387             return (setintvalue ((short)((day + 6 + dayoffset) / 7), v));
02388             }
02389 
02390         case yesterdayfunc: {
02391             unsigned long date;
02392 
02393             flnextparamislast = true;
02394             
02395             if (!getdatevalue (hparam1, 1, &date))
02396                 return (false);
02397 
02398             date = date - (24L*60L*60L);
02399 
02400             return (setdatevalue (date, v));
02401             }
02402 
02403         case getcurrenttimezonefunc: {
02404             if (!langcheckparamcount (hparam1, 0))
02405                 return (false);
02406 
02407             return (setlongvalue (getcurrenttimezonebias(), v));
02408             }
02409 
02410         case netstandardstringfunc: { //AR 07/07/1999
02411             unsigned long date;
02412 
02413             flnextparamislast = true;
02414             
02415             if (!getdatevalue (hparam1, 1, &date))
02416                 return (false);
02417                         
02418             return (datenetstandardstring (date, v));
02419             }
02420         
02421         case monthtostringfunc: { //AR 07/07/1999
02422             long x;
02423 
02424             flnextparamislast = true;
02425             
02426             if (!getlongvalue (hparam1, 1, &x))
02427                 return (false);
02428             
02429             return (datemonthtostring (x, v));
02430             }
02431 
02432         case dayofweektostringfunc: { //AR 07/07/1999
02433             long x;
02434 
02435             flnextparamislast = true;
02436             
02437             if (!getlongvalue (hparam1, 1, &x))
02438                 return (false);
02439             
02440             return (datedayofweektostring (x, v));
02441             }
02442 
02443         case dateversionlessthanfunc: { //AR 07/07/1999
02444             bigstring bs1, bs2;
02445             Handle h1, h2;
02446             
02447             if (!getreadonlytextvalue (hparam1, 1, &h1))
02448                 return (false);
02449 
02450             flnextparamislast = true;
02451 
02452             if (!getreadonlytextvalue (hparam1, 2, &h2))
02453                 return (false);
02454             
02455             texthandletostring (h1, bs1);
02456 
02457             texthandletostring (h2, bs2);
02458             
02459             return (dateversionlessthan (bs1, bs2, v));
02460             }
02461 
02462         case directionfunc:
02463             flnextparamislast = true;
02464             
02465             return (getdirectionparam (hparam1, 1, v));
02466         
02467         case ostypefunc:
02468             flnextparamislast = true;
02469             
02470             return (getostypeparam (hparam1, 1, v));
02471         
02472         case stringfunc:
02473             flnextparamislast = true;
02474             
02475             flcoerceexternaltostring = true; /*special case -- enable for this verb*/
02476             
02477             fl = getstringparam (hparam1, 1, v);
02478             
02479             flcoerceexternaltostring = false;
02480             
02481             return (fl);
02482         
02483         case displaystringfunc:
02484             flnextparamislast = true;
02485             
02486             if (!getparamvalue (hparam1, 1, v))
02487                 break;
02488             
02489             flcoerceexternaltostring = true; /*special case -- enable for this verb*/
02490             
02491             fl = getobjectmodeldisplaystring (v, bs);
02492             
02493             flcoerceexternaltostring = false;
02494             
02495             if (!fl)
02496                 break;
02497             
02498             return (setstringvalue (bs, v));
02499             
02500         case addressfunc:
02501             flnextparamislast = true;
02502             
02503             return (getaddressparam (hparam1, 1, v));
02504         
02505         case binaryfunc:
02506             flnextparamislast = true;
02507             
02508             return (getbinaryparam (hparam1, 1, v));
02509         
02510         case getbinarytypefunc: {
02511             Handle x;
02512             tyvaluerecord val;
02513             
02514             flnextparamislast = true;
02515             
02516             #ifdef version42orgreater
02517                 if (!getparamvalue (hparam1, 1, &val))
02518                     break;
02519                 
02520                 if (!coercetobinary (&val))
02521                     break;
02522                 
02523                 x = val.data.binaryvalue;
02524             #else
02525                 if (!getbinaryvalue (hparam1, 1, true, &x))
02526                     break;
02527             #endif
02528             
02529             setostypevalue (getbinarytypeid (x), v);
02530             
02531             return (true);
02532             }
02533         
02534         case setbinarytypefunc: {
02535             hdlhashtable htable;
02536             tyvaluerecord val;
02537             OSType type;
02538             hdlhashnode hnode;
02539             
02540             if (!getvarvalue (hparam1, 1, &htable, bs, &val, &hnode))
02541                 break;
02542             
02543             if (val.valuetype != binaryvaluetype) {
02544                 
02545                 langerror (binaryrequirederror);
02546                 
02547                 break;
02548                 }
02549             
02550             flnextparamislast = true;
02551             
02552             if (!getostypevalue (hparam1, 2, &type))
02553                 break;
02554             
02555             setbinarytypeid (val.data.binaryvalue, type);
02556             
02557             langsymbolchanged (htable, bs, hnode, true);
02558             
02559             (*v).data.flvalue = true;
02560             
02561             return (true);
02562             }
02563         
02564         case pointfunc:
02565             flnextparamislast = true;
02566             
02567             return (getpointparam (hparam1, 1, v));
02568         
02569         case setpointfunc: {
02570             Point pt;
02571             
02572             if (!getintvalue (hparam1, 1, &pt.h))
02573                 break;
02574             
02575             flnextparamislast = true;
02576             
02577             if (!getintvalue (hparam1, 2, &pt.v))
02578                 break;
02579             
02580             setpointvalue (pt, v);
02581             
02582             return (true);
02583             }
02584         
02585         case getpointfunc: {
02586             Point pt;
02587             
02588             if (!getpointvalue (hparam1, 1, &pt))
02589                 break;
02590             
02591             if (!setintvarparam (hparam1, 2, pt.h))
02592                 break;
02593             
02594             flnextparamislast = true;
02595             
02596             if (!setintvarparam (hparam1, 3, pt.v))
02597                 break;
02598             
02599             (*v).data.flvalue = true;
02600             
02601             return (true);
02602             }
02603         
02604         case rectfunc:
02605             flnextparamislast = true;
02606             
02607             return (getrectparam (hparam1, 1, v));
02608         
02609         case setrectfunc: {
02610             Rect r;
02611             diskrect dr;
02612             
02613             if (!getintvalue (hparam1, 1, &dr.top))
02614                 break;
02615             
02616             if (!getintvalue (hparam1, 2, &dr.left))
02617                 break;
02618             
02619             if (!getintvalue (hparam1, 3, &dr.bottom))
02620                 break;
02621             
02622             flnextparamislast = true;
02623             
02624             if (!getintvalue (hparam1, 4, &dr.right))
02625                 break;
02626 
02627             /*can not use diskrecttorect because that swaps the byte order */
02628             /*      diskrecttorect (&dr, &r);       */
02629             r.top = dr.top;
02630             r.bottom = dr.bottom;
02631             r.left = dr.left;
02632             r.right = dr.right;
02633             
02634             return (newheapvalue (&r, longsizeof (r), rectvaluetype, v));
02635             }
02636         
02637         case getrectfunc: {
02638             Rect r;
02639             
02640             if (!langcheckparamcount (hparam1, 5)) /*preflight*/
02641                 break;
02642             
02643             if (!getrectvalue (hparam1, 1, &r))
02644                 break;
02645             
02646             if (!setintvarparam (hparam1, 2, (short)r.top))
02647                 break;
02648             
02649             if (!setintvarparam (hparam1, 3, (short)r.left))
02650                 break;
02651             
02652             if (!setintvarparam (hparam1, 4, (short)r.bottom))
02653                 break;
02654             
02655             if (!setintvarparam (hparam1, 5, (short)r.right))
02656                 break;
02657             
02658             (*v).data.flvalue = true;
02659             
02660             return (true);
02661             }
02662         
02663         case rgbfunc:
02664             flnextparamislast = true;
02665             
02666             return (getrgbparam (hparam1, 1, v));
02667         
02668         case setrgbfunc: {
02669             RGBColor rgb;
02670             
02671             if (!getintvalue (hparam1, 1, (short *) &rgb.red))
02672                 break;
02673             
02674             if (!getintvalue (hparam1, 2, (short *) &rgb.green))
02675                 break;
02676             
02677             flnextparamislast = true;
02678             
02679             if (!getintvalue (hparam1, 3, (short *) &rgb.blue))
02680                 break;
02681             
02682             return (newheapvalue (&rgb, longsizeof (rgb), rgbvaluetype, v));
02683             }
02684         
02685         case getrgbfunc: {
02686             RGBColor rgb;
02687             
02688             if (!langcheckparamcount (hparam1, 4)) /*preflight*/
02689                 break;
02690             
02691             if (!getrgbvalue (hparam1, 1, &rgb))
02692                 break;
02693             
02694             if (!setintvarparam (hparam1, 2, rgb.red))
02695                 break;
02696             
02697             if (!setintvarparam (hparam1, 3, rgb.green))
02698                 break;
02699             
02700             if (!setintvarparam (hparam1, 4, rgb.blue))
02701                 break;
02702             
02703             (*v).data.flvalue = true;
02704             
02705             return (true);
02706             }
02707         
02708         case patternfunc:
02709             flnextparamislast = true;
02710             
02711             return (getpatternparam (hparam1, 1, v));
02712         
02713         case fixedfunc:
02714             flnextparamislast = true;
02715             
02716             return (getfixedparam (hparam1, 1, v));
02717         
02718         case singlefunc:
02719             flnextparamislast = true;
02720             
02721             return (getsingleparam (hparam1, 1, v));
02722         
02723         case doublefunc:
02724             flnextparamislast = true;
02725             
02726             return (getdoubleparam (hparam1, 1, v));
02727         
02728         case filespecfunc:
02729             flnextparamislast = true;
02730             
02731             return (getfilespecparam (hparam1, 1, v));
02732         
02733         case aliasfunc:
02734             flnextparamislast = true;
02735             
02736             return (getaliasparam (hparam1, 1, v));
02737         
02738         case listfunc:
02739             flnextparamislast = true;
02740             
02741             if (!getparamvalue (hparam1, 1, v))
02742                 break;
02743             
02744             return (coercevalue (v, listvaluetype));
02745         
02746         case recordfunc:
02747             flnextparamislast = true;
02748             
02749             if (!getparamvalue (hparam1, 1, v))
02750                 break;
02751             
02752             return (coercevalue (v, recordvaluetype));
02753         
02754         case enumfunc:
02755             flnextparamislast = true;
02756             
02757             if (!getparamvalue (hparam1, 1, v))
02758                 break;
02759             
02760             return (coercevalue (v, enumvaluetype));
02761         
02762         case memavailfunc:
02763             if (!langcheckparamcount (hparam1, 0))
02764                 break;
02765             
02766             return (setlongvalue (FreeMem (), v));
02767         
02768         case flushmemfunc: {
02769             long ctbytes = longinfinity;
02770             
02771             if (!langcheckparamcount (hparam1, 0))
02772                 break;
02773             
02774             shellcallmemoryhooks (&ctbytes);
02775             
02776             #if MACVERSION && fldebug
02777             
02778                 CompactMem (longinfinity); /*makes it easier to debug heap leakage*/
02779             
02780             #endif
02781             
02782             return (setbooleanvalue ((boolean)(ctbytes < longinfinity), v));
02783             }
02784         
02785         case randomfunc: {
02786             long lower, upper, n;
02787             
02788             if (!getlongvalue (hparam1, 1, &lower))
02789                 break;
02790             
02791             flnextparamislast = true;
02792             
02793             if (!getlongvalue (hparam1, 2, &upper))
02794                 break;
02795             
02796             if (lower > upper) {
02797                 
02798                 langerror (badrandomboundserror);
02799                 
02800                 break;
02801                 }
02802             
02803             n = rand ();    // 3/10/97 dmb - was: Random ();
02804             
02805             n = lower + (abs (n) % (upper - lower + 1));
02806             
02807             return (setlongvalue (n, v));
02808             
02809             /*
02810             if (!langcheckparamcount (hparam1, 0))
02811                 break;
02812             
02813             return (setlongvalue (Random (), v));
02814             */
02815             }
02816         
02817         #if !flruntime
02818         
02819         case mousebuttonfunc:
02820             if (!langcheckparamcount (hparam1, 0))
02821                 break;
02822             
02823             return (setbooleanvalue (mousebuttondown (), v));
02824         
02825         case mouselocationfunc: {
02826             Point pt;
02827             WindowPtr w = getfrontwindow ();
02828             
02829             if (!langcheckparamcount (hparam1, 0))
02830                 break;
02831             
02832             if (w == nil)
02833                 pt.h = pt.v = 0;
02834             
02835             else {
02836                 //Code change by Timothy Paustian Monday, August 21, 2000 4:29:53 PM
02837                 //pushport must receive a CGrafPtr, no implicit converstion on OS X
02838                 CGrafPtr    thePort;
02839                 #if TARGET_API_MAC_CARBON == 1
02840                 thePort = GetWindowPort(w);
02841                 #else
02842                 thePort = (CGrafPtr)w;
02843                 #endif
02844                 pushport (thePort);
02845                 
02846                 getmousepoint (&pt);
02847                 
02848                 popport ();
02849                 }
02850             
02851             return (setpointvalue (pt, v));
02852             }
02853         
02854         #endif
02855         
02856         case optionkeyfunc: case cmdkeyfunc: case shiftkeyfunc: case controlkeyfunc:
02857             if (!langcheckparamcount (hparam1, 0))
02858                 break;
02859             
02860             return (setbooleanvalue (keyboardmodifierverb ((tylangtoken) token), v));
02861         
02862         /*  
02863         case presskeyfunc: {
02864             char ch;
02865             
02866             flnextparamislast = true;
02867             
02868             if (!getcharvalue (hparam1, 1, &ch))
02869                 break;
02870             
02871             return (setbooleanvalue (presskeyverb (ch), v));
02872             }
02873         */
02874         
02875         case absfunc: { /*absolute value*/
02876             tyvaluerecord val;
02877             tyvaluerecord zeroval;
02878             tyvaluerecord tempval;
02879             
02880             flnextparamislast = true;
02881             
02882             if (!getparamvalue (hparam1, 1, &val))
02883                 break;
02884             
02885             setlongvalue (0, &zeroval); /*our comparison value*/
02886             
02887             if (!copyvaluerecord (val, &tempval)) /*work on a copy*/
02888                 break;
02889             
02890             if (!LTvalue (tempval, zeroval, &tempval)) /*couldn't compare to zero*/
02891                 break;
02892             
02893             if (tempval.data.flvalue) /*val was less than zero -- return negative*/
02894                 return (unaryminusvalue (val, v));
02895             
02896             return (copyvaluerecord (val, v)); /*return original value*/
02897             }
02898         
02899         case evaluatefunc: {
02900             Handle htext;
02901             
02902             flnextparamislast = true;
02903             
02904             if (!getexempttextvalue (hparam1, 1, &htext))
02905                 break;
02906             
02907             /*
02908             if (!getstringvalue (hparam1, 1, bs))
02909                 break;
02910             
02911             if (!newtexthandle (bs, &htext))
02912                 break;
02913             */
02914             
02915             if (!langrun (htext, v))
02916                 setbooleanvalue (false, v);
02917             
02918             return (true);
02919             }
02920         
02921         case evaluatethreadfunc: {
02922             Handle htext;
02923             
02924             flnextparamislast = true;
02925             
02926             if (!getexempttextvalue (hparam1, 1, &htext))
02927                 break;
02928             
02929             if (!processruntext (htext))
02930                 break;
02931             
02932             (*v).data.flvalue = true;
02933             
02934             return (true);
02935             }
02936         
02937         case alertdialogfunc:
02938             flnextparamislast = true;
02939             
02940             if (!getstringvalue (hparam1, 1, bs))
02941                 break;
02942             
02943             (*v).data.flvalue = alertdialog (bs);
02944             
02945             return (true);
02946         
02947     #ifdef MACVERSION
02948         case rundialogfunc:
02949             return (langrundialog (hparam1, v));
02950         
02951         #if !flruntime
02952         
02953         case runmodelessfunc:
02954             return (langrunmodeless (hparam1, v));
02955         
02956         #endif
02957     #endif
02958 
02959     #if macBirdRuntime
02960     
02961         case runcardfunc:
02962             return (langruncard (hparam1, false, v));
02963         
02964         case runmodalcardfunc:
02965             return (langruncard (hparam1, true, v));
02966         
02967         case ismodalcardfunc:
02968             return (langismodalcard (hparam1, v));
02969         
02970         case setmodalcardtimeoutfunc:
02971             return (langsetmodalcardtimeout (hparam1, v));
02972     #endif
02973     
02974     #ifdef MACVERSION
02975         case getdialogvaluefunc:
02976             return (langgetdialogvalue (hparam1, v));
02977         
02978         case setdialogvaluefunc:
02979             return (langsetdialogvalue (hparam1, v));
02980         
02981         case setdialogitemenablefunc:
02982             return (langsetdialogitemenable (hparam1, v));
02983         
02984         case showdialogitemfunc:
02985             return (langsetdialogitemvis (hparam1, true, v));
02986         
02987         case hidedialogitemfunc:
02988             return (langsetdialogitemvis (hparam1, false, v));
02989     #endif
02990     
02991         case twowaydialogfunc:
02992             return (twowayfunc (hparam1, v));       
02993         
02994         case threewaydialogfunc:
02995             return (threewayfunc (hparam1, v));
02996         
02997         case askdialogfunc:
02998             return (askfunc (hparam1, v, false));
02999 
03000         case askpassworddialogfunc:
03001             return (askfunc (hparam1, v, true));
03002         
03003         case getintdialogfunc:
03004             return (getintfunc (hparam1, v));
03005 
03006         case notifytdialogfunc:
03007             flnextparamislast = true;
03008             
03009             if (!getstringvalue (hparam1, 1, bs))
03010                 break;
03011             
03012             (*v).data.flvalue = notifyuser (bs);
03013             
03014             return (true);
03015 
03016         case getuserinfodialogfunc:
03017             return (getuserinfofunc (hparam1, v));
03018 
03019         case soundfunc: {
03020             short duration, amplitude, frequency;
03021             
03022             if (!getintvalue (hparam1, 1, &duration))
03023                 break;
03024                 
03025             if (!getintvalue (hparam1, 2, &amplitude))
03026                 break;
03027             
03028             flnextparamislast = true;
03029                 
03030             if (!getintvalue (hparam1, 3, &frequency))
03031                 break;
03032                                 
03033             dosound (duration, amplitude, frequency);
03034             
03035             (*v).data.flvalue = true;
03036             
03037             return (true);
03038             }
03039         
03040         case playsoundfunc:
03041             flnextparamislast = true;
03042             
03043             if (!getstringvalue (hparam1, 1, bs))
03044                 break;
03045             
03046             return (setbooleanvalue (playnamedsound (bs), v));
03047         
03048         case sysbeepfunc:
03049             if (!langcheckparamcount (hparam1, 0))
03050                 break;
03051             
03052             sysbeep ();
03053             
03054             (*v).data.flvalue = true;
03055             
03056             return (true);
03057         
03058         case tickcountfunc:
03059             if (!langcheckparamcount (hparam1, 0))
03060                 break;
03061             
03062             return (setlongvalue (gettickcount (), v));
03063         
03064         case millisecondcountfunc: {  /* 2005-01-08 SMD */
03065             if (!langcheckparamcount (hparam1, 0))
03066                 break;
03067             
03068             return (setlongvalue (getmilliseconds (), v));
03069             }
03070         
03071         case delayfunc: {
03072             long ctseconds;
03073             
03074             flnextparamislast = true;
03075             
03076             if (!getlongvalue (hparam1, 1, &ctseconds))
03077                 break;
03078             
03079             delayseconds (ctseconds);
03080             
03081             (*v).data.flvalue = true;
03082             
03083             return (true);
03084             }
03085         
03086         case sleepfunc: {
03087             long ctseconds;
03088             
03089             if (processisoneshot (true) && !langdialogrunning ()) {
03090                 
03091                 langparamerror (foragentsonlyerror, bsfunctionname);
03092                 
03093                 break;
03094                 }
03095             
03096             flnextparamislast = true;
03097             
03098             if (!getlongvalue (hparam1, 1, &ctseconds))
03099                 break;
03100                 
03101             (*v).data.flvalue = processagentsleep (ctseconds);
03102             
03103             return (true);
03104             }
03105                     
03106         case delaysixtiethsfunc: {
03107             long ctsixtieths;
03108             
03109             flnextparamislast = true;
03110             
03111             if (!getlongvalue (hparam1, 1, &ctsixtieths))
03112                 break;
03113             
03114             delayticks (ctsixtieths);
03115             
03116             (*v).data.flvalue = true;
03117             
03118             return (true);
03119             }
03120         
03121         case beachballfunc: {
03122             if (!langcheckparamcount (hparam1, 0))
03123                 break;
03124             
03125             if (!beachballcursor ())
03126                 initbeachball (right);
03127             
03128             rollbeachball ();
03129             
03130             (*v).data.flvalue = true;
03131             
03132             return (true);
03133             }
03134         
03135     #if isFrontier && MACVERSION
03136     
03137         case seteventtimeoutfunc:
03138             return (langipcsettimeout (hparam1, v));
03139         
03140         case seteventtransactionidfunc:
03141             return (langipcsettransactionid (hparam1, v));
03142         
03143         case seteventinteractionlevelfunc:
03144             return (langipcsetinteractionlevel (hparam1, v));
03145         
03146         case geteventattrfunc:
03147             return (langipcgeteventattr (hparam1, v));
03148         
03149         case coerceappleitemfunc:
03150             return (langipccoerceappleitem (hparam1, v));
03151         
03152         case putlistitemfunc:
03153             return (langipcputlistitem (hparam1, v));
03154         
03155         case getlistitemfunc:
03156             return (langipcgetlistitem (hparam1, v));
03157         
03158         case countlistitemsfunc:
03159             return (langipccountlistitems (hparam1, v));
03160     
03161         /*
03162         case ddeinitfunc:
03163             return (langipcddeinit (hparam1, v));
03164         */
03165         
03166         case systemeventfunc:
03167             return (langipcmessage (hparam1, systemmsg, v));
03168         
03169         case microsofteventfunc:
03170             return (langipcmessage (hparam1, noreplymsg + transactionmsg + microsoftmsg, v));
03171         
03172         case transactioneventfunc:
03173             return (langipcmessage (hparam1, transactionmsg, v));
03174     
03175     #endif
03176         
03177         case timecreatedfunc: {
03178             long timecreated, timemodified;
03179             
03180             if (!gettimesverb (hparam1, &timecreated, &timemodified))
03181                 return (setbooleanvalue (false, v));
03182             
03183             return (setdatevalue (timecreated, v));
03184             }
03185         
03186         case timemodifiedfunc: {
03187             long timecreated, timemodified;
03188             
03189             if (!gettimesverb (hparam1, &timecreated, &timemodified))
03190                 return (setbooleanvalue (false, v));
03191             
03192             return (setdatevalue (timemodified, v));
03193             }
03194         
03195         case settimecreatedfunc:
03196             return (settimesverb ((tylangtoken) settimecreatedfunc, hparam1, v));
03197         
03198         case settimemodifiedfunc:
03199             return (settimesverb ((tylangtoken) settimemodifiedfunc, hparam1, v));
03200         
03201         case msgfunc:
03202             return ((*langcallbacks.msgverbcallback) (hparam1, v));
03203         
03204     #if MACVERSION && TARGET_API_MAC_OS8 /*7.0b49: not implemented in OS X*/
03205             case callxcmdfunc:
03206                 return (callxcmdverb (hparam1, v));
03207     #endif
03208 
03209         case callscriptfunc:
03210             return (callscriptverb (hparam1, v));
03211 
03212         case dllcallfunc:
03213         case calldllfunc:       /* this is remaining for historical usage per Dave. rab: 5.0b4 1/6/98 */
03214             return (dllcallverb (hparam1, v));
03215 
03216         case dllloadfunc:
03217             return (dllloadverb (hparam1, v));
03218         
03219         case dllunloadfunc:
03220             return (dllunloadverb (hparam1, v));
03221         
03222         case dllisloadedfunc:
03223             return (dllisloadedverb (hparam1, v));
03224 
03225         case packwindowfunc:
03226             return (langpackwindowverb (hparam1, v));
03227         
03228         case unpackwindowfunc:
03229             return (langunpackwindowverb (hparam1, v));
03230         
03231         case getbitfunc:
03232             return (bitgetverb (hparam1, v));
03233         
03234         case setbitfunc:
03235             return (bitsetverb (hparam1, v));
03236     
03237         case clearbitfunc:
03238             return (bitclearverb (hparam1, v));
03239         
03240         case bitandfunc:
03241             return (bitandverb (hparam1, v));
03242 
03243         case bitorfunc:
03244             return (bitorverb (hparam1, v));
03245 
03246         case bitxorfunc:
03247             return (bitxorverb (hparam1, v));
03248 
03249         case bitshiftleftfunc:
03250             return (bitshiftleftverb (hparam1, v));
03251 
03252         case bitshiftrightfunc:
03253             return (bitshiftrightverb (hparam1, v));
03254 
03255         case lockfunc:
03256             return (locksemaphoreverb (hparam1, v));
03257         
03258         case unlockfunc:
03259             return (unlocksemaphoreverb (hparam1, v));
03260         
03261         case base64encodefunc:
03262             return (base64encodeverb (hparam1, v));
03263         
03264         case base64decodefunc:
03265             return (base64decodeverb (hparam1, v));
03266 
03267 
03268 /* This is the only place where these verbs are ifdef'd out for the Macintosh.  
03269    This is done so that an app written to these verbs will have a graceful unimplemented
03270    error message on the mac. */
03271 
03272 //#ifdef WIN95VERSION
03273         case netaddressdecode:
03274             {
03275             long addr;
03276 
03277             flnextparamislast = true;
03278 
03279             if (!getlongvalue (hparam1, 1, &addr))
03280                 return (false);
03281 
03282             if (fwsNetEventAddressDecode (addr, bs))
03283                 return (setstringvalue (bs, v));
03284 
03285             return (false);
03286             }
03287 
03288         case netaddressencode:
03289             {
03290             long addr;
03291 
03292             flnextparamislast = true;
03293 
03294             if (!getstringvalue (hparam1, 1, bs))
03295                 return (false);
03296 
03297             if (fwsNetEventAddressEncode(bs, (unsigned long *)(&addr)))
03298                 return (setlongvalue (addr, v));
03299 
03300             return (false);
03301             }
03302 
03303         case netaddresstoname:
03304             {
03305             long addr;
03306 
03307             flnextparamislast = true;
03308 
03309             if (!getlongvalue (hparam1, 1, &addr))
03310                 return (false);
03311 
03312             if (fwsNetEventAddressToName (addr, bs))
03313                 return (setstringvalue (bs, v));
03314 
03315             return (false);
03316             }
03317 
03318         case netnametoaddress:
03319             {
03320             long addr;
03321 
03322             flnextparamislast = true;
03323 
03324             if (!getstringvalue (hparam1, 1, bs))
03325                 return (false);
03326 
03327             if (fwsNetEventNameToAddress(bs, (unsigned long *)(&addr)))
03328                 return (setlongvalue (addr, v));
03329 
03330             return (false);
03331             }
03332 
03333         case netmyaddress:
03334             {
03335             long addr;
03336 
03337             if (fwsNetEventMyAddress((unsigned long *)(&addr)))
03338                 return (setlongvalue (addr, v));
03339 
03340             return (false);
03341             }
03342 
03343         case netabortstream:
03344             {
03345             long stream;
03346 
03347             flnextparamislast = true;
03348 
03349             if (!getlongvalue (hparam1, 1, &stream))
03350                 return (false);
03351 
03352             if (fwsNetEventAbortStream (stream))
03353                 return (setbooleanvalue (true, v));
03354 
03355             return (false);
03356             }
03357 
03358         case netclosestream:
03359             {
03360             long stream;
03361 
03362             flnextparamislast = true;
03363 
03364             if (!getlongvalue (hparam1, 1, &stream))
03365                 return (false);
03366 
03367             if (fwsNetEventCloseStream (stream))
03368                 return (setbooleanvalue (true, v));
03369 
03370             return (false);
03371             }
03372 
03373         case netcloselisten:
03374             {
03375             long stream;
03376 
03377             flnextparamislast = true;
03378 
03379             if (!getlongvalue (hparam1, 1, &stream))
03380                 return (false);
03381 
03382             if (fwsNetEventCloseListen (stream))
03383                 return (setbooleanvalue (true, v));
03384 
03385             return (false);
03386             }
03387 
03388         case netopenaddrstream:
03389             {
03390             long stream;
03391             long port;
03392             long addr;
03393 
03394             if (!getlongvalue (hparam1, 1, &addr))
03395                 return (false);
03396 
03397             flnextparamislast = true;
03398 
03399             if (!getlongvalue (hparam1, 2, &port))
03400                 return (false);
03401 
03402             if (fwsNetEventOpenAddrStream (addr, port, (unsigned long *)(&stream)))
03403                 return (setlongvalue (stream, v));
03404 
03405             return (false);
03406             }
03407 
03408         case netopennamestream:
03409             {
03410             long stream;
03411             long port;
03412 
03413             if (!getstringvalue (hparam1, 1, bs))
03414                 return (false);
03415 
03416             flnextparamislast = true;
03417 
03418             if (!getlongvalue (hparam1, 2, &port))
03419                 return (false);
03420 
03421             if (fwsNetEventOpenNameStream (bs, port, (unsigned long *)(&stream)))
03422                 return (setlongvalue (stream, v));
03423 
03424             return (false);
03425             }
03426 
03427         case netreadstream:
03428             {
03429             long stream;
03430             long len;
03431             char * charbuffer;
03432             Handle buf;
03433 
03434             if (!getlongvalue (hparam1, 1, &stream))
03435                 return (false);
03436 
03437             flnextparamislast = true;
03438 
03439             if (!getlongvalue (hparam1, 2, &len))
03440                 return (false);
03441 
03442             if (!newhandle (len, &buf))
03443                 return (false);
03444 
03445             lockhandle (buf);
03446 
03447             charbuffer = *buf;
03448 
03449             if (fwsNetEventReadStream (stream, (unsigned long *)(&len), charbuffer)) {
03450                 unlockhandle (buf);
03451                 SetHandleSize (buf, len);
03452                 return (setbinaryvalue (buf, '\?\?\?\?', v));
03453                 }
03454 
03455             unlockhandle (buf);     /*cleanup*/
03456             disposehandle (buf);
03457             return (false);
03458             }
03459 
03460         case netwritestream:
03461             {
03462             long stream;
03463             long len;
03464             char * charbuffer;
03465             Handle buf;
03466 
03467             if (!getlongvalue (hparam1, 1, &stream))
03468                 return (false);
03469 
03470             flnextparamislast = true;
03471     
03472             if (!gettextvalue (hparam1, 2, &buf))
03473                 return (false);
03474 
03475             len = gethandlesize (buf);
03476 
03477             lockhandle (buf);
03478 
03479             charbuffer = *buf;
03480 
03481             if (fwsNetEventWriteStream (stream, len, charbuffer)) {
03482                 unlockhandle (buf);
03483                 return (setbooleanvalue (true, v));
03484                 }
03485 
03486             unlockhandle (buf);
03487             return (false);
03488             }
03489 
03490         case netlistenstream:
03491             {
03492             long stream;
03493             long port;
03494             long refcon;
03495             long depth;
03496             unsigned long ipaddr;
03497             tyvaluerecord callbackval;
03498             hdlhashtable ht;    
03499             bigstring bsFullName;
03500 
03501             if (!getlongvalue (hparam1, 1, &port))
03502                 return (false);
03503 
03504             if (!getlongvalue (hparam1, 2, &depth))
03505                 return (false);
03506 
03507             if (!getaddressparam (hparam1, 3, &callbackval))
03508                 return (false);
03509             
03510             if (!getaddressvalue (callbackval, &ht, bs))
03511                 return (false);
03512 
03513             if (! langexternalgetquotedpath (ht, bs, bsFullName))
03514                 return (false);
03515 
03516             if (!getlongvalue (hparam1, 4, &refcon))
03517                 return (false);
03518 
03519             flnextparamislast = true;
03520     
03521             if (!getlongvalue (hparam1, 5, (long *)(&ipaddr)))
03522                 return (false);
03523             
03524             if (fwsNetEventListenStream (port, depth, bsFullName, refcon, (unsigned long *)(&stream), ipaddr, (long)(**((hdlexternalvariable)(**ht).hashtablerefcon)).hdatabase))
03525                 return (setlongvalue (stream, v));
03526 
03527             return (false);
03528             }
03529 
03530 
03531         case netstatusstream:
03532             {
03533             long stream;
03534             unsigned long bytesPending;
03535 
03536             if (!langcheckparamcount (hparam1, 2))
03537                 return (false);
03538 
03539             if (!getlongvalue (hparam1, 1, &stream))
03540                 return (false);
03541 
03542             if (fwsNetEventStatusStream (stream, bs, &bytesPending)) {
03543                 langsetlongvarparam (hparam1, 2, bytesPending);
03544                 return (setstringvalue (bs, v));
03545                 }
03546 
03547             return (false);
03548             }
03549 
03550         case netgetpeeraddress: {
03551             long stream;
03552             unsigned long adr, port;
03553 
03554             flnextparamislast = true;
03555 
03556             if (!getlongvalue (hparam1, 1, &stream))
03557                 return (false);
03558 
03559             if (fwsNetEventGetPeerAddress (stream, &adr, &port))
03560                 return (setlongvalue (adr, v));
03561 
03562             return (false);
03563             }
03564 
03565         case netgetpeerport: {
03566             long stream;
03567             unsigned long adr, port;
03568 
03569             flnextparamislast = true;
03570 
03571             if (!getlongvalue (hparam1, 1, &stream))
03572                 return (false);
03573 
03574             if (fwsNetEventGetPeerAddress (stream, &adr, &port))
03575                 return (setlongvalue (port, v));
03576 
03577             return (false);
03578             }
03579 
03580         case netwritestringtostream: {
03581             long stream, chunksize, timeout;
03582             Handle htext;
03583 
03584             if (!getlongvalue (hparam1, 1, &stream))
03585                 return (false);
03586 
03587             if (!getreadonlytextvalue (hparam1, 2, &htext))
03588                 return (false);
03589 
03590             if (!getlongvalue (hparam1, 3, &chunksize))
03591                 return (false);
03592             
03593             flnextparamislast = true;
03594 
03595             if (!getlongvalue (hparam1, 4, &timeout))
03596                 return (false);
03597 
03598             if (!fwsNetEventWriteHandleToStream (stream, htext, chunksize, timeout))
03599                 return (false);
03600 
03601             return (setbooleanvalue (true, v));
03602             }
03603         
03604         case netwritefiletostream: {
03605             long stream;
03606             tyvaluerecord vprefix;
03607             tyvaluerecord vsuffix;
03608             short ctconsumed = 2;
03609             short ctpositional = 2;
03610             tyfilespec fs;
03611 
03612             if (!getlongvalue (hparam1, 1, &stream))
03613                 return (false);
03614                 
03615             if (!getfilespecvalue (hparam1, 2, &fs))
03616                 return (false);
03617                 
03618             initvalue (&vprefix, stringvaluetype);
03619 
03620             if (!getoptionalparamvalue (hparam1, &ctconsumed, &ctpositional, BIGSTRING ("\x06" "prefix"), &vprefix)) 
03621                 return (false);
03622             
03623             initvalue (&vsuffix, stringvaluetype);
03624 
03625             flnextparamislast = true;
03626 
03627             if (!getoptionalparamvalue (hparam1, &ctconsumed, &ctpositional, BIGSTRING ("\x06" "suffix"), &vsuffix)) 
03628                 return (false);
03629 
03630             if (!fwsNetEventWriteFileToStream (stream, vprefix.data.stringvalue, vsuffix.data.stringvalue, &fs))
03631                 return (false);
03632 
03633             return (setbooleanvalue (true, v));
03634             }
03635 
03636 
03637         case netreadstreamuntil: {
03638             long stream, timeout;
03639             Handle hpattern;
03640             tyvaluerecord vadrbuffer, vbuffer;
03641             tyaddress adrbuffer;
03642             hdlhashnode hnode;
03643             
03644             if (!getlongvalue (hparam1, 1, &stream))
03645                 return (false);
03646 
03647             if (!getreadonlytextvalue (hparam1, 2, &hpattern))
03648                 return (false);
03649 
03650             if (!getlongvalue (hparam1, 3, &timeout))
03651                 return (false);
03652             
03653             flnextparamislast = true;
03654 
03655             if (!getaddressparam (hparam1, 4, &vadrbuffer))
03656                 return (false);
03657 
03658             if (!getaddressvalue (vadrbuffer, &adrbuffer.ht, adrbuffer.bs))
03659                 return (false);
03660 
03661             if (!langhashtablelookup (adrbuffer.ht, adrbuffer.bs, &vbuffer, &hnode))
03662                 return (false);
03663 
03664             if (!coercetostring (&vbuffer))
03665                 return (false);
03666 
03667             if (!fwsNetEventReadStreamUntil (stream, vbuffer.data.stringvalue, hpattern, timeout))
03668                 return (false);
03669 
03670             // new hdlhashnode parameter set to nil, should be OK because we only care if it's externl
03671             langsymbolchanged (adrbuffer.ht, adrbuffer.bs, nil, true);
03672 
03673             return (setbooleanvalue (true, v));
03674             }
03675 
03676         case netreadstreambytes: {
03677             long stream, ctbytes, timeout;
03678             tyvaluerecord vadrbuffer, vbuffer;
03679             tyaddress adrbuffer;
03680             hdlhashnode hnode;
03681 
03682             if (!getlongvalue (hparam1, 1, &stream))
03683                 return (false);
03684 
03685             if (!getlongvalue (hparam1, 2, &ctbytes))
03686                 return (false);
03687             
03688 
03689             if (!getlongvalue (hparam1, 3, &timeout))
03690                 return (false);
03691             
03692             flnextparamislast = true;
03693 
03694             if (!getaddressparam (hparam1, 4, &vadrbuffer))
03695                 return (false);
03696 
03697             if (!getaddressvalue (vadrbuffer, &adrbuffer.ht, adrbuffer.bs))
03698                 return (false);
03699 
03700             if (!langhashtablelookup (adrbuffer.ht, adrbuffer.bs, &vbuffer, &hnode))
03701                 return (false);
03702 
03703             if (!coercetostring (&vbuffer))
03704                 return (false);
03705 
03706             if (!fwsNetEventReadStreamBytes (stream, vbuffer.data.stringvalue, ctbytes, timeout))
03707                 return (false);
03708 
03709             langsymbolchanged (adrbuffer.ht, adrbuffer.bs, nil, true);
03710 
03711             return (setbooleanvalue (true, v));
03712             }
03713 
03714         case netreadstreamuntilclosed: {
03715             long stream, timeout;
03716             tyvaluerecord vadrbuffer, vbuffer;
03717             tyaddress adrbuffer;
03718             hdlhashnode hnode;
03719             
03720             if (!getlongvalue (hparam1, 1, &stream))
03721                 return (false);
03722 
03723             if (!getlongvalue (hparam1, 2, &timeout))
03724                 return (false);
03725             
03726             flnextparamislast = true;
03727 
03728             if (!getaddressparam (hparam1, 3, &vadrbuffer))
03729                 return (false);
03730 
03731             if (!getaddressvalue (vadrbuffer, &adrbuffer.ht, adrbuffer.bs))
03732                 return (false);
03733 
03734             if (!langhashtablelookup (adrbuffer.ht, adrbuffer.bs, &vbuffer, &hnode))
03735                 return (false);
03736 
03737             if (!coercetostring (&vbuffer))
03738                 return (false);
03739 
03740             if (!fwsNetEventReadStreamUntilClosed (stream, vbuffer.data.stringvalue, timeout))
03741                 return (false);
03742 
03743             langsymbolchanged (adrbuffer.ht, adrbuffer.bs, nil, true);
03744 
03745             return (setbooleanvalue (true, v));
03746             }
03747         
03748         case netstatus: {
03749         
03750             #if defined(MACVERSION) && __POWERPC__
03751                 long stream = nil;
03752                 bigstring lbs;
03753                 
03754                 if (langgetparamcount (hparam1) > 0) {
03755                 
03756                     flnextparamislast = true;
03757                     
03758                     if (!getlongvalue (hparam1, 1, &stream))
03759                         return (false);
03760                     }
03761                 
03762                 if (!fwsNetEventGetStats (stream, lbs))
03763                     return (false);
03764                     
03765                 return (setstringvalue (lbs, v));
03766             #else
03767                 langerror (unimplementedverberror);
03768 
03769                 return (false);
03770             #endif
03771             }
03772 
03773         case netcountconnections: {
03774 
03775             /*7.0b37 PBS: return the current TCP connections count.*/
03776 
03777             return (setlongvalue (fwsNetEventGetConnectionCount (), v));
03778             }
03779 
03780         //case pythondoscriptfunc:
03781         //  return (langrunpythonscript (hparam1, v));
03782 
03783 
03784         /* These functions are  for Windows - the code to ifdef 
03785             is in htmlcontrol.c  8/26/00 by RAB */
03786         
03787         #ifdef WIN95VERSION
03788 
03789         case htmlcontrolbackfunc: {
03790             if (!langcheckparamcount (hparam1, 0))
03791                 return (false);
03792             htmlcontrolback();
03793             return (setbooleanvalue (true, v));
03794             }
03795 
03796         case htmlcontrolforwardfunc: {
03797             if (!langcheckparamcount (hparam1, 0))
03798                 return (false);
03799             htmlcontrolforward();
03800             return (setbooleanvalue (true, v));
03801             }
03802 
03803         case htmlcontrolrefreshfunc: {
03804             if (!langcheckparamcount (hparam1, 0))
03805                 return (false);
03806             htmlcontrolrefresh();
03807             return (setbooleanvalue (true, v));
03808             }
03809 
03810         case htmlcontrolhomefunc: {
03811             if (!langcheckparamcount (hparam1, 0))
03812                 return (false);
03813             htmlcontrolhome();
03814             return (setbooleanvalue (true, v));
03815             }
03816 
03817         case htmlcontrolstopfunc: {
03818             if (!langcheckparamcount (hparam1, 0))
03819                 return (false);
03820             htmlcontrolstop();
03821             return (setbooleanvalue (true, v));
03822             }
03823 
03824         case htmlcontrolnavigatefunc: {
03825             Handle htext;
03826 
03827             flnextparamislast = true;
03828 
03829             if (!getreadonlytextvalue (hparam1, 1, &htext))
03830                 return (false);
03831 
03832             htmlcontrolnavigate (htext);
03833 
03834             return (setbooleanvalue (true, v));
03835             }
03836         
03837         case htmlcontrolisofflinefunc: {
03838             boolean fl;
03839 
03840             if (! langcheckparamcount (hparam1, 0))
03841                 return (false);
03842 
03843             if (! htmlcontrolisoffline (&fl))
03844                 return (false);
03845 
03846             return (setbooleanvalue (fl, v));
03847             }
03848         
03849         case htmlcontrolsetofflinefunc: {
03850             boolean fl;
03851 
03852             flnextparamislast = true;
03853 
03854             if (!getbooleanvalue (hparam1, 1, &fl))
03855                 return (false);
03856 
03857             if (! htmlcontrolsetoffline (fl))
03858                 return (false);
03859 
03860             return (setbooleanvalue (true, v));
03861             }
03862         
03863         /*7.0b20 PBS: new statusbar verbs from Bob*/
03864         
03865         case statusbarmsgfunc: {
03866             long partNumber;
03867 
03868             if (langgetparamcount (hparam1) == 1) {
03869                 flnextparamislast = true;
03870 
03871                 if (!getstringvalue (hparam1, 1, bs))
03872                     return (false);
03873 
03874                 return (setbooleanvalue (setstatusbarstring (bs, 0), v));
03875                 }
03876 
03877             if (langgetparamcount (hparam1) == 2) {
03878 
03879                 if (!getstringvalue (hparam1, 1, bs))
03880                     return (false);
03881 
03882                 flnextparamislast = true;
03883 
03884                 if (!getlongvalue (hparam1, 2, &partNumber))
03885                     return (false);
03886 
03887                 partNumber--; /*7.0b21 PBS: partNumber is one-based at the script level*/
03888 
03889                 return (setbooleanvalue (setstatusbarstring (bs, partNumber), v));
03890                 }
03891 
03892             return (false);
03893             }
03894         
03895 
03896         case statusbargetmessagefunc: {
03897             long partNumber;
03898             bigstring bs;
03899 
03900             if (langgetparamcount (hparam1) == 0) {
03901                 getstatusbarstring (bs, 0);
03902 
03903                 return (setstringvalue (bs, v));
03904                 }
03905 
03906             if (langgetparamcount (hparam1) == 1) {
03907 
03908                 flnextparamislast = true;
03909 
03910                 if (!getlongvalue (hparam1, 1, &partNumber))
03911                     return (false);
03912 
03913                 partNumber--; /*7.0b21 PBS: partNumber is one-based at the script level*/
03914 
03915                 getstatusbarstring (bs, partNumber);
03916 
03917                 return (setstringvalue (bs, v));
03918                 }
03919 
03920             return (false);
03921             }
03922         
03923         case statusbarsetsectionsfunc: {
03924             long partCount;
03925             long wArray[50];
03926             int i;
03927             tyvaluerecord vlist;
03928             tyvaluerecord val;
03929             hdllistrecord hlist;
03930 
03931             flnextparamislast = true;
03932 
03933             if (!getparamvalue (hparam1, 1, &vlist))
03934                 return (false);
03935 
03936             if (!coercetolist (&vlist, listvaluetype))
03937                 return (false);
03938 
03939             wArray[0] = -1;
03940 
03941             langgetlistsize (&vlist, &partCount);
03942 
03943             hlist = vlist.data.listvalue;
03944 
03945             if (partCount > 48)
03946                 return (false);
03947 
03948             for (i = 1; i <= partCount; i++) {
03949                 if (!getnthlistval (hlist, i, nil, &val))
03950                     return (false);
03951 
03952                 if (!coercevalue (&val, intvaluetype))
03953                     return (false);
03954 
03955                 wArray[i] = val.data.intvalue;
03956                 }
03957 
03958             return (setbooleanvalue (setstatusbarparts (partCount+1, wArray), v));
03959             }
03960 
03961         case statusbargetsectionsfunc: {
03962             long partCount;
03963             long wArray[50];
03964             int i;
03965             //tyvaluerecord vlist;
03966             //tyvaluerecord val;
03967             hdllistrecord hlist;
03968 
03969 
03970             partCount = getstatusbarparts (wArray);
03971 
03972             if (!opnewlist (&hlist, false))
03973                 return (false);
03974 
03975             for (i = 2; i <= partCount; i++) { /*7.0b21 PBS: don't get the first section width*/
03976                 if (!langpushlistlong (hlist, wArray[i-1])) 
03977                     goto getstatuspartsfuncerror;
03978                 }
03979 
03980             return (setheapvalue ((Handle) hlist, listvaluetype, v));
03981 
03982             getstatuspartsfuncerror:
03983 
03984             opdisposelist (hlist);
03985             
03986             return (false);
03987             }
03988 
03989         case statusbargetsectiononefunc: {
03990 
03991             /*
03992             7.0b21 PBS: get the width of the first section, which varies in size
03993             when the window is resized.
03994             */
03995 
03996             long wArray [50];
03997 
03998             getstatusbarparts (wArray);
03999 
04000             return (setlongvalue (wArray [0], v));
04001             }
04002         
04003         /*Windows Registry verbs -- 7.0.2b1 Radio PBS*/
04004 
04005         case winregistrygettypefunc: {
04006             
04007             Handle h;
04008             bigstring bstype;
04009             boolean fl;
04010 
04011             flnextparamislast = true;
04012         
04013             if (!getexempttextvalue (hparam1, 1, &h))
04014                 return (false);
04015 
04016             fl = winreggettype (h, bstype);
04017 
04018             disposehandle (h);
04019 
04020             if (!fl)
04021                 return (false);
04022 
04023             return (setstringvalue (bstype, v));
04024             }
04025 
04026         case winregistryreadfunc: {
04027 
04028             Handle h;
04029             boolean fl = false;
04030 
04031             flnextparamislast = true;
04032 
04033             if (!getexempttextvalue (hparam1, 1, &h))
04034                 return (false);
04035             
04036             fl = winregread (h, v);
04037 
04038             disposehandle (h);
04039 
04040             return (fl);
04041             }
04042 
04043         case winregistrydeletefunc: {
04044 
04045             Handle h;
04046             boolean fl = false;
04047             
04048             flnextparamislast = true;
04049 
04050             if (!getexempttextvalue (hparam1, 1, &h))
04051                 return (false);
04052 
04053             fl = winregdelete (h);
04054 
04055             disposehandle (h);
04056 
04057             return (setbooleanvalue (fl, v));
04058             }
04059 
04060         case winregistrywritefunc: {
04061 
04062             Handle h;
04063             tyvaluerecord val;
04064             bigstring bstype;
04065             short ctparams;
04066             boolean fl = false;
04067 
04068             if (!getexempttextvalue (hparam1, 1, &h))
04069                 return (false);
04070 
04071             ctparams = langgetparamcount (hparam1);
04072 
04073             if (ctparams == 2)
04074                 flnextparamislast = true;
04075 
04076             if (!getparamvalue (hparam1, 2, &val))
04077                 return (false);
04078 
04079             setemptystring (bstype);
04080             
04081             if (ctparams > 2) {
04082 
04083                 flnextparamislast = true;
04084 
04085                 if (!getstringvalue (hparam1, 3, bstype)) {
04086 
04087                     disposehandle (h);
04088                 
04089                     return (false);
04090                     } /*if*/
04091                 } /*if*/
04092 
04093             fl = winregwrite (h, &val, bstype);
04094             
04095             disposehandle (h);
04096 
04097             return (setbooleanvalue (fl, v));
04098             }
04099 
04100         #endif /*WIN95VERSION*/
04101         
04102 //#endif
04103 
04104         default:
04105             getstringlist (langerrorlist, unimplementedverberror, bserror);
04106             
04107             break;
04108         } /*switch*/
04109     
04110     return (false);
04111     } /*langfunctionvalue*/
04112 
04113 
04114 /*
04115 DW 6/18/19
04116 
04117 obsolete verbs that we won't have glue for, won't document
04118     
04119     checksyntax
04120     closeprogressdialog
04121     continueprogressdialog
04122     getfiletext
04123     openpalette
04124     pattern
04125     runprogram
04126     runstring
04127     startprogressdialog
04128     syntaxtrace
04129     username
04130 
04131 remaining very basic verbs, implemented in lang.c
04132 
04133     appleevent
04134     complexevent
04135     defined
04136     sizeof
04137     typeof
04138     pack
04139     unpack
04140     EFP
04141     finderevent
04142     gestalt
04143     myMoof
04144     objspec                        
04145     syscrash
04146     tmp
04147     setobj
04148 
04149 */
04150 
04151 
04152 
04153 boolean langinitbuiltins (void) {
04154     
04155     /*
04156     9/15/92 dmb: initialize randSeed with current date/time so we don't get 
04157     the same sequence each time
04158     
04159     2.1b5 dmb: use new loadfunctionprocessor for resource-based initialization
04160     */
04161 
04162     srand (timenow ());  // 3/10/97 dmb - was: qd.randSeed = timenow ();
04163 
04164     return (loadfunctionprocessor (idlangverbs, &langfunctionvalue));
04165     } /*langinitbuiltins*/
04166 
04167 
04168 
04169 

Generated on Wed May 31 18:19:54 2006 for frontierkernel 10.1.10a by  doxygen 1.4.6