Autolisp array

Status
Not open for further replies.

VL

Usenet Archive
Joined
Jan 10, 2002
Messages
33
Reaction score
0
Could someone tell me how to create an array to store data after read the file.

VL
 
By storing the information in Lists, usually with some form of unique identifier for each group of information. For example, if I wish to read a line of coordinates with a point number then I would join them together with:
(setq ptlist (cons ptnumber (list x y z))) - this creates a grouping of the individual point. I would then add this to the array of points with (setq ptsarray (cons ptlist ptsarray))

We can now find individual points within the array by using the assoc command. (assoc 52 ptsarray) would find point number 52 in the array (not the 52nd item in the array), returning the ptlist information (eg (52 (x y z))) If you don't have a unique identifier then you just step through the array by using the foreach command, or find the nth item with (nth ptsarray)

Jon Rasmussen
 
To read a file & put it in a list:
(setq fn (open "yourfile.ext" "r"))
(while (setq line (read-line fn)) (setq lst (cons line lst))) (close fn)
(reverse lst)

"VL" wrote:

Could someone tell me how to create an array to store data after read the file.

VL
 
Status
Not open for further replies.

Latest threads

Back
Top