GsharpWE Built-in Functions

This page lists the built-in functions that are relevant to the Gsharp Web Edition. For a complete description of all Gsharp functions, please refer to GSL Commands

 

getpid - get process id

Syntax: string float getpid()
Description: Get the id of the Gsharp process. This id is unique to the current Gsharp process and so can be used to create a unique filename that will not clash with another Gsharp process running the same script
Code Sample:
filename = "$TMP/log"+getpid()+".dat";
fptr = fopen(filename","w");
fprint(fptr,"Log started at "+time+" on "+date);

tmpnam - name of temporary file

Syntax: string tmpnam()
Description: Return a unique filename that can be used as a temporary file.
  • On Windows tmpnam() returns the name of a temporary file in the root directory. If you would rather use a file in C:\Windows\TEMP then use:

    "C:\\Windows\\TEMP"+tmpnam() or

    getenv("TEMP")+tmpnam();

    if you have the TEMP environment variable set on your system.

bounding_polygon - bounding polygon of an object

Syntax: float bounding_polygon(string object, float numVertices, float x, float y, string component, float row, float column, float plane, float numData, string resources)
Description: bounding_polygon returns the outline of any graphical object in Gsharp. It's main use is in the Gsharp Web Edition to create image maps for drilling down into graphs. See the Gsharp Web Edition documentation for more details and examples.
  • The function returns the number of polygons that bound the object
  • numVertices, x and y must already exist before bounding_polygon is called.
  • component can be used to specify the component of an axis object, e.g. "axle", "labels", "text", "tickmarks", "ticklines" or "unit". The default is "all".
  • The built-in function bounding_polygon specifies the polygon in mm's. The function HTMLbounding_polygon is a wrapper to this function which can be used to convert to your own preferred units.
Example:
include "$UNIDIR/lib/libhtml.gsl";
function PolygonExample(string object)
  float npoly, numvert, x, y, r, c, p, numdata;
  float lines, vertIndex, dataIndex;
  string resources;
  npoly = HTMLbounding_polygon(object, numvert, x, y, "",
                        r, c, p, numdata, resources, 100, 100);

  vertIndex = 0//accum(numvert);
  dataIndex = 0//accum(numdata);

  for i=1 to npoly
    lines = (vertIndex[i]+1):vertIndex[i+1];
    rx = slicex(x,lines);    ry = slicex(y,lines);
    lines = (dataIndex[i]+1):dataIndex[i+1];
    j = lines[1];
    echo("row="+r[j]+" column="+c[j]+" plane="+p[j]);
    echo("("+rx+","+ry+")");
  endfor
endfunction
create Viewport page_1.viewport_1;
create Domain page_1.viewport_1.domain_1;
create Graph page_1.viewport_1.domain_1.graph_1
   ( XuNgraphType = "bar",
     XuNxData = "1:4",
     XuNyData = "1:4"
   );
PolygonExample("page_1.viewport_1.domain_1.graph_1")