Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
- Updated help text


git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@12746 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
sjoelund committed Aug 31, 2012
1 parent 1af69cf commit e4804f6
Show file tree
Hide file tree
Showing 7 changed files with 62 additions and 44 deletions.
5 changes: 1 addition & 4 deletions Compiler/FrontEnd/ModelicaBuiltin.mo
Original file line number Diff line number Diff line change
Expand Up @@ -998,10 +998,7 @@ end saveAll;

function help "display the OpenModelica help text."
output String helpText;
annotation(__OpenModelica_EarlyInline = true);
algorithm
helpText := readFile(getInstallationDirectoryPath() + "/share/doc/omc/omc_helptext.txt");
annotation(preferredView="text");
external "builtin";
end help;

function clear "Clears everything: symboltable and variables."
Expand Down
2 changes: 1 addition & 1 deletion Compiler/Main/Main.mo
Original file line number Diff line number Diff line change
Expand Up @@ -1148,7 +1148,7 @@ algorithm
case {}
equation
false = System.userIsRoot();
Debug.bcall0(not Config.helpRequest() /* Already printed help */, Flags.printUsage);
print(Debug.bcallret0(not Config.helpRequest() /* Already printed help */, Flags.printUsage, ""));
then ();

case _
Expand Down
6 changes: 6 additions & 0 deletions Compiler/Script/CevalScript.mo
Original file line number Diff line number Diff line change
Expand Up @@ -1771,6 +1771,12 @@ algorithm
then
(cache,Values.BOOL(true),st);

case (cache,env,"help",{},st as Interactive.SYMBOLTABLE(ast=p),msg)
equation
str = Flags.printUsage();
then
(cache,Values.STRING(str),st);

case (cache,env,"saveModel",{Values.STRING(name),Values.CODE(Absyn.C_TYPENAME(classpath))},
(st as Interactive.SYMBOLTABLE(ast = p)),msg)
equation
Expand Down
24 changes: 24 additions & 0 deletions Compiler/Util/Debug.mo
Original file line number Diff line number Diff line change
Expand Up @@ -346,6 +346,30 @@ algorithm
end matchcontinue;
end fcallret3;

public function bcallret0
"function: bcallret0
Boolean-controlled calling of given function (2nd arg).
The passed function gets 0 arguments.
The last parameter is returned if the boolean is false."
input Boolean flag;
input FuncTypeType_aToType_b func;
input Type_b default;
output Type_b res;
partial function FuncTypeType_aToType_b
output Type_b outTypeB;
end FuncTypeType_aToType_b;
replaceable type Type_b subtypeof Any;
annotation(__OpenModelica_EarlyInline = true);
algorithm
res := match (flag,func,default)
case (true,_,_)
equation
res = func();
then res;
else default;
end match;
end bcallret0;

public function bcallret1
"function: bcallret1
Boolean-controlled calling of given function (2nd arg).
Expand Down
50 changes: 27 additions & 23 deletions Compiler/Util/Flags.mo
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ protected import Error;
protected import ErrorExt;
protected import Global;
protected import List;
protected import Print;
protected import Settings;
protected import System;
public import Util;
Expand Down Expand Up @@ -1474,7 +1475,7 @@ algorithm

case {}
equation
printUsage();
print(printUsage());
then
();

Expand Down Expand Up @@ -1534,29 +1535,32 @@ end printHelp;

public function printUsage
"Prints out the usage text for the compiler."
output String usage;
algorithm
print("OpenModelica Compiler "); print(Settings.getVersionNr()); print("\n");
print(System.gettext("Copyright © 2012 Open Source Modelica Consortium (OSMC)\n"));
print(System.gettext("Distributed under OMSC-PL and GPL, see www.openmodelica.org\n\n"));
//print("Please check the System Guide for full information about flags.\n");
print(System.gettext("Usage: omc [-runtimeOptions +omcOptions] (Model.mo | Script.mos) [Libraries | .mo-files] \n* Libraries: Fully qualified names of libraries to load before processing Model or Script.\n The libraries should be separated by spaces: Lib1 Lib2 ... LibN.\n* runtimeOptions: call omc -help to see runtime options\n"));
print(System.gettext("* +omcOptions:\n"));
print(printAllConfigFlags());
print("\n");
print(System.gettext("* Examples:\n"));
print(System.gettext("\tomc Model.mo will produce flattened Model on standard output\n"));
print(System.gettext("\tomc +s Model.mo will produce simulation code for the model:\n"));
print(System.gettext("\t * Model.c the model C code\n"));
print(System.gettext("\t * Model_functions.c the model functions C code\n"));
print(System.gettext("\t * Model.makefile the makefile to compile the model.\n"));
print(System.gettext("\t * Model_init.xml the initial values\n"));
//print("\tomc Model.mof will produce flattened Model on standard output\n");
print(System.gettext("\tomc Script.mos will run the commands from Script.mos\n"));
print(System.gettext("\tomc Model.mo Modelica will first load the Modelica library and then produce \n\t flattened Model on standard output\n"));
print(System.gettext("\tomc Model1.mo Model2.mo will load both Model1.mo and Model2.mo, and produce \n\t flattened Model1 on standard output\n"));
print(System.gettext("\t*.mo (Modelica files) \n"));
//print("\t*.mof (Flat Modelica files) \n");
print(System.gettext("\t*.mos (Modelica Script files) \n"));
Print.clearBuf();
Print.printBuf("OpenModelica Compiler "); Print.printBuf(Settings.getVersionNr()); Print.printBuf("\n");
Print.printBuf(System.gettext("Copyright © 2012 Open Source Modelica Consortium (OSMC)\n"));
Print.printBuf(System.gettext("Distributed under OMSC-PL and GPL, see www.openmodelica.org\n\n"));
//Print.printBuf("Please check the System Guide for full information about flags.\n");
Print.printBuf(System.gettext("Usage: omc [-runtimeOptions +omcOptions] (Model.mo | Script.mos) [Libraries | .mo-files] \n* Libraries: Fully qualified names of libraries to load before processing Model or Script.\n The libraries should be separated by spaces: Lib1 Lib2 ... LibN.\n* runtimeOptions: call omc -help to see runtime options\n"));
Print.printBuf(System.gettext("* +omcOptions:\n"));
Print.printBuf(printAllConfigFlags()); Print.printBuf("\n");
Print.printBuf(System.gettext("* Examples:\n"));
Print.printBuf(System.gettext("\tomc Model.mo will produce flattened Model on standard output\n"));
Print.printBuf(System.gettext("\tomc +s Model.mo will produce simulation code for the model:\n"));
Print.printBuf(System.gettext("\t * Model.c the model C code\n"));
Print.printBuf(System.gettext("\t * Model_functions.c the model functions C code\n"));
Print.printBuf(System.gettext("\t * Model.makefile the makefile to compile the model.\n"));
Print.printBuf(System.gettext("\t * Model_init.xml the initial values\n"));
//Print.printBuf("\tomc Model.mof will produce flattened Model on standard output\n");
Print.printBuf(System.gettext("\tomc Script.mos will run the commands from Script.mos\n"));
Print.printBuf(System.gettext("\tomc Model.mo Modelica will first load the Modelica library and then produce \n\t flattened Model on standard output\n"));
Print.printBuf(System.gettext("\tomc Model1.mo Model2.mo will load both Model1.mo and Model2.mo, and produce \n\t flattened Model1 on standard output\n"));
Print.printBuf(System.gettext("\t*.mo (Modelica files) \n"));
//Print.printBuf("\t*.mof (Flat Modelica files) \n");
Print.printBuf(System.gettext("\t*.mos (Modelica Script files) Documentation is available in the built-in package OpenModelica.Scripting or online <https://build.openmodelica.org/Documentation/OpenModelica.Scripting.html>\n"));
usage := Print.getString();
Print.clearBuf();
end printUsage;

public function printAllConfigFlags
Expand Down
16 changes: 2 additions & 14 deletions Examples/ReleaseNotes.mos
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,5 @@ versions:={
// $TypeName(OpenModelica.UsersGuide.ReleaseNotes.'1.8.1'),
$TypeName(OpenModelica.UsersGuide.ReleaseNotes.'1.9.0')
};
loadFile("../../Compiler/FrontEnd/ModelicaBuiltin.mo");
loadString("function myReadFile
input OpenModelica.$Code.TypeName name;
output String contents;
protected
String strs[:],str;
algorithm
strs := OpenModelica.Scripting.typeNameStrings(name);
str := strs[4];
contents := OpenModelica.Scripting.readFile(\"ReleaseNotes/release-notes/\" + OpenModelica.Scripting.stringReplace(str,\"'\",\"\") + \".html\");
end myReadFile;");getErrorString();
deleteClass(myReadFile);
getClassNames();getErrorString();
writeFile("newf.mo",list());getErrorString();
system("grep -v DOCTYPE ReleaseNotes/release-notes/1.9.0.html | grep -v xhtml11.dtd | sed 's/<html .*>/<html>/g' > 1.9.0.html");
readFile("1.9.0.html");
3 changes: 1 addition & 2 deletions Makefile.common
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,7 @@ interactive: .testvariables mkbuilddirs

docs: mkbuilddirs omlibrary
make -C Compiler/Translation release
(cp -p doc/*.pdf doc/*.txt doc/OpenModelicaAPI-Howto/*.pdf $(builddir_doc)/omc)
rm -f build/doc/omc/CMakeLists.txt
(cp -p doc/*.pdf doc/OpenModelicaAPI-Howto/*.pdf $(builddir_doc)/omc)
(cp -p Examples/*.* $(builddir_doc)/omc/testmodels/)
rm -f $(builddir_doc)/omc/testmodels/CMake*.txt
cp -p ./SimulationRuntime/interactive/README.txt $(builddir_doc)/omc/OpenModelica-InteractiveSimulation-README.txt
Expand Down

0 comments on commit e4804f6

Please sign in to comment.