The Origin Forum
File Exchange
Try Origin for Free
The Origin Forum
Home | Profile | Register | Active Topics | Members | Search | FAQ | Send File to Tech support
Username:
Password:
Save Password
Forgot your Password? | Admin Options

 All Forums
 Origin Forum for Programming
 LabTalk Forum
 typesetting brackets in control flow statements
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

tom3m

USA
27 Posts

Posted - 06/26/2002 :  2:06:26 PM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
I have a question/comment/observation concerning bracket positioning in control flow statements for labtalk. I have noticed on several occasions that Origin (6.1) encounters a run-time error while executing a script depending on the typesetting of brackets in the input labtalk script file. For example, compare the following two code fragments


loop(ip,1,10)
{
loop(jp,1,10)
{
Type My loopstuff goes here;
};
};


versus the following

loop(ip,1,10){
loop(jp,1,10){
Type My loopstuff goes here;};};


Note that these code fragments are too simple to produce the errors I have encountered. I hope they are sufficient to illustrate the formatting style difference.

I have found that Origin will often produce run-time errors, sometimes so catastrophic that the Origin session terminates completely, when I use the former method of typesetting the script, but not when I use the latter method of typesetting the script. Personally, I find the former method to be much easier to read and debug, especially when loops and if/else statements span many editor screen pages.

I have also noted that the crash is more likely to occur if the script is run from a user-defined button instead of from the script window.

I am pretty sure the error is not due to general program logic error (script bug), lack of semi-colons where they should be, etc. I have had this type of run-time error occur so many times under different circumstances that I now just typeset my Origin code using the latter method and everything is ok. I would still like to be able to use the former typesetting format, though.

Has anyone else noticed this?


CStorey

Canada
137 Posts

Posted - 06/26/2002 :  2:55:34 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
I normally use the first methode shown, and never get the kinds of errors you mention.

You should be aware that there is a limit as to how many lines/characters you can but between a set of brackets. I believe it is less than 1024 characters. No error will be reported if this limit is exceeded, Origin simply crashes. Usually crashes and displays two error messages. To avoid this problem break you r code up into sections and use run.section() calls for large segments inside conditionals.

Example:


[Main] // Main section
loop(ip,1,10)
{
run.section(,SecondSection);
};

[SecondSection]
loop(jp,1,10)
{
Type My loopstuff goes here;
};


Note that the run.section(, x); notation refers to section x in the same file. You can also refer to sections in other files by using run.section(FullFilePath, x);

Hope this solves your problems.


Craig Storey
Origin WebRing Member - http://g.webring.com/hub?ring=originwebring
Go to Top of Page
  Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
The Origin Forum © 2020 Originlab Corporation Go To Top Of Page
Snitz Forums 2000