Here's the problem in the code:
(foreach n l_pt
(write-line
(strcat "sommet" str_sep
(itoa (setq (nbs (+1 nbs )))) str_sep
(rtos (car n) 2 2) str_sep
(rtos (cadr n) 2 2) str_sep
(strcat "2") str_sep
(strcat "borne")
)
f_open
)
)
;;(write-line "" f_open)
I have these kind of files in output:
Sommets;;
Type;Num;X;Y;Precison;Nature
sommet;1;1532292.16;3214140.11;2;borne
sommet;2;1532287.08;3214140.60;2;borne
sommet;1;1532291.45;3214136.43;2;borne
sommet;2;1532286.50;3214135.87;2;borne
sommet;1;1532287.08;3214140.60;2;borne
As you've guessed, the problematic part is the "Num" which is not working as intended, incrementing.
I've understood that it's this line: " (itoa (setq (nbs (+1 nbs )))) str_se" not working as intended, but I don't know why. I've tried to switch it to (setq (nbs (+ 1 nbs))), but it doesn't works either.
Do you have any ideas from where it's coming?
(+ 1 nbs)do exactly the same thing as(+1 nbs)?(operator arg1 arg2 ...). In the case ofsetq, the assignment operator, the argument is order is(setq <place> <new value>). That means that(setq (nbs (+1 nbs)))is wrong, and should be(setq nbs (+ 1 nbs)).(), it's easy to miss this kind of thing. You might want to post that as an answer. (As an aside, it's possible that+1is a defined incrementer function and that(+1 nbs)returns the same value as(+ 1 nbs). However the latter form is clearly correct.)(defun test (/ counter) (foreach n '(a b c) (write-line (itoa (setq counter (+ 1 counter))))))