View Full Version : lscript crashes modeler

05-18-2008, 01:18 PM
I'm just starting to learn lscript, and one of the scripts written in the user guide crashes modeler. If it crashes modeler on a small script of less than 30 lines how am I going to debug a script that is 500 lines long? Oh well it crashed I'll just comment out 499 lines of code 500 times until I find the offending line? How do you people put up with this? An error code, any error code, at least the offending line is a bare minimum for an IDE.

05-18-2008, 04:51 PM
It's not that common. Okay it does happen, but if there's an error in an lscript, it will usually throw up an error of some sort. When this sort of thing does happen, since I've usually written in functions I just // some of those out and try to pin it down.

05-19-2008, 02:09 AM
Copying and pasting directly from the pdf manual might copy characters that aren't allowed. For example, the pdf use different characters for starting and ending quotes. And if you copy code across several pages you will most likely get text from the header and the footer aswell, which naturally should be removed (cutting and pasting from pdf/acrobat reader always sucked).

To pinpoint errors it is common to use a debugger. With the debugger you can follow along the execution of the code line by line. You can start the debugger by simply calling debug(); anywhere in the code (Try right at the start). When you then run the script is will make that call, and a debugger window will popup. You then use F10 or F11 to step forward.

If LW doesn't even allow you to add or run the script you've got a (more severe) syntactical error. In those cases you can usually find it via the LScript Editors Check Syntax function.

I would recommend to use the LScript Editor if it weren't for the fact that it is crash prone when undoing and saving (will foobar your script completely!). As a new scripter you benefit greatly from the syntax highlighting and the Check Syntax function. So I say start with the LScript Editor, use all it's functions, but save often (especially when you need to undo several steps;alternate between two different files or save incrementally to spare yourself from the save bug). Or use the editor that someone (Dodgy?) created a syntax highlighter for and only load the file into the into LScript Editor when you need the Check Syntax function.

05-21-2008, 11:51 AM
Thank you Dodgy and evenflcw for your replies, I will try some of those suggestions soon.