root/branches/maintenance/2.2.1/Modelica/Utilities/System.mo

Revision 463, 2.8 kB (checked in by hubertus, 22 months ago)

Created maintenance version from Dynasims version with minimal changes (no checksum, 1 graphics, a few improved documentation places, structurallyIncomplete annotations in Visualizers)

Line 
1package System "Interaction with environment" 
2  extends Modelica.Icons.Library;
3    annotation (
4  preferedView="info",
5Documentation(info="
6<HTML>
7<p>
8This package contains functions to interact with the environment.
9</p>
10</HTML>
11"),   Coordsys(
12        extent=[0, 0; 417, 614],
13        grid=[1, 1],
14        component=[20, 20]),
15      Window(
16        x=0.03,
17        y=0.02,
18        width=0.42,
19        height=0.86,
20        library=1,
21        autolayout=1));
22 
23function getWorkDirectory "Get full path name of work directory" 
24  extends Modelica.Icons.Function;
25  output String directory "Full path name of work directory";
26// POSIX function "getcwd"
27  external "C" directory = ModelicaInternal_getcwd(0);
28    annotation (Documentation(info="<html>
29 
30</html>"));
31end getWorkDirectory;
32 
33function setWorkDirectory "Set work directory" 
34  extends Modelica.Icons.Function;
35  input String directory "New work directory";
36// POSIX function "chdir"
37external "C" ModelicaInternal_chdir(directory);
38    annotation (Documentation(info="<html>
39 
40</html>"));
41end setWorkDirectory;
42 
43function getEnvironmentVariable "Get content of environment variable" 
44  extends Modelica.Icons.Function;
45  input String name "Name of environment variable";
46  input Boolean convertToSlash =  false 
47      "True, if native directory separators in 'result' shall be changed to '/'";
48  output String content
49      "Content of environment variable (empty, if not existent)";
50  output Boolean exist
51      "= true, if environment variable exists; = false, if it does not exist";
52  external "C" ModelicaInternal_getenv(name, convertToSlash, content, exist);
53    annotation (Documentation(info="<html>
54 
55</html>"));
56end getEnvironmentVariable;
57 
58function setEnvironmentVariable "Set content of local environment variable" 
59  extends Modelica.Icons.Function;
60  input String name "Name of environment variable";
61  input String content "Value of the environment variable";
62  input Boolean convertFromSlash =  false 
63      "True, if '/' in content shall be changed to the native directory separator";
64external "C" ModelicaInternal_setenv(name, content, convertFromSlash);
65    annotation (Documentation(info="<html>
66   
67</html>"));
68end setEnvironmentVariable;
69 
70function command "Execute command in default shell" 
71  extends Modelica.Icons.Function;
72  input String string "String to be passed to shell";
73  output Integer result "Return value from command (depends on environment)";
74  external "C" result = system(string);
75    annotation (Documentation(info="<html>
76 
77</html>"));
78end command;
79 
80function exit "Terminate execution of Modelica environment" 
81  extends Modelica.Icons.Function;
82  input Integer status=0 
83      "Result to be returned by environment (0 means success)";
84  external "C" ModelicaInternal_exit(status);
85end exit;
86end System;
Note: See TracBrowser for help on using the browser.