/* viewobj.spl */
#include
/* default height and width */
#define _VIEWOBJ_H 300
#define _VIEWOBJ_W 360
static pfile = "";
static viewobj_numitems();
static viewobj_object_header();
static viewobj_object_footer();
static viewobj_object_format_string();
static viewobj_cell_header();
static viewobj_cell_footer();
static viewobj_cell_format_string();
/* view any variable */
viewobj(obj = refwin(w0), objname = "", title = "Object Properties and Methods", h = -1, w = -1)
{
local iscell;
iscell = viewobj_iscell(obj);
if (iscell)
{
viewobj_cell(obj, objname, title, h, w);
}
else
{
viewobj_object(obj, objname, title, h, w);
}
}
/* display object properties and methods */
viewobj_object(obj = 0, objname = "", title = "Object Properties and Methods", h = -1, w = -1)
{
local numprop, nummethod, i, j, k, vtype, val, valstr, name, curobj, nc, ni;
/* temp file for html */
pfile = getmiscpath(1, 1) + "vobject.htm";
if (fopen(pfile, "w") > 0)
{
/* html header */
viewobj_object_header(pfile);
ni = viewobj_numitems(obj);
loop (i = 1..ni)
{
if (isstripchart(obj))
{
nc = 1;
}
else
{
nc = isarray(obj) ? numcols(refseries(obj, i)) : 1;
}
loop (k = 1..nc)
{
/* get type, get value and type as strings */
(type, valstr, vtype) = valuetype(obj, LOCAL_VARIABLE);
/* show value if it exists */
if (type != 105 && k == 1)
{
fputs('
Value
\n', pfile);
/* html table */
fputs('
\n', pfile);
fputs('
Name
Type
Value
\n', pfile);
/* format for HTML */
valstr = viewobj_object_format_string(valstr);
/* html table row */
fputs(sprintf("
%s
%s
%s
", objname, vtype, valstr), pfile);
/* close table */
fputs("
\n", pfile);
}
curobj = isarray(obj) ? castobject(refseries(obj, i, k)) : obj;
if (isobject(curobj))
{
/* properties */
if ((numprop = getbasepropertyname(curobj, -1)) > 0)
{
if (nc > 1)
{
fputs(sprintf('
Series %d Properties
\n', k), pfile);
}
else
{
fputs('
Properties
\n', pfile);
}
/* html table */
fputs('
\n', pfile);
fputs('
Name
Type
Value
\n', pfile);
loop (j = 1..numprop)
{
/* get property name, value and type as strings */
(name, valstr, vtype) = getbasepropertyname(curobj, j);
/* format for HTML */
valstr = viewobj_object_format_string(valstr);
/* html table row */
fputs(sprintf("
\n", pfile);
}
if ((nummethod = getbasemethodname(curobj, -1)) > 0)
{
if (numprop > 0)
{
fputs('
\n', pfile);
}
fputs('
Methods
\n', pfile);
/* html table */
fputs('
\n', pfile);
fputs('
Name
Args
Value
\n', pfile);
loop (j = 1..nummethod)
{
/* get property name, value and type as strings */
(name, valstr, vtype) = getbasemethodname(curobj, j);
/* format for HTML */
valstr = viewobj_object_format_string(valstr);
/* html table row */
fputs(sprintf("