Jump to content

Use read-line to extract comma separated values


ynotrobits

Recommended Posts

Try this simple routine and pay your attention to the command line at the end of the program , you should see a list of the values .

 

(defun c:Test (/ o f str p lst)
 (if (and (setq o (getfiled "" (getvar 'dwgprefix) "csv" 16))
          (setq f (open o "r"))
     )
   (progn
     (while (setq str (read-line f))
       (if (setq p (vl-string-search "," str 0))
         (setq lst (cons (substr str 1 p) lst))
       )
     )
     (close f)
   )
 )
 (if lst
   (setq lst (reverse lst))
 )
)

Link to comment
Share on other sites

  • Replies 24
  • Created
  • Last Reply

Top Posters In This Topic

  • Tharwat

    11

  • jmerch

    10

  • ynotrobits

    2

  • Lee Mac

    1

Top Posters In This Topic

("Number" "1" "2" "3" "4" "5" "6")

 

Good , is not that what you've looking for since your first question in this thread ?

 

so...for each 'lst', I need to perform my commands....am I thinking right?

 

Correct , but it also depends on what you are trying to do with the list ?

Link to comment
Share on other sites

Yes that is what I was looking for, my initial thought was to populate this list in order to separate it out. Then the more I got into it, I liked the idea of skipping that step and just having the LISP execute my commands 'foreach' number in the list, keeping that 'setq' definition saved so I can use it in my filter.

Link to comment
Share on other sites

Then the more I got into it, I liked the idea of skipping that step and just having the LISP execute my commands 'foreach' number in the list, keeping that 'setq' definition saved so I can use it in my filter.

 

Just ask if you stuck with any of your process with LISP and not with your third party commands . ;)

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...