Author Topic: newbie question: COND limits?  (Read 4667 times)

0 Members and 1 Guest are viewing this topic.

CHulse

  • Bull Frog
  • Posts: 454
newbie question: COND limits?
« on: November 10, 2010, 10:27:54 AM »
I'm sure this is a newbie question, but is there a max limit to how many conditions can be tested with a COND statement?

Thanks
Cary Hulse
Sr. Urban Forester
Wetland Studies and Solutions

Civil 3D 2018

Lee Mac

  • Seagull
  • Posts: 12390
  • London, England
Re: newbie question: COND limits?
« Reply #1 on: November 10, 2010, 11:12:23 AM »
I think its 256, don't quote me on that though...

mjfarrell

  • Seagull
  • Posts: 14444
  • Every Student their own Lesson
Re: newbie question: COND limits?
« Reply #2 on: November 10, 2010, 11:13:39 AM »
Be your Best


Michael Farrell
http://primeservicesglobal.com/

Lee Mac

  • Seagull
  • Posts: 12390
  • London, England
Re: newbie question: COND limits?
« Reply #3 on: November 10, 2010, 11:15:23 AM »
 :-D

CHulse

  • Bull Frog
  • Posts: 454
Re: newbie question: COND limits?
« Reply #4 on: November 10, 2010, 11:27:38 AM »
Thanks
Cary Hulse
Sr. Urban Forester
Wetland Studies and Solutions

Civil 3D 2018

CAB

  • Global Moderator
  • Seagull
  • Posts: 10388
Re: newbie question: COND limits?
« Reply #5 on: November 10, 2010, 12:29:37 PM »
Sounds like you need some refining of your algorithm if you have anywhere near that many comparisons.
Care to share your code problem? 8-)
I've reached the age where the happy hour is a nap. ()
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

jbuzbee

  • Swamp Rat
  • Posts: 843
Re: newbie question: COND limits?
« Reply #6 on: November 10, 2010, 12:39:17 PM »
He's attempting to write an algorithm to predict women . . ..






OK before any of you chicks start throwing stones my wife and I have been happily married for 26 years - that makes me an expert on the fact you can NEVER be figured out!  ^-^
James Buzbee
Windows 8

Lee Mac

  • Seagull
  • Posts: 12390
  • London, England
Re: newbie question: COND limits?
« Reply #7 on: November 10, 2010, 12:58:29 PM »
Sounds like you need some refining of your algorithm if you have anywhere near that many comparisons.
Care to share your code problem? 8-)


x2

Jeff_M

  • King Gator
  • Posts: 3977
  • C3D user & customizer
Re: newbie question: COND limits?
« Reply #8 on: November 10, 2010, 03:30:19 PM »
AFAIK, there is no limit to the number of tests in a condition. From the lisp docs:
The cond function accepts any number of lists as arguments.

Not that I'd want to use a large number of tests....there're usually better ways to attack the problem.

CHulse

  • Bull Frog
  • Posts: 454
Re: newbie question: COND limits?
« Reply #9 on: November 10, 2010, 04:49:03 PM »
Well, being a lisp noob, I work with what I know.  :wink:
At this point I don't know exactly what I will be doing. Let me explain :)
I want to insert blocks from a CSV file (thanks Lee Mac for that original code). Normally I only have a few attribs to add to the block. I was approached with a new project where I may have many attribs to apply. The code I have uses a cond to match the attrib tag to the coorect variable. I just wasn't sure if there was a limit to that process. I'm not sure yet how may attribs each block will have on this, but I expect it to be 10 or more.

this is the method I have to apply the data to the block attribs:

Code: [Select]
(foreach att (vlax-invoke obj 'GetAttributes)
                (COND ((EQ "ID" (VLA-GET-TAGSTRING att))
                        (VLA-PUT-TEXTSTRING att tnum)
                       )
                       ((EQ "BOTANICAL" (VLA-GET-TAGSTRING att))
                        (VLA-PUT-TEXTSTRING att species)
                       )
                 ) ;_ end of cond
         );_ end of foreach


 Any insight as to how I could do this better would be appreciated, just use small words to explain it and speak slowly :)
Cary Hulse
Sr. Urban Forester
Wetland Studies and Solutions

Civil 3D 2018

Lee Mac

  • Seagull
  • Posts: 12390
  • London, England
Re: newbie question: COND limits?
« Reply #10 on: November 10, 2010, 04:53:26 PM »
Perhaps use an association list:

Code: [Select]
((<tag> . <value>) (<tag> . <value>) ... (<tag> . <value>))
Then use assoc to obtain the correct value:

Code: [Select]
(if (setq val (cdr (assoc (vla-get-TagString <att>) <alist>)))
  (vla-put-TextString <att> val)
)


CHulse

  • Bull Frog
  • Posts: 454
Re: newbie question: COND limits?
« Reply #11 on: November 10, 2010, 04:57:59 PM »
Sweet, I'll try that. That seems simple enough and would clean up the code for that many atts...
Thanks!!
Cary Hulse
Sr. Urban Forester
Wetland Studies and Solutions

Civil 3D 2018

alanjt

  • Needs a day job
  • Posts: 5328
  • Standby for witty remark...
Re: newbie question: COND limits?
« Reply #12 on: November 10, 2010, 05:04:22 PM »
FYI, assoc doesn't require a dotted pair, it just searched the first item in each list.

Also, assoc is case-sensitive, so be sure capitalize the search item in the defined list and (strcase (vla-get-TagString <att>)) before trying to search with assoc.
Civil 3D 2019 ~ Windohz 7 64bit
Dropbox

CHulse

  • Bull Frog
  • Posts: 454
Re: newbie question: COND limits?
« Reply #13 on: November 10, 2010, 05:17:21 PM »
FYI, assoc doesn't require a dotted pair, it just searched the first item in each list.

Also, assoc is case-sensitive, so be sure capitalize the search item in the defined list and (strcase (vla-get-TagString <att>)) before trying to search with assoc.

Would COND not require those steps?
Cary Hulse
Sr. Urban Forester
Wetland Studies and Solutions

Civil 3D 2018

alanjt

  • Needs a day job
  • Posts: 5328
  • Standby for witty remark...
Re: newbie question: COND limits?
« Reply #14 on: November 10, 2010, 05:21:42 PM »
FYI, assoc doesn't require a dotted pair, it just searched the first item in each list.

Also, assoc is case-sensitive, so be sure capitalize the search item in the defined list and (strcase (vla-get-TagString <att>)) before trying to search with assoc.

Would COND not require those steps?
both ways still have to compare with tagstring.
Civil 3D 2019 ~ Windohz 7 64bit
Dropbox