TheSwamp

Code Red => AutoLISP (Vanilla / Visual) => Topic started by: sln8458 on July 29, 2020, 03:51:23 AM

Title: nth list limitations?
Post by: sln8458 on July 29, 2020, 03:51:23 AM
Hi All,

I'm working on a project which refers back to a txt file for file names and dimensions. see example below.
However the values for nth9 & 10 are reading in as nth8.

This suggests that an nth list can only have 9 values.
Is this the case or am I missing something?
If this is the case, is there a 'simple' work around?

(nth0   nth1     nth2        nth3    nth4   nth5 nth6 nth7  nth8    nth9   nth10)
("1/2" "1/2" "ldct1.sld"  89.00  60.30  15.80  4  11.20  21.30  48.00  00.60) actual values.

S
Title: Re: nth list limitations?
Post by: Dlanor on July 29, 2020, 04:41:38 AM
Works correctly for me on the command line in 2012. Difficult to remedy without seeing the code you using.
Title: Re: nth list limitations?
Post by: sln8458 on July 29, 2020, 09:58:07 AM
Works correctly for me on the command line in 2012. Difficult to remedy without seeing the code you using.

Thanks for that, it's my code then, I'll keep chasing  :opps:
Title: Re: nth list limitations?
Post by: kirby on July 29, 2020, 11:10:19 AM
Beware of null strings "" in your list. 
Title: Re: nth list limitations?
Post by: Lee Mac on July 30, 2020, 12:20:45 PM
Others have found empirically that the maximum length of an AutoLISP list in AutoCAD is around 20,000,000 items - I imagine that this limit arises from a limit on the memory available to be allocated to list items and is therefore also dependent on the data type of the items contained within the list.

A list can certainly contain more than 9 items:
Code - Auto/Visual Lisp: [Select]
  1. _$ (setq l '(0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15))
  2. (0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15)
  3. _$ (nth 10 l)
  4. 10
  5. _$ (nth 11 l)
  6. 11
  7. _$ (nth 12 l)
  8. 12
Title: Re: nth list limitations?
Post by: Marc'Antonio Alessi on July 30, 2020, 12:39:33 PM
works here:
Code: [Select]

Command: (progn
(_> (setq alist  '("1/2" "1/2" "ldct1.sld"  89.00  60.30  15.80  4  11.20  21.30  48.00  00.60)  Countr 0)
(_> (repeat (length alist)  (print (nth Countr  alist))  (setq Countr (1+ Countr)))
(_> (princ)
(_> )
"1/2"
"1/2"
"ldct1.sld"
89.0
60.3
15.8
4
11.2
21.3
48.0
0.6