Jump to content

Recommended Posts

Posted

I cannot make it work in any case... thanks a lot to all for your comments. I tried to simplify as much as I could the explanation. Here is my last code. It has to work like this somehow because all other variables aredone already and it woulkd imply a lot of changes in my source coding. Basically I would have to re-write the whole routine. Can anybody help me? Please?

 

(defun c:Test
 ()
 (setq LST_TST
   (list
     '("TST1" "c" "1")
     '("TST2" "c" "t" "0,76,38")
   )
 )
 (defun sw
   ()
   (cond
     (
       (= SYM_TST nil)
       (setq SYM_TST 1)
     ) 
     (
       (= SYM_TST 1)
       (setq SYM_TST 2)
     ) 
     (
       (= SYM_TST 2)
       (setq SYM_TST 1)
     ) 
   )
   (print SYM_TST)
   (princ)
 )
 (sw)
 (command
   "-layer"
   "m"
   (cond
     (
       (= SYM_TST 1)
       (nth 0 
         (nth 0 LST_TST)
       )
       (nth 1 
         (nth 0 LST_TST)
       )
       (nth 2 
         (nth 0 LST_TST)
       )
       (nth 0 
         (nth 0 LST_TST)
       )
       ""
     ) 
     (
       (= SYM_TST 2)
       (
         (= SYM_TST 1)
         (nth 0 
           (nth 1 LST_TST)
         )
         (nth 1 
           (nth 1 LST_TST)
         )
         (nth 2 
           (nth 1 LST_TST)
         )
         (nth 0 
           (nth 1 LST_TST)
         )
         ""
       )
     ) 
   )
 )
)

 

Thanks again in advance

  • Replies 22
  • Created
  • Last Reply

Top Posters In This Topic

  • svorgodne

    9

  • Grrr

    3

  • BIGAL

    2

  • Tharwat

    2

Top Posters In This Topic

Posted

This code is working but I think it is a dirty way to solve the problem and not duplicating the code and making it dependant on a variable:

 

(defun c:Test
 ()
 (setq LST_TST
   (list
     '("0" "c" "1")
     '("0" "c" "t" "0,76,38")
   )
 )
 (defun sw
   ()
   (cond
     (
       (= SYM_TST nil)
       (setq SYM_TST 1)
     ) 
     (
       (= SYM_TST 1)
       (setq SYM_TST 2)
     ) 
     (
       (= SYM_TST 2)
       (setq SYM_TST 1)
     ) 
   )
   (print SYM_TST)
   (princ)
 )
 (sw)
 (cond
   (
     (= SYM_TST 1)
     (command
       "-layer"
       "m"
       (nth 0 
         (nth 0 LST_TST)
       )
       (nth 1 
         (nth 0 LST_TST)
       )
       (nth 2 
         (nth 0 LST_TST)
       )
       (nth 0 
         (nth 0 LST_TST)
       )
       "s"
       "0"
       ""
     )
   ) 
   (
     (= SYM_TST 2)
     (command
       "-layer"
       "m"
       (nth 0 
         (nth 1 LST_TST)
       )
       (nth 1 
         (nth 1 LST_TST)
       )
       (nth 2 
         (nth 1 LST_TST)
       )
       (nth 3 
         (nth 1 LST_TST)
       )
       (nth 0 
         (nth 1 LST_TST)
       )
       "s"
       "0"        
       ""
     )
   )
 )
)

 

Thanks again and really hoping someone to help to do it shorter.

Posted

Following BIGAL's strlen suggestion:

(defun c:Test ( / LST_TST)
 (setq LST_TST
   '(
     ("TST1" "1")
     ("TST2" "0,76,38")
   )
 )
 (command "_.-layer")
 (foreach sub LST_TST
   (command "_make" (car sub) "_color")
   (if (> (strlen (cadr sub)) 3) (command "_true"))
   (command (cadr sub) "")
 )
 (command "_set" "0" "")
 (princ)
)

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...