PDA

View Full Version : Modeler crashing due to variable declaration



Derek Serra
11-23-2007, 11:58 PM
Hi all,

I just started learning Lscript. I have been reading the manual, and following along with the samples. After creating the codes for the fastweld tool, avgWeld, and groupWeld (which all worked fine), I decided to write my own script. I want to make a script that welds points that are chosen with the Symmetry selection on in Modeler.

Here's the code - my comments follow:
-------------
main
{
// edit only selected components
selmode(DIRECT);
// get number of selected points
pntCnt = pointcount();
// check for selection
if(pntCnt == 0)
error("No points selected.");
// check for enough points
if(pntCnt < 4)
error("Not enough points selected.");
// check for even number of points
if((pntCnt/2) != (floor(pntCnt/2)))
error("Odd number of points selected. Is the object symmetric?");
info(pntCnt);
// adjust for symmetry
loopy=pntCnt-2;
/* editbegin();
pntPos=pointinfo(points[pntCnt-1]);
nxtPos=pointinfo(points[pntCnt]);
info(pntPos);
info(nxtPos);
for (currPnt = 1; currPnt < loopy; currPnt++)
{
info(currPnt);
// move 2 points to proper points
pointmove(points[currPnt],pntPos);
pointmove(points[currPnt+1],nxtPos);
currPnt++;
}
editend();
// merge points together
mergepoints(); */
}
--------------------

Ok, the line that reads "loopy=pntCnt-2;" is my problem child, according to the error messages that I've seen. The current message tells me that it found a '-', but was expecting a '@'. After that, Modeler crashes. Also, when I try to run Tools->Check Syntax in the Lscript Editor, that crashes, too.

I've searched around the net, but haven't had any luck with finding information.

Thanks,
Derek

dpont
11-24-2007, 03:08 AM
This a know limitation of Lscript,
when you write a "-" operator add space like this:
loopy = pntCnt - 2;

Denis.

Derek Serra
11-24-2007, 07:27 AM
Thanks Denis. It's working now.

It's good to know that I wasn't coding wrong. That's a messed up bug. :P