4
/* ----------------------------- */
5
/* CUSTOMFORVECT - defines vector objects that app can #for across */
6
customforvect( result, obj, n )
15
/* ----------------------------- */
16
/* CUSTOMTEXTVECT - defines text objects that app can #for across */
17
customtextvect( result, obj, pos )
26
/* ----------------------------- */
27
/* CUSTOM_FUNCTION - returns 0 on success, 1 if named function not found */
29
/* NOTE: in order to add a custom function it is now necessary to check the
30
hash value of the function name to be sure that it does not collide with
31
existing names. See functions.c, fprintf statement around line 108. */
33
custom_function( name, arg, nargs, result, typ )
40
double Econv(), Elimit();
45
strcpy( result, "0" );
47
/* ------------------- */
48
/* hash:615 $inrange(value,axis) or $inrange(value,axis,min,max)
49
return 1 if value in range for the axis, 0 if not.
50
min and max are optional args */
51
if( strcmp( name, "inrange" )==0 ) {
52
double fval, flow, fhi;
53
axis = tolower( arg[1][0] );
54
fval = Econv( axis, arg[0] );
55
if( nargs > 2 ) flow = Econv( axis, arg[2] );
56
else flow = Elimit( axis, 'l', 's' );
57
if( nargs > 3 ) fhi = Econv( axis, arg[3] );
58
else fhi = Elimit( axis, 'h', 's' );
59
if( fval >= flow && fval <= fhi ) sprintf( result, "1" );
60
else sprintf( result, "0" );
63
/* ------------------- */
64
/* hash:564 $icolor( i ) - return one of 20 color entries, chosen for contrast */
65
else if( strcmp( name, "icolor" )==0 ) {
75
/* ------------------- */
76
/* hash:849 $dataitem(row,field) - return the contents of row,field of current data set.
77
Row is a number (first = 1). Field is a datafield (name or number 1..n) */
78
else if( strcmp( name, "dataitem" )==0 ) {
80
row = atoi( arg[0] ) -1;
81
fld = fref( arg[1] ) -1;
82
sprintf( result, "%s ", da( row, fld ) );
87
/* ------------------- */
88
/* hash:987 $nextstub(maxlen) - return next pltab row stub, "" if no more */
89
else if( strcmp( name, "nextstub" )==0 ) {
91
maxlen = atoi( arg[0] );
92
if( maxlen == 0 ) maxlen = 80;
94
/* see which axis is using categories or pltab scaling.. */
95
Egetunits( 'y', buf );
97
if( strcmp( buf, "categories" )==0 ) nextcat( 'y', result, maxlen );
99
Egetunits( 'x', buf );
100
if( strcmp( buf, "categories" )==0 ) nextcat( 'x', result, maxlen );
101
else Eerr( 2709, "$nextstub only valid with pltab or categories", "" );
103
/* convert spaces to underscores */
104
for( i = 0, slen = strlen( result ); i < slen; i++ ) if( result[i] == ' ' ) result[i] = '_';
110
/* -------------------- */
111
/* hash:206 $max(f1,f2..fn) */
112
else if( strcmp( name, "max" )==0 ) {
115
max = -999999999999999.0;
116
for( i = 0; i < nargs; i++ ) {
117
if( !GL_goodnum( arg[i], &prec ) ) continue; /* added scg 11/15/00 */
118
if( atof( arg[i] ) > max ) max = atof( arg[i] );
120
sprintf( result, "%g", max );
125
/* hash:3396 $data_to_absolute(axis,val) - given a data coordinate, return the absolute location.
126
Example: #set AVAL = $data_to_absolute(Y,@DVAL)
128
else if( strcmp( name, "data_to_absolute" )==0 ) {
129
double f, Econv(), Ea();
130
f = Econv( tolower(arg[0][0]), arg[1] );
131
sprintf( result, "%g", Ea( tolower(arg[0][0]), f ) );
136
/* ------------------- */
137
/* hash:376 sleep( n ) - delay for N seconds */
138
else if( strcmp( name, "sleep" )==0 ) {
146
/* ------------------- */
147
/* hash:793 getclick( label ) - produce a button; when user clicks on it, return */
148
else if( strcmp( name, "getclick" )==0 ) {
149
if( Edev == 'x' ) do_x_button( "More.." );
155
/* ------------------- */
156
/* hash:956 $fieldname(n) - return the field name assigned to field n. First is 1 */
157
else if( strcmp( name, "fieldname" )==0 ) {
158
getfname( atoi( arg[0] ), result );
165
/* hash:615 $exists(val) - return 1 if val has length > 0 */
166
else if( strcmp( name, "exists" )==0 ) {
167
if( arg[0][0] != '\0' ) strcpy( result, "1" );
168
else strcpy( result, "0" );
173
/* hash:1303 $notexists(val) - return 1 if val has length > 0 */
174
else if( strcmp( name, "notexists" )==0 ) {
175
if( arg[0][0] != '\0' ) strcpy( result, "0" );
176
else strcpy( result, "1" );