warning: local variable used as function error

warning: local variable used as function error

stanovb
Advocate Advocate
2,210 Views
34 Replies
Message 1 of 35

warning: local variable used as function error

stanovb
Advocate
Advocate

I have some variables listed here.

stanovb_0-1661125611604.png

I then define the dialog box that works with this program:

stanovb_1-1661125748023.png

I then setup the various dialog box tiles:

stanovb_2-1661125851534.png

I then define the action tiles:

stanovb_3-1661125988459.png

I then have some if statement conditions where I remove some tabs & rename some other tabs based on what's selected in the dialog box. I had the dialog box working before but now i'm getting these errors.

; warning: local variable used as function: WALKUP
; warning: local variable used as function: RECTANGULAR
; warning: local variable used as function: PULLFORWARD
; warning: local variable used as function: WALKUP
; warning: local variable used as function: PULLFORWARD
; warning: local variable used as function: WALKUP
; warning: local variable used as function: DOORSCHED
; warning: local variable used as function: RECTANGULAR
; warning: local variable used as function: PULLFORWARD
; warning: local variable used as function: WALKUP
; warning: local variable used as function: DOORSCHED

 

I'm wondering if for some reason its not getting to the dialog definition. Some of the guys that helped me out before taught me how to set an alert to show where the program is getting to, maybe I can try that. This program works with my other thread that has a long message chain.

https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/are-there-ang-good-tutorials-on-usin...

 

This is what defines the (= ln16 "SAO") variable. That works now, but I'm trying to get my updatecover routine working. This program looks at various elements & deletes & renames tabs based on selections that the user makes in "SAO select.DCL". I have an older routine that worked with some other project types & loads a different dialog box so the logic was working before.

 

I am trying to figure out what is making it say I'm using  a local variable as a function. I was trying to add onto an existing program but I must have something in there that's causing the error. i will post the updatecover file as well as the older version & also the dcl file. The 184kb file is the newer one. it should have the added variables listed at the top of this post. I hope this does not create a problem for anyone that looks at this.

0 Likes
2,211 Views
34 Replies
Replies (34)
Message 21 of 35

stanovb
Advocate
Advocate

I think I got it. I don't want to claim total victory yet, but this one worked

 

stanovb_0-1661632513507.png

I got all of the alerts & it removed & renamed the correct tabs

0 Likes
Message 22 of 35

stanovb
Advocate
Advocate

This is encouraging. Not claiming total victory, but the first 3 options are working as expected. I had an extra cond statement in there. I'll let you know when everything is good, but it is progressing.

0 Likes
Message 23 of 35

stanovb
Advocate
Advocate

Still trying to figure out the and not combination. This gives me T at the command prompt:

(setq square 1 pullforward 1 walkup 1 doorsched nil)

(if square
(if(not doorsched)(and pullforward walkup)
)
)

 

but this doesn't execute, it goes to the next block which is the (or pullforward walkup) code. 

stanovb_0-1661719361320.png

I thought maybe i had to put the (and pullforward walkup) before the (or pullforward walkup), but it still falls through to the 2nd block of code. The first block doesn't execute.

0 Likes
Message 24 of 35

paullimapa
Mentor
Mentor

that's because you're once again combining the (not....) & (and...) functions incorrectly

what happened to this which I showed you:

(and(not doorsched)(or pullforward walkup))

 

That is not the same as what you have now:

(not doorsched)(and pullforward walkup)

 

try and figure out the correct way of structuring this code and test it the way I told you to at the command line before.


Paul Li
IT Specialist
@The Office
Apps & Publications | Video Demos
0 Likes
Message 25 of 35

stanovb
Advocate
Advocate

@paullimapa wrote:

that's because you're once again combining the (not....) & (and...) functions incorrectly

what happened to this which I showed you:

(and(not doorsched)(or pullforward walkup))

 

That is not the same as what you have now:

(not doorsched)(and pullforward walkup)

 

try and figure out the correct way of structuring this code and test it the way I told you to at the command line before.


yes i have been testing it at the command line first. The code that you are referencing above is for when you have (not doorsched)& either pullforward or walkup selected. What i'm trying to do now is to have (not doorsched) & both pullforward and walkup selected. I think the problem I'm having now is I'm trying to include square along with wrapping everything in either a cond statement, an if statement or a nested if statement so that I can include my prog statement which contains all of the tabs that are being deleted or removed. If i copy 

(cond (and (not doorsched)(and square pullforward walkup ))
;;; (PROGN
;;; (command "layout" "d" "DM-100.00 (2)")
;;; (command "layout" "d" "A-100.00")
;;; (command "layout" "d" "A-100.00 (2)")
;;; (command "layout" "d" "A-100.00 (3)")
;;; (command "layout" "d" "A-100.00 (4)")
;;; (command "layout" "d" "A-100.00 (5)")
;;; (command "layout" "d" "A-100.00 (6)")
;;; (command "layout" "d" "A-100.00 (8)")
;;; (command "layout" "d" "A-100.00 (9)")
;;; (command "layout" "d" "A-100.00 (10)")
;;; (command "layout" "d" "Brand Review (2)")
;;; (command "layout" "R" "A-100.00 (7)" "A-100.00")
;;; );end progn
)

to the command line i get T as a result, but when i run my program with the prog statement not commented out it falls down to the next block of code. I did have an alert in the 2nd block of code so it is running that.

 

The interesting thing is the one that has

stanovb_0-1661734957075.png

 

works in the routine but not at the command line

0 Likes
Message 26 of 35

paullimapa
Mentor
Mentor

I don't know why you keep switching back to (cond...) function.

When you use (cond...) it's a different structure than (if...) 

Go back to the documentation and see how the two are structured differently.

But for what you are doing now, just stay with (if...).

You do not have more than one condition to test.

This is wrong:

(not doorsched)(and pullforward walkup)

 

But this is right...try and figure out why:

(and (not doorsched)(and pullforward walkup))


Paul Li
IT Specialist
@The Office
Apps & Publications | Video Demos
0 Likes
Message 27 of 35

stanovb
Advocate
Advocate

The reason is because when i copy the if statement to the command line I was getting an error so i was trying something else to see if it would work. i'll look at what you were suggesting, but I have to somehow surround this in something so I can include my prog statement that contains the deletion of certain tabs and the renaming of others. For the other options I did it with nested if statements & it worked, but when i copied to the command line I got an error so I thought it might be the wrong way to do it.

0 Likes
Message 28 of 35

stanovb
Advocate
Advocate

I think I figured it out. It is a cond statement that I need. The reason is I have two predicates that I am trying to evaluate, not just one. I'm trying in one case to test if pullforward or walkup is true, & the other test is if pullforward & walkup are both true. I was trying to these individually with a nested if statement & the flow was falling through to the second block of code which was the or option, but once I put this together under the one cond statement both scenarios worked.

 

stanovb_0-1661741373732.png

 

0 Likes
Message 29 of 35

paullimapa
Mentor
Mentor
Good for you also when using (cond....) you don’t need (progn) statement. This is optional.

Paul Li
IT Specialist
@The Office
Apps & Publications | Video Demos
0 Likes
Message 30 of 35

stanovb
Advocate
Advocate

Thanks, I've been at this awhile. Basically all weekend except for when I went to the football game yesterday. Do I understand progn correctly in that if you want to evaluate multiple things you use progn? Also I might want to add a no echo statement because I get the current text style displayed on the command line

you're saying I don't need progn? I  can just do

(command....)

(command...)?

0 Likes
Message 31 of 35

paullimapa
Mentor
Mentor

Like I said before you only need progn when you use if. For cond remove progn and it’ll still work

 

To remove echo (setvar”cmdecho”0) and (setvar”menuecho”0)

also it’s a good idea to save the current settings to variables at the beginning so you can restore them back at the end. 


Paul Li
IT Specialist
@The Office
Apps & Publications | Video Demos
0 Likes
Message 32 of 35

stanovb
Advocate
Advocate

yeah thanks. it would be less code so that's good. I don't want to claim victory until I try out all of the scenarios, but I believe I have the logic down now.  Sorry for all of the messages, you've been very helpful. I think there is just too many options to do this with an if statement.

0 Likes
Message 33 of 35

Kent1Cooper
Consultant
Consultant

@paullimapa wrote:

....But this is right...try and figure out why:

(and (not doorsched)(and pullforward walkup))


That has a nesting of (and) functions that can be further simplified, if you want:

(and (not doorsched) pullforward walkup)

Kent Cooper, AIA
Message 34 of 35

Sea-Haven
Mentor
Mentor

My $0.05 lee-mac has a nice DCl that is populate a list then pick multiple items and add to a new list, so you could get a full list of layout tabnames and choose which ones to delete like wise rename rather than hard coded. Use Ctrl and Shift to select multiple layouts.

 

SeaHaven_0-1661828798910.png

 

 

 

(setq laylst (layoutlist))

(setq laylst2 (LM:listbox "please choose layouts to delete"  laylst 1))
(princ laylst2)

 

 

 

 

0 Likes
Message 35 of 35

stanovb
Advocate
Advocate

That's nice for  future, programs but I want this hard coded. The routine will delete & rename tabs based on the user's selections.

0 Likes