T O P I C R E V I E W |
Shemini |
Posted - 12/27/2011 : 5:34:30 PM Origin Ver. 8.0 and Service Release SR6 (Select Help-->About Origin): Operating System: Windows 7
Is there a bug in the function calling in Origin C? I have a function called ChoseTemplate() that was working fine until today, now when I call it it has a command error saying 'Unknown function: CHOSETEMPLATE()' I tried various things to fix it and have searched for what this error means but the one thing that made this function work again was to change the name to something different like ChTemplate(). If there is a way to get a more permanent fix that does not require me to change the name of the function I would appreciate any help in finding that fix.
I have tried having the prototype for the function in and out of the header file. I am thinking the name of the function is being stored somewhere that makes it overlook the actual function since it works to rename the function.
Please let me know if there is a known solution to this problem.
Thanks, Shem |
5 L A T E S T R E P L I E S (Newest First) |
Penn |
Posted - 12/30/2011 : 04:41:48 AM Hi Shem,
The problem you mentioned is a bug in Origin 8, and it is fixed since Origin 8.1 SR1. You can download a free demo of the current latest version, Origin 8.6, from this page to have a try.
If you want the function, which is defined (including prototype and body, or just the prototype declaration) in the header file, to be executed in Command Window, please include the header file in a c or cpp file for compiling.
Penn |
Shemini |
Posted - 12/29/2011 : 7:24:12 PM Hi Penn,
I think I have found my error because the problem is no longer occurring (at least for the time being). I noticed that any function that has a prototype in the .h file cannot be called in the command window but has to be called by a different function that has the .h file with the said prototype included in its source file. I was trying to call functions directly which had a prototype saved in a .h file, this was causing the error. This may mean that having the second instance of the source file in code builder was not actually causing this problem at all.
Now if I put a prototype for a function in a header file I have to have some other function to call that function or it will not be seen. If I want to have a function that I can call from the command window I cannot create a prototype for it in a header file or else it will give the command error and say 'Unknown function: functionName()'. I can handle this now that I know what the issue was, but I may need more help with it if there are more issues down the road.
Thank you, Shem |
Penn |
Posted - 12/28/2011 : 10:58:38 PM Hi Shem,
When using run.LoadOC(), the file will be seen in the Temporary folder of Code Builder. I don't know why you have a same file of different path in the User folder. Maybe you created such file by yourself?
If there are two functions with the same name, error message will tell there is already a function body when compiling. For example, I test like this:
1. Create a file named test.c under D:\, and the code is:
#include <Origin.h>
void ChoseTemplate()
{
out_str("Test ChoseTemplate");
}
2. In the push button, I will run the script like:
run.LoadOC(d:\test.c, 16);
choseTemplate();
It runs correctly.
3. Open Code Builder, I can see the test.c file in the Temporary folder (To see the full path, right click on the Temporary folder, and select Show Full Path). And create a new file, named test.c, which will be in the User folder. Add the same code to this file as step 1.
4. Compile the files, then it gives the error:
Error, Function already has a body
I think this error message makes sense. If your steps are not like this, could you please provide detail steps? Please also include the Origin C code and LabTalk script you have used.
Penn |
Shemini |
Posted - 12/28/2011 : 6:26:06 PM Hi Penn,
Thank you for the quick response, I think I have found the issue that I was having, although I am not sure why the mistake was made. It appears that the file containing the ChoseTemplate() function was being placed in the Temporary folder and compiled each time the chose template button was pushed by the command run.loadOC. I was editing some other functions in the same c file in code builder and it somehow got saved to a different path. Therefore I had one copy of the file in the Temporary folder and another copy in the User folder in code builder and they each had a different path to them but the same functions inside so when one function was called instead of telling me there were multiple instances of that function it just said that the function was unknown.
I was able to get the ChoseTemplate() function to work by simply taking the instance of the file out of the user folder and leaving the other one in the Temporary folder. The strange thing about the new file was that I had not saved it with a different path intentionally and the path that the new file had (OriginLab\Origin8\Project Temp\) was not visible in windows explorer (at least the Project Temp folder was not visible), I only saw that path in the code builder when I moused over that particular file.
Thanks again for the quick response and I hope that this will help someone avoid the same headache somehow. Maybe if the error message would say that there are multiple instances of that function rather than treating it as if it didn't see the function at all that could at least help debug the problem.
It still may be useful to try to reproduce this error since I didn't solve the problem but merely found out what the problem was. The only thing I was doing when the problem occurred was editing a different function in the same c source file. once I finished editing the new function I compiled it (it compiled fine) and tried to use the new function, but it gave the error. I tried clicking the button to run ChoseTemplate() and it gave the error for that as well (I had used this chose template button before editing the new function so the file was already in the Temporary folder). This may not be much to go on but I would like to know the reason for this happening. Should I just stay away from having extra functions in the same file with functions I use buttons to call?
Thanks, Shem
|
Penn |
Posted - 12/27/2011 : 8:48:22 PM Hi Shem,
I am sorry that I cannot reproduce your problem currently. When seeing the error you mentioned, it always happens in the following two cases:
1. No function named "ChoseTemplate" is defined yet. Obviously, your case is not this one.
2. The file, in which the function "ChoseTemplate" is defined, is not compiled yet. So, please make sure the file is compiled before using the function. If the file is compiled, and the problem is still there, please provide the detail steps on how to reproduce it.
Penn |
|
|