|
generate_gsl
- Generate GSL
| Syntax: |
string generate_gsl(string
filename, float includeDataCommands, float
includeAllPages, string path) |
| Description: |
Generate the GSL commands
to recreate the graphics that have been defined.
For each object that has been created in Gsharp
a create command is output and for any resources which have non-default
values a resource line is included. e.g.
create Viewport page_1.viewport_1
( XuNfirstDiagonalPoint = (12.23,13.22),
XuNsecondDiagonalPoint = (44.32,18.99)
);
- if filename is not set then the GSL commands
are returned as a string array
- if includeDataCommands is true then a
log of any data commands (file open, interpolate etc.) is also
included at the top of the output.
- if includeAllPages is true then GSL is
created for all pages, if not then only the current page is created.
- If path has been set then GSL is created
for the specified object and all its children (includeAllPages
is ignored).
|
| Sample output: |
set displayoption
( XuNautoRepaint = true
);
set page_1
( XuNsize = (166.113,140.884) mm
);
create Viewport page_1.viewport_1;
create Domain page_1.viewport_1.domain_1;
create Graph page_1.viewport_1.domain_1.graph_1
( XuNxData = "cos(1:100)",
XuNyData = "sin(1:100)"
);
|
| Sample code: |
function SaveLayout(string filename)
float f;
f = fopen(filename, "w");
if (f<0) return;
fwrite(f, "#This Layout is for MyApp");
fwrite(f, "WORK.LayoutVersion = 2.3;");
fwrite(f, "ResetAll();"//"CreateTemplate()");
fwrite(f, generate_gsl(,false));
fclose(f);
endfunction
|
| See also: |
exec,
eval
|
get_messages - get
status of message flags
| Syntax: |
get_messages(float
errors, float warnings, float information, float
user) |
| Description: |
get_messages gets the state
of each message flag and stores it in the corresponding variable.
- There is an input variable for each type of message
that Gsharp can output.
- By default all message types are switched on.
- Use set_messages to turn messages on and off.
- The output of the echo and printf commands is
controlled by the user flag.
|
| Sample code
1: |
#turn off user-defined messages
float u;
get_messages(,,,u);
set_messages(,,,false);
|
| See also: |
set_messages
|
getcode - get country
code
| Syntax: |
string getcode(string
country) |
| Description: |
Return the corresponding
code for the specified country.
- The code can be used with the import_worldmap
function.
- getcode(), getcode("") or getcode("*")
returns the full list of country codes
|
| Examples: |
country
|
getcode(country) |
"Denmark"
"St-Pierre et Miquelon"
"Trinidad and Tobago" |
"DEN"
"PMQ"
"TRI" |
| Sample code: |
code = getcode("Brazil");
import_worldmap(code);
|
| See also: |
getcountry,
showcode,
showcountry,
import_worldmap,
Country Codes
|
getcountry - get country
from code
| Syntax: |
string getcountry(string
code) |
| Description: |
Return the country
of the specified code.
- getcountry(), getcountry("") or getcountry("*")
returns the full list of countries
|
| Examples: |
code
|
getcountry(code) |
"DEN"
"PMQ"
"TRI" |
"Denmark"
"St-Pierre et Miquelon"
"Trinidad and Tobago" |
| Sample code: |
function string FindCountry(string c)
string allc;
allc = getcountry();
return mask(allc, strstr(allc,c)<>undef);
endfunction
matching = FindCountry("Br");
echo(matching + " - " + getcode(matching));
|
| See also: |
getcode, showcode,
showcountry,
import_worldmap,
Country Codes
|
getdir - get working directory
| Syntax: |
string getdir() |
| Description: |
Return the working directory
|
| Sample code: |
tmpDir = getdir();
setdir(WORK.TemplateDir);
CreateTemplates();
setdir(tmpDir);
|
|
|
setdir(workingdir);
if (getdir()<>workingdir) then
echo("Cannot set working directory to: "+workingdir);
endif
|
| See also: |
setdir
|
getenums - get enumerated
values
| Syntax: |
string getenums(string
resource) |
| Description: |
Return all the possible enumerated
values for the specified resource |
| Example: |
getenums("page_1.XuNorientation")
|
"landscape"
"portrait" |
|
Sample code:
|
WORK.LineStyles = getenums("graph.XuNlineStyle");
create Combobox gsharp_1.mydialog.linestyle
( XuNguiPosition = (100,0),
XuNguiCallback = "LineStyleChangedCB",
XuNguiListItems = "WORK.LineStyles"
);
|
| See also: |
getresources
|
getenv - get environment
variable
| Syntax: |
string getenv(string
name) |
| Description: |
Get the value of the environment
variable name. This function could be used to during start-up
to configure Gsharp based on an environment variable.
- If there is no environment variable name,
then getenv returns undef.
- Environment variables can be included in file
names.e.g.
include "$UNIDIR/lib/libhtml.gsl";
|
| Code Sample: |
user = getenv("USER");
if user="Bob" then
CreateBobsMenu();
else
CreateUserMenu();
endif
|
| See also: |
putenv
|
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);
...
|
getresources
- get object's resources
| Syntax: |
string getresources(string
object, float visible) |
| Description: |
Return all the resources
of the specified object.
- object can either be the full pathname
of an object ("page_1.viewport_1") or an object class
("Viewport")
- If visible is true, then only return resources
which are currently available, e.g. for the specified graph type.
By default all resources are returned.
|
| Example: |
getresources("Folder")
|
|
"XuNdestroyable"
"XuNeditorData"
"XuNimmutable"
"XuNinternalData"
"XuNname"
"XuNsave"
"XuNuserData"
|
| See also: |
getenums
|
getunit - get unit
used by resource
| Syntax: |
string string getunit(string
resource) |
| Description: |
Returns the current unit
of the specified resource.
-
If resource does not exist or is not a resource
relating to size then undef is returned.
-
Sizes can be specified in "%", "mm",
"cm", "m", "inch", "ft",
"pixel", "point", "deg" or "rad".
- % is normally relative to the smaller length
of the viewport's sides, but check the documentation of the specific
resource.
1000 mm = 100 cm = 1 m
864 point = 12 inch = 1 ft = .3048 m
A pixel is the smallest size supported by a device
180 deg = 3.14159265358979323846 rad (angles) |
|
| Code sample: |
function FindPageSize(float &origin, float &pagesize)
pagesize = page_1.XuNsize;
origin = ( GetMargin("page_1.XuNmarginLeft", pagesize[,1]),
GetMargin("page_1.XuNmarginBottom", pagesize[,2]) );
pagesize = (pagesize - origin) -
(GetMargin("page_1.XuNmarginRight", pagesize[,1]),
GetMargin("page_1.XuNmarginTop", pagesize[,2]) );
endfunction
function float GetMargin(string res, float pagesize)
float vval;
string vunit;
vval = $res;
vunit = getunit(res);
if vunit = "%" then
return (pagesize * vval) / 100;
elif vunit = "inch" then
return vval * 25.4;
endif
return vval;
endfunction
|
| See also: |
getresources
|
|