ssget logical operator help

ssget logical operator help

zph
Collaborator Collaborator
888 Views
5 Replies
Message 1 of 6

ssget logical operator help

zph
Collaborator
Collaborator

Good day all,

 

The following snip on code is throwing the "error: syntax error".

 

(foreach sL sList
	(progn
	(setq tVal (cdr (assoc 1 (entget sL))))

		(if (/= (vl-string-search " -" tVal) nil)
			(progn
			(setq sVal (substr tVal 1 (- (strlen tVal) 2)))

				(if 	(not (setq sFlag (ssget "X" (list
						'(0 . "TEXT,MTEXT")
						(cons 1 sVal)
						'(8 . "TEXT")
						'(4 . "<OR")
						'(4 . "=") '(67 . 0)
						'(4 . "=") (cons 410 (getvar "ctab"))
						'(4 . "OR>")
					))))
				
				(setq dList (cons (list sL) dList))
				) ;if
			) ;progn
		) ;if
	) ;progn
) ;foreach

 

At first, I thought that the problem may be with the (mis)use of the logical operator -4.  So, I reworked the code:

 

(foreach sL sList
	(progn
	(setq tVal (cdr (assoc 1 (entget sL))))

		(if (/= (vl-string-search " -" tVal) nil)
			(progn
			(setq sVal (substr tVal 1 (- (strlen tVal) 2)))

				(if 	(and 	(not (setq sFlag (ssget "X" (list
						'(0 . "TEXT,MTEXT")
						(cons 1 sVal)
						'(8 . "TEXT")
						'(67 . 0)
						))))

						(not (setq sFlag (ssget "X" (list
						'(0 . "TEXT,MTEXT")
						(cons 1 sVal)
						'(8 . "TEXT")
						(cons 410 (getvar "ctab")) 
						))))
					) ;and
				
				(setq dList (cons (list sL) dList))
				) ;if
			) ;progn
		) ;if
	) ;progn
) ;foreach

 

...but, this still returned the same error.

 

Do you guys see the problem?

 

Thanks!

~Z

0 Likes
889 Views
5 Replies
Replies (5)
Message 2 of 6

Anonymous
Not applicable

Must be something with another part of your code. sList needs to be a list of ENAMEs that are only text or mtext otherwise it would error out. you cant cdr nil.

Message 3 of 6

zph
Collaborator
Collaborator

Yes, you are correct.  "sList" is a list of text object enames.

0 Likes
Message 4 of 6

Anonymous
Not applicable

Running your code with a presumed list, I was able to run it without error...

0 Likes
Message 5 of 6

zph
Collaborator
Collaborator

I don't understand how this is possible for you.

 

As (4 . "<OR") .....needs to be (-4. "<OR").

 

(foreach sL sList
	(progn
	(setq tVal (cdr (assoc 1 (entget sL))))

		(if (/= (vl-string-search " -" tVal) nil)
			(progn
			(setq sVal (substr tVal 1 (- (strlen tVal) 2)))

				(if 	(not (setq sFlag (ssget "X" (list
						'(0 . "TEXT,MTEXT")
						(cons 1 sVal)
						'(8 . "TEXT")
						'(-4 . "<OR")
						'(-4 . "=") '(67 . 0)
						'(-4 . "=") (cons 410 (getvar "ctab"))
						'(-4 . "OR>")
					))))
				
				(setq dList (append dList (list sL)))
				) ;if
			) ;progn
		) ;if
	) ;progn
) ;foreach

 

Even with this fix, though, the issue isn't with running the routine, but rather loading it is when I encounter the error and it still occurs with the "-4".

 

EDIT:  I took a last look at the code and I found the error.  Prior to the posted segment, I intentionally force the code to initialize 'dList' as an empty list , but forgot to include the empty parenthesis after the variable ().  *facepalm*

 

Cheers.

0 Likes
Message 6 of 6

Anonymous
Not applicable

check out lee mac's description of -4. it's at the bottom of his page.

0 Likes