| Author |
Topic  |
|
|
srmcarneir
Brazil
33 Posts |
Posted - 07/08/2004 : 08:20:31 AM
|
Hi All,
We have a LabTalk script which contains a block as follows: ...
for (aa = 1; aa <= iNum; aa++ ) { ierrGeg = fdlog.get(A, aa);
if ( ierrGet == 1 ) run.section(,ChooseCondition, aa); }
[ChooseCondition]
switch (%1) { case 1: ...some calculations... break;
default: ...other calculations... break; }
return 0;
We have noticed that the for loop stopped after having run for aa = 1, even when iNum > 1. It seems that the "break" command makes an exit out of the switch command, by exiting the for loop also. We have not found a way to let the for loop continue running until aa <= iNum (when iNum >1) yet. We also have tried the command continue, unsuccessfully.
Best Regards,
Ricardo Carneiro |
|
|
Mike Buess
USA
3037 Posts |
Posted - 07/08/2004 : 10:23:01 AM
|
Hi Ricardo,
This might just be a typo in your post but it's best to eliminate the obvious first...
You define ierrGeg=fdlog.get(A,aa) but use if(ierrGet==1) as the condition. If that's really in your script then ierrGet is always undefined and your script will fail.
Mike Buess Origin WebRing Member |
 |
|
|
srmcarneir
Brazil
33 Posts |
Posted - 07/08/2004 : 1:08:25 PM
|
Hi Mike, All,
Thanks for your prompt response!
I apologize for that , it is really a misspelling. Please consider ierrGet in all cases instead of ierrGeg. I wish this mistake was made in the original script of mine, that would make things much easier.
By the way, we are planning to redesign our script from scratch because this has already taken too long to debug. We are also considering the "translation" of some LabTalk blocks to OriginC.
[Just forgot to inform: we are using OriginPro 7 with SR4 under Win2k. Sorry for that!]
We appreciate your help!
Regards,
Ricardo Carneiro |
 |
|
|
Mike Buess
USA
3037 Posts |
Posted - 07/08/2004 : 2:19:46 PM
|
Hi Ricardo,
I tried this simplied version of your script...
for(aa=1; aa<iNum; aa++) { run.section(,ChooseCondition,aa); };
[ChooseCondition] switch(%1) { case 1: ty 0; break; default: ty $(%1); break; };
It works fine unless iNum is undefined. I'd look closely at the calculations in the switch statement and make sure they don't change the value of either iNum or aa. An advantage or disadvantage (depending on your viewpoint) of LabTalk over Origin C is that LabTalk variables are global. Changing the value of aa in the switch command will effect the for loop which calls it. In fact, it's not necessary to pass aa as an argument - run.section(,ChooseCondition,aa). This will work just as well...
for (aa=1; aa<=iNum; aa++) { run.section(,ChooseCondition); }
[ChooseCondition] switch(aa) { }
Mike Buess Origin WebRing Member |
 |
|
| |
Topic  |
|
|
|