Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

strcat (run lisp).

13 REPLIES 13
Reply
Message 1 of 14
rlk
741 Views, 13 Replies

strcat (run lisp).

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...
13 REPLIES 13
Message 2 of 14
kcalexander71
in reply to: rlk

(eval (list (read (strcat "C:" ntnum))))
Message 3 of 14
rlk
in reply to: rlk

I'm sorry...I don't understand what's going on with this..
Message 4 of 14
Anonymous
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..
Message 5 of 14
rlk
in reply to: rlk

This will work great...Thanks for the explaination.

Rich...
Message 6 of 14
Anonymous
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...
>
Message 7 of 14
rlk
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")
))
Message 8 of 14
Anonymous
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")
> ))
>
Message 9 of 14
rlk
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)
)
Message 10 of 14
Anonymous
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)
> )
Message 11 of 14
rlk
in reply to: rlk

I do like to use alot of my old lisp routines and modify to what I need. I didn't take it out because I got confused when trying to input integers but then converting to a string at the end...When removing this line the program returns "nil" but does not execute the following routine. Is there an explaination?
Message 12 of 14
Anonymous
in reply to: rlk

Well...just be careful with atoi and strcat....the following lines
should work

.....
(if (null projnum)
(setq projnum "0")
)
(setq ntnum (atoi projnum))
(if (> ntnum 0)
(setq ntnum (nth ntnum proj))
(setq ntnum "none")
)
.....

rlk a écrit :

> I do like to use alot of my old lisp routines and modify to what I
> need. I didn't take it out because I got confused when trying to input
> integers but then converting to a string at the end...When removing
> this line the program returns "nil" but does not execute the following
> routine. Is there an explaination?
Message 13 of 14
Anonymous
in reply to: rlk

You need part of that line of code. (setq ntnum (nth (atoi projnum) proj))
will return the string required. I think you are going setq overboard, that's
causing your confusion. Compare this cond statement with yours, I believe
it will give you the result you're after. (not tested). Some error checking would be
good too.


(cond ((= to_do 1)
(if (and projnum (> (atoi projnum) 1))
(progn
(setq ntnum (nth (atoi projnum) proj))
(setq atd (getvar "attdia"))
(setq cmdd (getvar "cmdecho"))
(setvar "attdia" 0)
(setvar "cmdecho" 0)
(load "l:\\autocad\\programs\\mecmenu_proj2.lsp")
(eval (list (read (strcat "C:" ntnum))))
(setvar "cmdecho" cmdd)
(setvar "attdia" atd)
(princ "\n***Menu Loading...***\n")
)
(princ "\nNothing Selected")
)
)
)

--
"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.9@WebX.maYIadrTaRb...
> I do like to use alot of my old lisp routines and modify to what I need. I didn't take
it out because I got confused when trying to input integers but then converting to a
string at the end...When removing this line the program returns "nil" but does not execute
the following routine. Is there an explaination?
Message 14 of 14
rlk
in reply to: rlk

Works Amazingly...Thanks for all of your help...

Ken you were right...I think I was getting confused with un-needed setq statements...

Michel you were right...I do need to watch more carefully when using an old lisp...

Thanks again..

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost