Not sure exactly what you are trying to do (a piece of sample code would help), but I would just use "cons" to put the new string in a list:
Code:(setq strlst (cons *newstring* strlst))

Registered forum members do not see this ad.
I have a list, and I am trying to loop trough the list, change each string in the list and add the new string to a new list. I cant get the result to the bottom or the top of the list. It seems like whatever I try it creates a 2 item list, the first item is the last edited string, and the last item is a string of every other previously altered string. How do I get it to put a new line on the string? I have tried append, multiple variations of cons and everything else I can find. I know this is really simple but for some reason, I seem to get hung up on the easy things.
Not sure exactly what you are trying to do (a piece of sample code would help), but I would just use "cons" to put the new string in a list:
Code:(setq strlst (cons *newstring* strlst))
Lee Mac Programming
With Mathematics there is the possibility of perfect rigour, so why settle for less?
Just another Swamper

Thanks for the help Lee.
I had been trying this and all sorts of variations with CONS but it still isnt creating my list in the desired format.
Here is a sample
This somewhat works, but my list comes out looking like this.(setq user (dos_username))
(cond ((= user "BLockhart")
(setq userp "Ben"))
((= user "CBearden")
(setq userp "Chris"))
((= user "LBrown")
(setq userp "Lavon"))
((= user "RChambers")
(setq userp "Ronnie"))
((= user "JMitchell")
(setq userp "Justin"))
((= user "JPrice")
(setq userp "Joe"))
((= user "LCooper")
(setq userp "Lonny"))
(setq userp (getstring "\n Please enter your first name: "))
);cond end
(setq maindir (dos_getdir "Select directory you wish to print:" (strcat "W:\\"userp"\\New Projects")))
(setq sublist (dos_subdir maindir))
(setq subnum (length sublist))
(setq cnt 0)
(setq dwglist "")
(while (< cnt subnum)
(setq fldr (nth cnt sublist))
(setq dwglist (cons (strcat maindir fldr) dwglist))
(setq cnt (+ cnt 1))
)
)
Like I said, I know there is something amazingly simple I am missing, but it's driving me battyLOG ("W:\\Ben\\New Projects\\Solvay\\test\\109487" "W:\\Ben\\New Projects\\Solvay\\test\\109478" "W:\\Ben\\New Projects\\Solvay\\test\\109476" "W:\\Ben\\New Projects\\Solvay\\test\\109455" "W:\\Ben\\New Projects\\Solvay\\test\\109452" "W:\\Ben\\New Project...
[car] "W:\\Ben\\New Projects\\Solvay\\test\\109487"
[cdr] ("W:\\Ben\\New Projects\\Solvay\\test\\109478" "W:\\Ben\\New Projects\\Solvay\\test\\109476" "W:\\Ben\\New Projects\\Solvay\\test\\109455" "W:\\Ben\\New Projects\\Solvay\\test\\109452" "W:\\Ben\\New Projects\\Solvay\\test\\109438" "W:\\Ben\\New Project...![]()
I can't really test it because it uses those "dos" functions... but give this a shot:
Code:(setq user (dos_username)) (cond ((= user "BLockhart") (setq userp "Ben")) ((= user "CBearden") (setq userp "Chris")) ((= user "LBrown") (setq userp "Lavon")) ((= user "RChambers") (setq userp "Ronnie")) ((= user "JMitchell") (setq userp "Justin")) ((= user "JPrice") (setq userp "Joe")) ((= user "LCooper") (setq userp "Lonny")) (setq userp (getstring "\n Please enter your first name: ")) );cond end (setq maindir (dos_getdir "Select directory you wish to print:" (strcat "W:\\"userp"\\New Projects"))) (setq sublist (dos_subdir maindir) subnum (length sublist) cnt 0) (while (< cnt subnum) (setq fldr (nth cnt sublist)) (setq dwglist (cons (strcat maindir fldr) dwglist) cnt (+ cnt 1)) ) )
Lee Mac Programming
With Mathematics there is the possibility of perfect rigour, so why settle for less?
Just another Swamper
Another variation, untested.
Code:(setq user (dos_username)) (setq userp (cadr (assoc user '(("BLockhart" "Ben") ("CBearden" "Chris") ("LBrown" "Lavon") ("RChambers" "Ronnie") ("JMitchell" "Justin") ("JPrice" "Joe") ("LCooper" "Lonny") ) ) ) ) (if (null userp) (setq userp (getstring "\n Please enter your first name: ")) ) (if (and (/= userp "") (setq maindir (dos_getdir "Select directory you wish to print:" (strcat "W:\\" userp "\\New Projects"))) (setq sublist (dos_subdir maindir)) (setq subnum (length sublist)) (setq cnt -1) ) (while (< (setq cnt (+ cnt 1)) subnum) (setq fldr (nth cnt sublist)) (setq dwglist (cons (strcat maindir fldr) dwglist)) ) )
Last edited by CAB; 13th Mar 2009 at 05:01 am. Reason: Changed cdr to cadr
Ahh nice one CAB, good use of associative lists - I should have looked at this one a bit more.
Lee Mac Programming
With Mathematics there is the possibility of perfect rigour, so why settle for less?
Just another Swamper

Registered forum members do not see this ad.
Thanks for the help guys,
This is what I finally got to work.
Everything else made my list look funny. and I was dreading having to pull info from it.(while (< cnt subnum)
(setq fldr (nth cnt sublist))
(setq dwglist (append dwglist (list (strcat maindir fldr))))
(setq cnt (+ cnt 1))
)
In case you're curious, I am working on a Batchplot lisp that searches a directory for files that match a certain criteria, writes a script with the info and plots all of them.
So basically, all the user has to do to plot off a job, is select a directory with all the part folders in it and it goes through the folders and pulls out the relevant files, (ignoring files used for xrefs and reference drawings) and plots them based on Border size. Let you know how it comes along....
Bookmarks