|
echo - output expressions
|
Syntax:
|
echo(expression1, expression2, expression3,
...)
|
|
Description:
|
Output expressions to message area.
- There is no limit to the number of parameters that can be passed
to the echo command.
|
|
Examples:
|
echo("x = "+x);
echo("Error: "+filename+" does not exist);
echo("T"+(1:9));
echo(x, " ", y, " ", z);
|
|
See also:
|
printf,
fprintf
|
eval - execute GSL
|
Syntax:
|
eval(string expression)
|
|
Description:
|
Execute specified commands
-
Errors in the expression will not cause a script to stop
-
Can be used if to specify objects which cannot be specified
using pointers. e.g. functions, resources or expressions - see
samples below.
-
Also useful for redefining functions on the fly - see SetFactor
example below.
-
eval cannot be used with local variables - it only works with
real datasets. e.g. eval("echo(a);"); will echo the
dataset a, even if a local variable a exists.
|
| Code samples: |
function SetFactor(float n)
eval("function float factor() return "+n+"; endfunction");
endfunction
|
function string GetResource(string OBJ, string res)
eval("WORK.TmpValue = "+OBJ+".XuN"+res);
return WORK.TmpValue;
endfunction
|
function float AddAny(x, y)
float z;
WORK.TmpX = x; WORK.TmpY = y;
eval("WORK.TmpZ="+typeof(x)+"Add(WORK.TmpX,WORK.TmpY);");
z = WORK.TmpZ;
destroy WORK.TmpX, WORK.TmpY, WORK.TmpZ;
return z;
endfunction
function float floatAdd(float x, float y)
return x+y;
endfunction
function string stringAdd(string x, string y)
return x+y;
endfunction
function date dateAdd(date x, float y)
return invdaysince(daysince(x)+y);
endfunction
function time timeAdd(time x, float y)
return invsecsince(secsince(x)+y);
endfunction
echo("In a weeks time the date will be:");
echo(AddAny(today,7));
echo("In one hour from now, the time will be:");
echo(AddAny(time,3600));
|
|
See also:
|
exec
|
exec - execute GSL file
|
Syntax:
|
exec(string filename)
|
|
Description:
|
Executes specified GSL file.
This function is useful on the command line of Gsharp when debugging
an external GSL script as the command can be recalled using the
cursor up key rather than having to navigate the File/Open dialog
each time.
However, if you want to include a library of functions inside another
GSL script then it is recommended that you should use the include
statement instead. e.g
include "$UNIDIR/lib/libio.gsl";
rather than
exec("$UNIDIR/lib/libio.gsl");
Please read the page on function
parameters for an explanation of why this is important.
|
|
Code sample:
|
function ReloadLibraries()
exec("libio.gsl");
exec("libgen.gsl");
endfunction
|
|
See also:
|
eval, include
|
exists - check existence of object
|
Syntax:
|
exists(object object)
|
|
Description:
|
Return true if object exists
-
exists works with GUI objects, Graphic objects, datesets, folders
and functions.
-
The full path to a dataset must be used e.g. WORK.argv not
argv. To check for a dataset in the current folder use member().
|
|
Examples:
|
if exists(WORK.argv) destroy WORK.argv;
if not exists(gsharp_1.dialog) CreateDialog();
if exists(page_1.view1) page_1.view1.XuNobjectEnabled = false;
if exists(myfunction) myfunction("a",1);
|
|
Code sample:
|
function string NewView()
string PTR; float i;
PTR = "page_1.view1"; i=1;
while exists($PTR)
i = i+1;
PTR = "page_1.view"+i;
endwhile
return PTR;
endfunction
|
|
See also:
|
member
|
exp - exponential
|
Syntax:
|
float exp(float x)
|
|
Description:
|
Return the exponential of each member of x. The exponential
of x is e^x, where e is equal to 2.71828
|
|
Examples:
|
x
|
exp(x)
|
|
-1
0
1
2
|
0.367879
1
2.71828
7.38906
|
|
See also:
|
log,
log10
|
export_ascii - Export dataset to
ASCII file
|
Syntax:
|
export_ascii(string filename, string dataset)
|
|
Description:
|
The specified dataset is output to the file, filename
-
dataset can be float, string, date or time data
-
Each element of dataset is written to a separate line
-
If dataset is a grid or a block then it is converted
to an array in the same way as the list function. The original
dimensions of dataset are not stored in the file.
-
Remember to specify the dataset as a string - do not pass the
dataset. e.g use export_ascii("args.dat","argv")
not export_ascii("args.dat", argv);
|
|
See also:
|
export_binary, export_folder,
export_report, fwrite,
fprintf,
import_ascii
|
export_ascii_folder - Export
folder to ASCII file
|
Syntax:
|
include "$UNIDIR/lib/libio.gsl";
export_ascii_folder(string filename, string
folder)
|
|
Description:
|
The specified folder is output to the file filename.
Exporting a folder in ASCII format means that is is platform independent
and can be read in a texteditor or by another package.
-
If folder equals "" then the current folder is used.
-
This function is implemented in GSL. Either include the library
libio.gsl (as shown) in your code or copy the function from
your library.
-
It is suggested that you use the extension ".afl"
for ASCII Folders.
-
If you are not concerned about creating platform independent
files, then export_folder and import_folder are
quicker and produces smaller files.
|
|
Example:
|
export_ascii_folder("WORK.afl", "WORK");
|
|
See also:
|
export_folder, import_ascii_folder
|
export_binary - Export dataset
to binary file
|
Syntax:
|
export_binary(string filename, string fileType,
float wordsPerRecord, string dataset)
|
|
Description:
|
The specified dataset is output to the binary file, filename
-
dataset must be a float dataset
-
Each element of dataset is written to a separate line
-
If dataset is a grid or a block then it is converted
to an array in the same way as the list function. The original
dimensions of dataset are not stored in the file.
-
fileType must be one of: "c_byte", "c_float",
"c_int", "c_short", "f77_int"
or "c_real".
-
Binary files are platform dependent and can not be read on
a UNIX system.
|
|
See also:
|
export_ascii, export_folder,
export_report, fwrite,
fprintf,
import_binary
|
export_folder - Archive folder
|
Syntax:
|
export_folder(string filename, string folder)
|
|
Description:
|
The specified folder is archived in the file, filename
-
If folder is not specified, then the current folder
is used.
-
The folder file is platform dependent.
-
The folder format is the only format which can store multiple
datasets together with their dimensions. It is useful for storing
data between sessions.
-
The file extension ".fold" is normally used for folders.
|
|
Code sample:
|
#taken from $UNIDIR\example\Gsharp\gsl\archive.gsl
for FOLD in all("Folder")
export_folder(name+"_"+FOLD+".fold",FOLD);
endfor
|
|
See also:
|
export_ascii, export_binary,
export_report, fwrite,
fprintf,
import_folder
|
export_report - Export folder as
an ASCII file
|
Syntax:
|
export_report(string filename)
|
|
Description:
|
Output the datasets in the current folder to an ASCII file, filename
-
Each dataset will be written to a separate column
-
If a dataset is a row, grid or a block then it is first
converted to an array in the same way as the list function.
The original dimensions of the datasets are not stored in the
report.
-
The dataset names are used for the column titles
-
If the datasets are of a different size then the shorter datasets
are padded out with undef values - represented by a "?"
in the report.
-
The file extension ".dat" is normally used for reports.
|
|
See also:
|
export_ascii, export_binary,
export_folder, fwrite,
fprintf,
import_report
|
exprnd - Exponentially distributed random
numbers
|
Syntax:
|
float exprnd(float n)
|
|
Description:
|
Return n exponentially distributed random numbers with mean 1.0
and standard deviation 1.0
m + exprnd(n)*sd;
|
|
See also:
|
rnd,
normrnd
|
expsemiv - See Kriging
Interpolation
|