Author Topic: nth list limitations?  (Read 1385 times)

0 Members and 1 Guest are viewing this topic.

sln8458

  • Newt
  • Posts: 91
  • CMS Intellicad 9.0/10.0
nth list limitations?
« 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
There is no such  thing as a 'silly question' to those who do not know!

Dlanor

  • Bull Frog
  • Posts: 263
Re: nth list limitations?
« Reply #1 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.

sln8458

  • Newt
  • Posts: 91
  • CMS Intellicad 9.0/10.0
Re: nth list limitations?
« Reply #2 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:
There is no such  thing as a 'silly question' to those who do not know!

kirby

  • Newt
  • Posts: 127
Re: nth list limitations?
« Reply #3 on: July 29, 2020, 11:10:19 AM »
Beware of null strings "" in your list. 

Lee Mac

  • Seagull
  • Posts: 12906
  • London, England
Re: nth list limitations?
« Reply #4 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

Marc'Antonio Alessi

  • Swamp Rat
  • Posts: 1451
  • Marco
Re: nth list limitations?
« Reply #5 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