Visual LISP, AutoLISP and General Customization

Reply
Distinguished Contributor rlk
Distinguished Contributor
rlk
Posts: 165
Registered: ‎06-05-2003
Message 1 of 14 (178 Views)

strcat (run lisp).

178 Views, 13 Replies
03-30-2003 09:48 PM
I have a drop list in a dcl that gives me the variable ntnum. I am trying to run that variable as a seperate lisp. This is what I came up with but it keep returning - "(c:6163)" unknown lisp... Is there a way to execute this lisp this way...

(setq rout (strcat "(c:" ntnum ")"))
(rout)

Any help would be appreciated...
Contributor
kcalexander71
Posts: 25
Registered: ‎03-30-2003
Message 2 of 14 (178 Views)

Re: strcat (run lisp).

03-30-2003 10:02 PM in reply to: rlk
(eval (list (read (strcat "C:" ntnum))))
Distinguished Contributor rlk
Distinguished Contributor
rlk
Posts: 165
Registered: ‎06-05-2003
Message 3 of 14 (178 Views)

Re:

03-30-2003 11:08 PM in reply to: rlk
I'm sorry...I don't understand what's going on with this..
*Alexander, Ken
Message 4 of 14 (178 Views)

Re:

03-30-2003 11:22 PM in reply to: rlk
Load these two function and run C:main, you will see that (eval(list(read(strcat "C:"
func))), returns the results of C:test function.

(defun C:main (/ func)
(setq func "test")
(eval(list(read(strcat "C:" func))))
(princ)
)

(defun C:test ()
(princ "\nEvaluated this function")
(princ)
)

--
"We can't solve problems by using the same kind
of thinking we used when we created them."
--Albert Einstein

Ken Alexander
Acad 2000
Windows XP Pro
"rlk" wrote in message news:f153b84.1@WebX.maYIadrTaRb...
> I'm sorry...I don't understand what's going on with this..
Distinguished Contributor rlk
Distinguished Contributor
rlk
Posts: 165
Registered: ‎06-05-2003
Message 5 of 14 (178 Views)

Re:

03-30-2003 11:47 PM in reply to: rlk
This will work great...Thanks for the explaination.

Rich...
*Alexander, Ken
Message 6 of 14 (178 Views)

Re:

03-30-2003 11:58 PM in reply to: rlk
You're Welcome.

As a side note. I was working on a routine to do similar when I posted my question on
this NG, some advised using a condition statement in lieu of (eval........ I do not
remember the reasoning. I've used both with no problems.

--
"We can't solve problems by using the same kind
of thinking we used when we created them."
--Albert Einstein

Ken Alexander
Acad 2000
Windows XP Pro
"rlk" wrote in message news:f153b84.3@WebX.maYIadrTaRb...
> This will work great...Thanks for the explaination.
> Rich...
>
Distinguished Contributor rlk
Distinguished Contributor
rlk
Posts: 165
Registered: ‎06-05-2003
Message 7 of 14 (178 Views)

Re:

03-31-2003 12:02 AM in reply to: rlk
The section shown to me works great. However I am still getting a "too many arguements" statement. I was wondering if you could take a look.

(defun c:mecproj (/ proj_list dcl_id projnum ntnum atd to_do rout)

(setq proj '("Select Project Number..." "None" "6163" "E031" "6152"))
(setq dcl_id (load_dialog "project.dcl"))
(if
(not
(new_dialog "project" dcl_id))
(progn
(alert "Project Choice dialog could not be found!!!")
(exit)
)
)
(start_list "projnum")
(mapcar 'add_list proj)
(end_list)
(mode_tile "projnum" 2)
(action_tile "projnum" "(setq projnum $value)")
(action_tile "accept" "(done_dialog 1)")
(action_tile "cancel" "(done_dialog 0)")
(setq to_do (start_dialog))
(unload_dialog dcl_id)
(cond ((= to_do 1)
(if
(null projnum)
(setq projnum "0"))
(setq ntnum (atoi projnum))
(if
(> ntnum 0)
(setq ntnum (atoi (nth ntnum proj)))
(setq ntnum "none"))
(setq atd (getvar "attdia"))
(setq cmdd (getvar "cmdecho"))
(setvar "attdia" 0)
(setvar "cmdecho" 0)
(if
(/= ntnum "none")
(load "l:\\autocad\\programs\\mecmenu_proj2.lsp")
(eval(list(read(strcat "C:" ntnum))))
(setvar "cmdecho" cmdd)
(setvar "attdia" atd)
(princ))
)(princ "\n***Menu Loading...***\n")
))
*Alexander, Ken
Message 8 of 14 (178 Views)

Re:

03-31-2003 12:18 AM in reply to: rlk
Your if statement needs a (progn.....)

(if (/= ntnum "none")
(progn
(load "l:\\autocad\\programs\\mecmenu_proj2.lsp")
(eval (list (read (strcat "C:" ntnum))))
(setvar "cmdecho" cmdd)
(setvar "attdia" atd)
)
)

--
"We can't solve problems by using the same kind
of thinking we used when we created them."
--Albert Einstein

Ken Alexander
Acad 2000
Windows XP Pro
"rlk" wrote in message news:f153b84.5@WebX.maYIadrTaRb...
> The section shown to me works great. However I am still getting a "too many arguements"
statement. I was wondering if you could take a look.
> (defun c:mecproj (/ proj_list dcl_id projnum ntnum atd to_do rout)
>
> (setq proj '("Select Project Number..." "None" "6163" "E031" "6152"))
> (setq dcl_id (load_dialog "project.dcl"))
> (if
> (not
> (new_dialog "project" dcl_id))
> (progn
> (alert "Project Choice dialog could not be found!!!")
> (exit)
> )
> )
> (start_list "projnum")
> (mapcar 'add_list proj)
> (end_list)
> (mode_tile "projnum" 2)
> (action_tile "projnum" "(setq projnum $value)")
> (action_tile "accept" "(done_dialog 1)")
> (action_tile "cancel" "(done_dialog 0)")
> (setq to_do (start_dialog))
> (unload_dialog dcl_id)
> (cond ((= to_do 1)
> (if
> (null projnum)
> (setq projnum "0"))
> (setq ntnum (atoi projnum))
> (if
> (> ntnum 0)
> (setq ntnum (atoi (nth ntnum proj)))
> (setq ntnum "none"))
> (setq atd (getvar "attdia"))
> (setq cmdd (getvar "cmdecho"))
> (setvar "attdia" 0)
> (setvar "cmdecho" 0)
> (if
> (/= ntnum "none")
> (load "l:\\autocad\\programs\\mecmenu_proj2.lsp")
> (eval(list(read(strcat "C:" ntnum))))
> (setvar "cmdecho" cmdd)
> (setvar "attdia" atd)
> (princ))
> )(princ "\n***Menu Loading...***\n")
> ))
>
Distinguished Contributor rlk
Distinguished Contributor
rlk
Posts: 165
Registered: ‎06-05-2003
Message 9 of 14 (178 Views)

Re:

03-31-2003 01:41 AM in reply to: rlk
I keep getting a "bad stringp 6163". Is it because I have an integer and not a string of text?

(defun c:mecproj (/ proj_list dcl_id projnum ntnum atd to_do rout)

(setq proj '("Select Project Number..." "None" "6163" "E031" "6152"))
(setq dcl_id (load_dialog "project.dcl"))
(if
(not
(new_dialog "project" dcl_id))
(progn
(alert "Project Choice dialog could not be found!!!")
(exit)
)
)
(start_list "projnum")
(mapcar 'add_list proj)
(end_list)
(mode_tile "projnum" 2)
(action_tile "projnum" "(setq projnum $value)")
(action_tile "accept" "(done_dialog 1)")
(action_tile "cancel" "(done_dialog 0)")
(setq to_do (start_dialog))
(unload_dialog dcl_id)
(cond ((= to_do 1)
(if
(null projnum)
(setq projnum "0"))
(setq ntnum (atoi projnum))
(if
(> ntnum 0)
(setq ntnum (atoi (nth ntnum proj)))
(setq ntnum "none"))
(setq atd (getvar "attdia"))
(setq cmdd (getvar "cmdecho"))
(setvar "attdia" 0)
(setvar "cmdecho" 0)
(if
(/= ntnum "none")
(progn
(load "l:\\autocad\\programs\\mecmenu_proj2.lsp")
(eval(list(read(strcat "C:" ntnum))))
(setvar "cmdecho" cmdd)
(setvar "attdia" atd)
(princ)))
)(princ "\n***Menu Loading...***\n")
))

-------------------------------------------------------

(defun c:6163 (/)
(command "menuunload" "mecdolphin")
(command "menuunload" "pid")
(command "menuunload" "pid_mm")
(command "menuunload" "mec_arch")
(command "menuload" "l:\\autocad\\menus\\mec_arch.mnu")
(setq popmnu (strcat "P14=+" "mec_arch" ".pop1"))
(menucmd popmnu)
)
*Michel
Message 10 of 14 (178 Views)

Re:

03-31-2003 01:51 AM in reply to: rlk
Why this line (setq ntnum (atoi (nth ntnum proj)))

because if you pass this line, the value of NTNUM is now an integer....
when you try to STRCAT, in (eval(list(read(strcat "C:" ntnum)))) you
have
the bad stringp error !

rlk a écrit :

> I keep getting a "bad stringp 6163". Is it because I have an integer
> and not a string of text?
>
> (defun c:mecproj (/ proj_list dcl_id projnum ntnum atd to_do rout)
>
> (setq proj '("Select Project Number..." "None" "6163" "E031" "6152"))
> (setq dcl_id (load_dialog "project.dcl"))
> (if
> (not
> (new_dialog "project" dcl_id))
> (progn
> (alert "Project Choice dialog could not be found!!!")
> (exit)
> )
> )
> (start_list "projnum")
> (mapcar 'add_list proj)
> (end_list)
> (mode_tile "projnum" 2)
> (action_tile "projnum" "(setq projnum $value)")
> (action_tile "accept" "(done_dialog 1)")
> (action_tile "cancel" "(done_dialog 0)")
> (setq to_do (start_dialog))
> (unload_dialog dcl_id)
> (cond ((= to_do 1)
> (if
> (null projnum)
> (setq projnum "0"))
> (setq ntnum (atoi projnum))
> (if
> (> ntnum 0)
> (setq ntnum (atoi (nth ntnum proj)))
> (setq ntnum "none"))
> (setq atd (getvar "attdia"))
> (setq cmdd (getvar "cmdecho"))
> (setvar "attdia" 0)
> (setvar "cmdecho" 0)
> (if
> (/= ntnum "none")
> (progn
> (load "l:\\autocad\\programs\\mecmenu_proj2.lsp")
> (eval(list(read(strcat "C:" ntnum))))
> (setvar "cmdecho" cmdd)
> (setvar "attdia" atd)
> (princ)))
> )(princ "\n***Menu Loading...***\n")
> ))
>
> -------------------------------------------------------
>
> (defun c:6163 (/)
> (command "menuunload" "mecdolphin")
> (command "menuunload" "pid")
> (command "menuunload" "pid_mm")
> (command "menuunload" "mec_arch")
> (command "menuload" "l:\\autocad\\menus\\mec_arch.mnu")
> (setq popmnu (strcat "P14=+" "mec_arch" ".pop1"))
> (menucmd popmnu)
> )

You are not logged in.

Log into access your profile, ask and answer questions, share ideas and more. Haven't signed up yet? Register

Announcements
Are you familiar with the Autodesk Expert Elites? The Expert Elite program is made up of customers that help other customers by sharing knowledge and exemplifying an engaging style of collaboration. To learn more, please visit our Expert Elite website.

Need installation help?

Start with some of our most frequented solutions to get help installing your software.

Ask the Community