I was trying to save my path coordinates as a list. But when i was trying to print the list of points, got errors "unbound variable-plist" . the code is mentioned below.
I can't test your code right now, but one thing that springs to mind is that plist is a function, and possibly a special variable... As I read your code I don't see anything that would cause plist to be undefined - it is declared in the let statement, so it should always have a value in that scope, at the very least it would be nil.
Try using a different name for the variable...
Hope this helps,
In reply to skillUser:
In reply to Neeraj Vardhan:
I'm guessing that your code cannot be what you've posted, because that works fine. There's nothing wrong with it (well, apart from you using the obsolete getCurrentWindow() rather than hiGetCurrentWindow() - but that shouldn't cause any problems).
Have you really loaded that version of the code? Or maybe your real code is more complicated than what you've posted?
In reply to Andrew Beckett:
I was trying to upload the code from morning, but failed to upload... below is the code i am working on
let((xy1 xy2 x1 x2 y1 y2)
for(i 1 n
if(x2-x1>0 && y2-y1 == 0 then print("RIGHT"))
if(x2-x1<0 && y2-y1 == 0 then print("LEFT"))
if(y2-y1>0 && x2-x1 == 0 then print("TOP"))
if(y2-y1>0 && x2-x1 == 0 then print("BOTTOM"))
) ; for
) ; let
) ; procedure_nvMyDirection
Not clear what your problem is now - please elaborate. You have four separate functions there, which are variously referring to global variable. For example, nvGetLocation is referring to a variable n which would need to be defined. nvMyDirection is referring to global variable p_list (which is not the same as the variable p_list in nvGetMyLocation, since that is local to the prog() call within that function).
So what are you calling, and what is happening that is not what you expect?
Yes, but what functions are you running?
If you're calling nvGetMyLocation() (assuming you have a variable n defined), then p_list will be set within that function, but will be discarded (and hence no longer defined) after the prog() has finished. So if you're then trying to look at p_list in the CIW, it will be undefined - hardly surprising since it is a local variable. Similarly if you call nvMyDirection() it will be looking for a global variable p_list, which won't be defined. If it was, then it could compute local variables xy1, xy2, x1, x2 (which are defined in the let()), but these will be thrown away when the let() exits and hence when nvMyDirection exits. If you then call nvMyPath, it won't know what xy1 and xy2 are - plus the fact that the code is wrong in this function because the list of points is improperly specified.
So PLEASE explain what you're doing. Nobody can debug by reading your mind!
OK, but you still haven't said which functions you are calling, and in what order. In other words, the sequence of events that led to the error you saw.
As Andrew said, nvMyDirection is not going to execute because p_list is a local variable in nvGetMyLocation. That is what the declaration in the prog statement does. The value is only available within the dynamic scope of the function (the function and all it the functions it calls). The variable does not exist at the interpreter level of when inside nvMyDirection. I would probably return the value from nvGetMyLocation and use that as the input to nvMyDirection.
Look at your print values. Each one is the point and the a list containing only that point. There is nothing accumulating the data. It is better to use println or printf( "%L\n" ...) for your print statement so it will print on each line.
Also, n (in the n++ statement) is a global variable.
In reply to theopaone:
I tried one of your bindkeys, and I get (not surprisingly):
*Error* eval: unbound variable - n
If I then type "n=0" in the CIW, the bindkey then works - it just prints the coordinates of the cursor in the CIW.
So it's still not producing the error you say. I see no reason why it should - but I would expect that you'd get that error if you called nvMyDirection(), but you didn't say that you were calling that.
It sounds as if you're lacking some basic understanding on variable scoping. I'd suggest that you read the SKILL Language User Guide which is an introduction to the SKILL Language.
Hi Andrew and Ted, thanks a lot for the help. Andrew, i went through the manual yesterday. I got why i was facing problem.
If you've got the shape in a variable, it would be shape~>width .
For example, if you have the path selected (and only one thing selected), it would be car(geGetSelSet())~>width