Page 1 of 1

Dynamic functions

Posted: Fri Jun 17, 2005 3:15 pm
by statik
(set 'a "myprogram -abc -use=something example.txt")
(set 'b (parse a))

b => ("myprogram" "-abc" "-use=something" "example.txt")

Now I need a way to execute this as a newlisp function. Something along the lines of:

(eval ((nth 0 b) (nth 1 b) (nth 2 b) (nth 3 b)))

I need newlips to try to turn all that into (myprogram -abc -use=something example.txt), or in other words, I need it to take my string and turn it into a newlisp function.

Any ideas?

Posted: Fri Jun 17, 2005 3:32 pm
by statik
Ok, I got it running the function using:

(eval-string (append "(" (nth 0 parsed) " " (nth 1 parsed) ")"))

However, the (nth 1 parsed) needs to be a string.

I cant add quotes though using append: eg, (append """ (nth 1 parsed) "'")

Any help is appreciated.

Posted: Fri Jun 17, 2005 5:02 pm
by statik
grundle got me some working code :) kudos.