Calling a variable name symbol inside a loop
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi everyone.
I am creating a loop wich sets eleven points in each step (Step 1 from P1 to P11 Step 2: from P12 to P22 an so on) with this routine:
(setq count1 (+ count (+ 0 (* 10 (- count 1)))))
(setq count2 (+ count (+ 1 (* 10 (- count 1)))))
(setq count3 (+ count (+ 2 (* 10 (- count 1)))))
(setq count4 (+ count (+ 3 (* 10 (- count 1)))))
(setq count5 (+ count (+ 4 (* 10 (- count 1)))))
(setq count6 (+ count (+ 5 (* 10 (- count 1)))))
(setq count7 (+ count (+ 6 (* 10 (- count 1)))))
(setq count8 (+ count (+ 7 (* 10 (- count 1)))))
(setq count9 (+ count (+ 8 (* 10 (- count 1)))))
(setq count10 (+ count (+ 9 (* 10 (- count 1)))))
(setq count11 (+ count (+ 10 (* 10 (- count 1)))))
(set (read (strcat "p" (itoa count1))) (cadr (assoc inflinenumber pp)))
(set (read (strcat "p" (itoa count2))) (caddr (assoc inflinenumber pp)))
(set (read (strcat "p" (itoa count3))) (cadr (assoc suplinenumber pp)))
(set (read (strcat "p" (itoa count4))) (caddr (assoc suplinenumber pp)))
After this, program works perfectly if I call this points from his name like this:
(setq p1sup2 (list (car p1) (cadr p1)))
(setq p2sup2 (list (+ (car p2)5) (cadr p2)))
(setq p3sup2 (list (car p3) (cadr p3)))
(setq p4sup2 (list (+ (car p4)5) (cadr p4)))
(setq diam (- (cadr p3) (cadr p1)))
(setq p5sup2 (list (+ (car p1sup2) (* diam 50)) (cadr p1)))
(setq p6sup2 (list (+ (car p3sup2) (* diam 50)) (cadr p3)))
(command "_pline" p1sup2 "_a" "_d" 180 p3sup2 "_l" p4sup2 p2sup2 p1sup2 "_a" "_d" 180 p3sup2 "_l" p6sup2 p5sup2 p1sup2 "")
But what I want to achieve is the loop to call in each step its correspondent point. I have tried this way:
(setq p1sup2 (list (car (strcat "p" (itoa count1))) (cadr (strcat "p" (itoa count1)))))
(setq p2sup2 (list (+ (strcat "p" (itoa count2))5) (cadr (strcat "p" (itoa count2)))))
.... and so on.
But when making this it appears the message:
; error: bad argument type: consp "p1"
It would be really helpful if you can give a hint of how to solve it.
Thank you very much!