T O P I C R E V I E W |
EigenGoofy |
Posted - 06/16/2011 : 5:43:24 PM Origin Ver. and Service Release (Select Help-->About Origin): 8.5
For example. on the codebuilder window, I open an ogs file named "mycube.ogs", which has the following code:
@global = 1;
function double dCubeRoot(double dVal) { double xVal; if(dVal<0) xVal = -exp(ln(-dVal)/3); else xVal = exp(ln(dVal)/3); return xVal; }
Then click "Enable Breakpoints", and toggle a breakpoint on the line "if(dVal<0) xVal = -exp(ln(-dVal)/3);", then on the Code Builder's LabTalk Console I type "mycube", and then type "dcuberoot(-8)".
The result: Nothing happened! It did not pause the program at the breakpoint, nor did the console return "-2" as final calculation result. It was just nothing returned.
Question:
How can I pause the problem in debug mode at the breakpoint?
The info provided by the following address can not really help me: http://www.originlab.com/www/helponline/Origin/en/Programming/Programming.htm#Programming_1.htm
Thank you! |
4 L A T E S T R E P L I E S (Newest First) |
EigenGoofy |
Posted - 06/20/2011 : 10:04:27 PM quote: Originally posted by cpyang
LabTalk function is new and when more people are using it, we will put in the effort to hook up break point support. Currenly, you can use break point with ogs file section scripts.
Before that, you have to use the good old technique of dumping values in your function. And you can also use the type command to dump more info. You can also use the #! technique to keep the debugging code and wake them up only via @B=1, see
http://wiki.originlab.com/~originla/wiki/index.php?title=Script:Debugging_Tools#.23.21script_.28special_syntax.29
so your function could be written as
function double dCubeRoot(double dVal)
{
double xVal;
if(dVal<0) xVal = -exp(ln(-dVal)/3);
else xVal = exp(ln(dVal)/3);
#! type "DB Dump: dCubeRoot($(dVal)) = $(xVal,*12)";
return xVal;
}
Having the #! marking will make it easy for you to remove them once you know the function is working well.
CP
Yes, I have tried your technique, at the same time I was imagining that without resorting breakpoints how an experienced programmer might be smart enough to use such technique with efficiency, and even treat it as a shortcut. Maybe yes, they can do it. However, as a greenhorn, Breakpoints support is wanted!
Thank you, cpyang! |
cpyang |
Posted - 06/17/2011 : 8:30:09 PM LabTalk function is new and when more people are using it, we will put in the effort to hook up break point support. Currenly, you can use break point with ogs file section scripts.
Before that, you have to use the good old technique of dumping values in your function. And you can also use the type command to dump more info. You can also use the #! technique to keep the debugging code and wake them up only via @B=1, see
http://wiki.originlab.com/~originla/wiki/index.php?title=Script:Debugging_Tools#.23.21script_.28special_syntax.29
so your function could be written as
function double dCubeRoot(double dVal)
{
double xVal;
if(dVal<0) xVal = -exp(ln(-dVal)/3);
else xVal = exp(ln(dVal)/3);
#! type "DB Dump: dCubeRoot($(dVal)) = $(xVal,*12)";
return xVal;
}
Having the #! marking will make it easy for you to remove them once you know the function is working well.
CP
|
EigenGoofy |
Posted - 06/17/2011 : 4:42:34 PM quote: Originally posted by cpyang
There is no break point support for LabTalk function yet.
You can add code like
xVal =;//dump value to script window
return xVal;
CP
Thank you, cpyang! According to what you said, I have done as following:
@global = 1;
function double dCubeRoot(double dVal) { double xVal; if(dVal<0) xVal = -exp(ln(-dVal)/3); else xVal = exp(ln(dVal)/3); xVal =; return xVal; }
It returns "dcuberoot(-8) xVal=-2"
It is so disappointed that we are unable to debug Labtalk code by using breakpoints!
So question:
How can I debug Labtalk code? What is the alternative to do so please? |
cpyang |
Posted - 06/16/2011 : 7:48:53 PM There is no break point support for LabTalk function yet.
You can add code like
xVal =;//dump value to script window
return xVal;
CP
|
|
|