DCL mode_tile depending on other tile

DCL mode_tile depending on other tile

gustavobernardi
Advocate Advocate
2,377 Views
8 Replies
Message 1 of 9

DCL mode_tile depending on other tile

gustavobernardi
Advocate
Advocate

Can I define a mode_tile depending on other while the dialog is opened.

 

What I need is when I uncheck the option A, the B tile_mode get the value 1, and so can not edit B.

I need to close the box and open it again or can I do during execution?

 

In The image a quick example of what I need - If I uncheck the first checkbox the next field is unavailable.

 

Imagem 01.JPGimagem 02.JPG

 

TIA

0 Likes
Accepted solutions (1)
2,378 Views
8 Replies
Replies (8)
Message 2 of 9

scot-65
Advisor
Advisor
Accepted solution
Yes it is possible to turn off and back on mode_tile for a particular key
(or a group of keys) while the dialog is running.

Use action_tile for that checkbox and for the action, use mode_tile = 1
to turn off the tile.

If you wish to turn off the boxed_column, add a key to the box_column.
All items inside the boxed column will toggle.

For multiple toggles, call a subroutine and go from there. Each key will
need to be called out separately.

(action_tile "Tog01" "(MyMode1 $value)")
where
(defun MyMode1 ( $v / a )
(if (= $v "0") ;;remember, keys return as strings.
(setq a 1)
(setq a 0)
);if
(mode_tile "Box01" a)
(mode_tile "Box02" a)
);end MyMode

untested

???

Scot-65
A gift of extraordinary Common Sense does not require an Acronym Suffix to be added to my given name.

Message 3 of 9

gustavobernardi
Advocate
Advocate
Perfect, Scot 🙂
Message 4 of 9

scot-65
Advisor
Advisor
The original code was written long form for easier understanding.
I like to shorten the code where possible (follow me on this...):

(action_tile "Tog01" "(MyMode1 (- 1 (atoi $value)))")
where
(defun MyMode1 ( $v / )
(foreach x (list "Box01" "Box02")
(mode_tile x $v)
);foreach
);end MyMode1

There are times when I have a cluster of radio buttons and
each is assigned to a boxed_column. Allow only one
boxed column to be edited and the others turned off.
A matrix will be required (one method):

(action_tile "Rad01" "(MyMode1 1 0 0)")
(action_tile "Rad02" "(MyMode1 0 1 0)")
(action_tile "Rad03" "(MyMode1 0 0 1)")
where
(defun MyMode1 ( a b c / )
(mode_tile "Box01" a)
(mode_tile "Box02" b)
(mode_tile "Box03" c)
);end MyMode1

untested.

🙂

Scot-65
A gift of extraordinary Common Sense does not require an Acronym Suffix to be added to my given name.

0 Likes
Message 5 of 9

gustavobernardi
Advocate
Advocate

Works Fine, Scot. 

 

But I could not do the subrotine to verify a secondary condition... "When I turn the global option on, verify a secundary option to define a individual iten". 

 

In the image, I want:

 

When I turn on the global (A), turn on the appropriate rows/columns (B) (on this point all right), but i want a inspection in the field (C) to highlight or no the (D) field.

 

imagem 02 t.jpg

 

Below, the code i am using:

 

(action_tile "active_save" "(MyModeSave $value)")
(defun MyModeSave ( $v / a )(if (= $v "0")(setq a 1)(setq a 0))(mode_tile "MinutesCOL" a)(mode_tile "OptionCOL" a)(mode_tile "OptionCOM" a))

This code, based on your previous tip, turn off or on all the columns and rows.

 

Sorry if I was not clear, my English is not from cradle 🙂

 

thank you.

 

0 Likes
Message 6 of 9

scot-65
Advisor
Advisor
I think I understand.
You will have to do a little more digging to turn off/on the edit boxes
based on the adjacent toggle's value.

I know you can do this, so I will outline the procedure:

If "TogA1" toggle is "1"
Mode tile 0 both boxed columns to turn on.
Get tile each toggle, one at a time, and determine if checked ("1").
If checked, do nothing. The adjacent edit box is already on.
If unchecked, mode tile "1" the adjacent edit box to turn off.

If "TogA1" toggle is "0"
Mode tile 1 both boxed columns. All will turn off.

Let's see if I can create a fancy line of code for the edit boxes:
(mode_tile "EdiB1" (- 1 (atoi (get_tile "TogB1"))))
(mode_tile "EdiB2" (- 1 (atoi (get_tile "TogB2"))))
(mode_tile "EdiB3" (- 1 (atoi (get_tile "TogB3"))))

untested.
???

Scot-65
A gift of extraordinary Common Sense does not require an Acronym Suffix to be added to my given name.

0 Likes
Message 7 of 9

gustavobernardi
Advocate
Advocate

And what is wrong with my code?

 

 

(action_tile "active_save" "(MyModeSave $value)")
(defun MyModeSave ( $v / a )(if (= $v "0")(setq a 1)(setq a 0)) (mode_tile "MinutesCOL" a);;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Turn on/off column 1 - OK (mode_tile "OptionCOL" a);;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Turn on/off column 2 - OK (mode_tile "OptionCOM" a);;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Turn on/off column 3 - OK (mode_tile "time_own" (- 1 (atoi (get_tile "active_own"))));;;;;;;;;;;;;;;;;;;;;;;;; Do not work (if (=(get_tile "active_own")"0")(mode_tile "time_own" 1)(mode_tile "time_own" 0));; Do not work too )

I tried the both ways...

 

 

The individually defun codes works:

 

(action_tile "active_own" "(MyModeOwn $value)")
(defun MyModeOwn ( $v / a )(if (= $v "0")(setq a 1)(setq a 0))(mode_tile "time_own" a))

Thank you again 🙂

0 Likes
Message 8 of 9

scot-65
Advisor
Advisor

From what I can tell, it looks OK to me.

 

If by chance, you have the "defun MyModeSave" block of code between new_dialog and start_dialog?

If so, place outside and try again.

 

I may need to see the whole code for further help.

 

???

 


Scot-65
A gift of extraordinary Common Sense does not require an Acronym Suffix to be added to my given name.

0 Likes
Message 9 of 9

scot-65
Advisor
Advisor

It just occurred to me last night that you may not have initialized the tiles.

 

new_dialog creates the tiles however they have to be initialized with a value.

 

I'll give a simple example based on part of your design that will create a session only Gremlin:

 

<<new_dialog>>

 

** INITIALIZE **

(if (not USER_MyDCL)

 (setq USER_MyDCL (list "0" "22" "0" "333" "1"))

);if

 

** SET TILE **

(set_tile "TogA1" (nth 0 USER_MyDCL)) ;enable boxed columns

(set_tile "EdiB1" (nth 1 USER_MyDCL)) ;edit box 1

(set_tile "TogB1" (nth 2 USER_MyDCL)) ;toggle 1

(set_tile "EdiB2" (nth 3 USER_MyDCL)) ;edit box 2

(set_tile "TogB2" (nth 4 USER_MyDCL)) ;toggle 2

 

** MODE TILE **

here you determine the modes and in this case reverse the order from set tile.

 

** ACTION TILE **

here is where all the action tiles belong

(action_tile "accept" "(MyDCL_GET)(done_dialog 1)")

(action_tile "cancel" "(done_dialog 0)")

 

<<(setq sd (start_dialog))>>

 

where

(defun MyDCL_GET ()

 (setq USER_MyDCL (list

  (get_tile "TogA1")

  (get_tile "EdiB1")

  (get_tile "TogB1")

  (get_tile "EdiB2")

  (get_tile "TogB2")

 ))

),end MyDCL_GET

 

What happens here is that values are remembered from the dialog's state

at time of close and recreated when dialog is reopened. This Gremlin is

also a carrier of information when one enters the main part of the program.

 

Hope this helps.

 


Scot-65
A gift of extraordinary Common Sense does not require an Acronym Suffix to be added to my given name.

0 Likes