| T O P I C R E V I E W |
| jwang@rsma2 |
Posted - 01/13/2003 : 1:38:42 PM I'm having a lot of problems with using the run.LoadOC to load and compile my c functions. My script works fine if I open the Code Builder and manually build my functions. But if I use run.LoadOC at the beginning of the script, I get return code 0 but the functions appear not to be recognized and I get Command error! The strange thing is that if I manually run the first LoadOC (highlight that portion of script and hit return) then that function is recognized. If I then run some other LoadOC's then that first function is again unrecognized. Is there some better documentation of LoadOC? How do I load and compile an entire workspace? What are the options?
|
| 2 L A T E S T R E P L I E S (Newest First) |
| Gary Lane |
Posted - 01/13/2003 : 2:26:57 PM Hi,
Here is code from DBRoutines.OGS in Origin folder that I use to load workspace files of type *.ocw (I exclude internal.c option = 4).
if(run.LoadOC("OriginLab\StatisticsOn.OCW",4)!=0) { run.section(DBRoutines.OGS,ReportError,$StatisticsOn.StatisticsOnCnotLoaded); return 1; }
I will add a similar example to help file. If this or above information does not help please post again with specific question and I will reply.
Gary
|
| easwar |
Posted - 01/13/2003 : 2:10:03 PM Hi,
The documentation can be found in the Programming Help Files under "Origin C Programmer's Guide->Compiling and Linking->Compiling and Linking from Origin".
The following is a cut-and-paste of the information from the help file. We recommend you get the SR3 patch for version 7 and then get the update help files using the Help->Check for Updates menu item in Origin.
Easwar OriginLab.
Compiling and Linking from Origin Before you call your Origin C function from Origin, your function must be compiled and linked in the current Origin session. Origin provides the following method to programmatically compile and link a source file, or to programmatically build a workspace.
err = run.LoadOC("myFile",[option]);
The following rules apply to the err return value:
If err = 0, indicates success. Either myFile is already loaded in the current workspace or it is loaded from a .c file and compiled and linked successfully.
If err = 1, myFile was not found.
If err = 2, myFile was found and loaded into the current workspace, but the compiling or linking failed.
The following rules apply to the myFile argument:
myFile can be either a workspace file (.ocw)or a source file (.c).
If myFile is a workspace file, Origin checks each source file in the workspace file to see whether or not it is already loaded.
If myFile is a source file, Origin checks to see if it is already loaded.
In either case, if a source file is not already loaded then Origin adds it to the Temporary folder in the Code Builder workspace. When Origin is finished checking, it builds the Code Builder workspace. Files added to the Temporary folder of the Code Builder workspace are removed from the workspace when you close Code Builder or when you open a new or existing workspace file.
You must surround myFile with quotation marks ("myFile").
If no file extension is included, myFile is assumed to be a source file (.c).
If myFile has a full path, then it is used as is. If a path is not specified, Origin assumes that myFile is located in the \OriginC subfolder.
For network versions of Origin, Origin checks for myFile first in the server's \OriginC subfolder. If it is not found, then Origin checks in the client's \OriginC subfolder.
The following rules apply to the optional option argument:
option = 1, myFile should be added to the current workspace file and not added to the Temporary folder.
option = 2, force myFile to be rebuilt, even if it is already loaded in the current workspace.
option = 4, disable adding internal.c to the workspace. (By default, internal.c is added to the workspace when this method is run. The internal.c file contains many function definitions that are used by built-in Origin routines.)
option = 8, disable linking, so that you can load and compile multiple source files and link after the last one is compiled.
Note: These are bit values and can be combined using the bit wise OR operator |.
In the following example, the my_tools.c file is loaded and compiled. If this fails, an error message displays.
if (run.LoadOC("myFolder\my_tools")!=0)
type -b "Cannot load support Origin C file";
In this example, myFolder is assumed to be a subfolder in the \OriginC folder. Thus, the string is equivalent to:
"%YOriginC\myFolder\my_tools.c"
where %Y is a system string variable that holds the drive and path of the Origin program folder.
In the next example, two source files are loaded, compiled and linked. Linking is explicitly performed by omitting the file argument in the last call to the run.LoadOC method.
err=run.LoadOC(originlab\util,8);// compile but don't link
err=run.LoadOC(originlab\final,8);// compile but don't link
if (err == 0)
run.LoadOC(); // full linking if no file specified
|
|
|