/* xltest - get the :test or :test-not keyword argument */ VOID xltest P2C(LVAL *, pfcn, int *, ptresult) { if (xlgetkeyarg(k_test,pfcn)) /* :test */ *ptresult = TRUE; else if (xlgetkeyarg(k_tnot,pfcn)) /* :test-not */ *ptresult = FALSE; else { *pfcn = getfunction(s_eql); *ptresult = TRUE; } }
/* xlopen - open a text or binary file */ LVAL xlopen(int binaryflag) { char *name,*mode=NULL; FILE *fp; LVAL dir; /* get the file name and direction */ name = (char *)getstring(xlgetfname()); if (!xlgetkeyarg(k_direction,&dir)) dir = k_input; /* get the mode */ if (dir == k_input) mode = "r"; else if (dir == k_output) mode = "w"; else xlerror("bad direction",dir); /* try to open the file */ if (binaryflag) { fp = osbopen(name,mode); } else { fp = osaopen(name,mode); } return (fp ? cvfile(fp) : NIL); }
LVAL xlkey(V) { LVAL kfcn; /* TAA MOD, 7/93, so if key is IDENTITY, it is ignored */ if (xlgetkeyarg(k_key,&kfcn) && kfcn != s_identity) return kfcn; return NIL; }
/* xlgkfixnum - get a fixnum keyword argument */ int xlgkfixnum P2C(LVAL, key, LVAL *, pval) { if (xlgetkeyarg(key,pval)) { if (!fixp(*pval)) xlbadtype(*pval); return (TRUE); } return (FALSE); }
/* :ISNEW Method */ LVAL xsitem_isnew(V) { LVAL item, title, value; item = xlgaobject(); title = xlgastring(); set_item_ivar('T', item, title); object_isnew(item); if (xlgetkeyarg(sk_enabled, &value)) set_item_ivar('E', item, value); else set_item_ivar('E', item, s_true); return(NIL); /* to keep compilers happy - L. Tierney */ }
/* xload - read and evaluate expressions from a file */ LVAL xload(void) { unsigned char *name; int vflag,pflag; LVAL arg; /* get the file name */ name = getstring(xlgetfname()); /* get the :verbose flag */ if (xlgetkeyarg(k_verbose,&arg)) vflag = (arg != NIL); else vflag = TRUE; /* get the :print flag */ if (xlgetkeyarg(k_print,&arg)) pflag = (arg != NIL); else pflag = FALSE; /* load the file */ return (xlload((char *) name, vflag, pflag) ? s_true : NIL); }
LVAL iview_apply_transformation(V) { IVIEW_WINDOW w; LVAL m, b, object; int vars; object = xlgaobject(); w = (IVIEW_WINDOW) get_iview_address(object); m = xlgamatrix(); if (! xlgetkeyarg(sk_basis, &b)) b = NIL; vars = IViewNumVariables(w); set_internal_transformation(vars, m, b); IViewApplyTransformation(w, transform, inbasis); check_redraw(object, TRUE, TRUE); return(NIL); }
/****************************************************************************** * Prim_POPEN - start a process and open a pipe for read/write * (code stolen from xlfio.c:xopen()) * * syntax: (popen <command line> :direction <direction>) * <command line> is a string to be sent to the subshell (sh). * <direction> is either :input (to read from the pipe) or * :output (to write to the pipe). * (:input is the default) * * Popen returns a stream, or NIL if files or processes couldn't be created. * The success of the command execution can be checked by examining the * return value of pclose. * * Added to XLISP by Niels Mayer ******************************************************************************/ LVAL Prim_POPEN() { extern LVAL k_direction, k_input, k_output; char *name,*mode; FILE *fp; LVAL dir; /* get the process name and direction */ name = (char *) getstring(xlgastring()); if (!xlgetkeyarg(k_direction, &dir)) dir = k_input; /* get the mode */ if (dir == k_input) mode = "r"; else if (dir == k_output) mode = "w"; else xlerror("bad direction",dir); /* try to open the file */ return ((fp = popen(name,mode)) ? cvfile(fp) : NIL); }
LVAL iview_hist_adjust_to_data(V) { LVAL object; IVIEW_WINDOW w; StGWWinInfo *gwinfo; double low, high; int ticks, labeled, x, y, scaled, bins; char *label; LVAL arg, hdata; gethistargs(&w, &object, &hdata); if (! IVIEW_WINDOW_NULL(w)) { gwinfo = StGWObWinInfo(object); StGrObAdjustToData(object, FALSE); scaled = (slot_value(object, s_scale_type) != NIL) ? TRUE : FALSE; StGrGetContentVariables(gwinfo, &x, &y); IViewGetRange(w, x, &low, &high); label = IViewVariableLabel(w, x); labeled = (label != NULL && strlen(label) != 0) ? TRUE : FALSE; ticks = 4; GetNiceRange(&low, &high, &ticks); IViewSetRange(w, x, low, high); IViewSetXaxis(w, ! scaled, labeled, ticks); bins = 5 + log(1.0 + IViewNumPoints(w)); GetNiceRange(&low, &high, &bins); if (bins > 1) bins --; if (bins > 30) bins = 30; IViewHistSetNumBins(object, hdata, bins); if (! xlgetkeyarg(sk_draw, &arg)) arg = s_true; if (arg != NIL) send_message(object, sk_resize); if (arg != NIL) send_message(object, sk_redraw); } return(NIL); }