action_tile in loop

action_tile in loop

thabit79BL3
Enthusiast Enthusiast
578 Views
6 Replies
Message 1 of 7

action_tile in loop

thabit79BL3
Enthusiast
Enthusiast

Hello, 

 

I need to define 20 CAT, of course I need to use a WHILE or REPEAT loop but can't find the right implementation. 

 

(action_tile "CAT1" "(setq CAT1 $value)")
(action_tile "CAT2" "(setq CAT2 $value)")

 

 

I tried to implement it in this way but there are errors:

 

  (setq catCounter 1)
  (repeat 20
    (setq catSet (strcat "CAT" (itoa catCounter)))
    (action_tile catSet "(setq catSet $value)")
    (setq catCounter (1+ catCounter)))

 

 

 

Thanks 😉

0 Likes
Accepted solutions (2)
579 Views
6 Replies
Replies (6)
Message 2 of 7

paullimapa
Mentor
Mentor

try this:

(setq i 0 lst '())

(repeat 20 (setq lst( append lst (list (strcat "CAT" (itoa (setq i (1+ i))))))))

(foreach item lst (action_tile item (setq item $value)))


Paul Li
IT Specialist
@The Office
Apps & Publications | Video Demos
0 Likes
Message 3 of 7

thabit79BL3
Enthusiast
Enthusiast

@paullimapa 

it's sounds totally reasonable though: 

; error: bad argument type: stringp nil 😢

 

Thanks

0 Likes
Message 4 of 7

paullimapa
Mentor
Mentor

oops..forgot the quotes:

(foreach item lst (action_tile item "(setq item $value)"))


Paul Li
IT Specialist
@The Office
Apps & Publications | Video Demos
0 Likes
Message 5 of 7

thabit79BL3
Enthusiast
Enthusiast

@paullimapa 

 

Unfortunately, that didn't work either 😞

Although it doesn't give an error, but still the user's input is not saved in CAT1...

 

BTW, I use the above code to check if my input is saved in CAT1

 


(alert (strcat "CAT1 :  " CAT1
                 "\nCAT2 :  " CAT2
       ))

 

Appreciate your time thanks

0 Likes
Message 6 of 7

Sea-Haven
Mentor
Mentor
Accepted solution

maybe something like this

 

(repeat num
    (setq keynum (strcat "key" (rtos (setq y (+ Y 1)) 2 0)))
    (setq key_lst (cons keynum key_lst))
    (set_tile keynum (nth (setq x (+ x 4)) dcllst))
  )
  (mode_tile "key1" 2)
  (action_tile "accept" "(mapcar '(lambda (x) (setq v_lst (cons (get_tile x) v_lst))) key_lst)(done_dialog)")
  (action_tile "cancel" "(done_dialog)")
0 Likes
Message 7 of 7

paullimapa
Mentor
Mentor
Accepted solution

try this variation which should save "1" to the symbol selected from the dcl by using (set) & (read) functions:

(setq i 0 lst '())

(repeat 20 (setq lst( append lst (list (strcat "CAT" (itoa (setq i (1+ i))))))))

(foreach item lst (action_tile item "(set (read $key) $value)"))

Paul Li
IT Specialist
@The Office
Apps & Publications | Video Demos
0 Likes