How to apply 3 or 4 if conditions at once?

Hayat shared this question 1 week ago
Answered

Example. We have two checkbox a , b & c. I want

if a is true then b true (after click on checkbox b) and a become false so line rotated clockwise.

if b true then a true (after click on checkbox a) and b become false line rotated counterclockwise

if c true then a true (after click on checkbox a) and c become false line translate.

All transformation depend on what was the checkbox before. how to write this condition.

Comments (26)

photo
1

To write your conditions, see all about booleans (displayed as checkboxes), conditions (équal, and, or, ...) and syntax here : https://wiki.geogebra.org/e...

If you want to do something when a checkbox changes, enter script in the OnUpdate tag (in the properties of the checkbox).

(for example : SetValue(a,If(b,false,true))

You can also consult the manual about the If command : https://wiki.geogebra.org/e...

photo
1

For me the description is confusing and probably incomplete..

You may want: of the three bolean is always exactly 1 bolean is ON (the one that is ON cannot be set to OFF, the one that is set to ON effected: all others are set to OFF)

photo
1

alternatively 1A:

  • of the three bolean always exactly 1 bolean is ON
  • If the one that is ON is set to Off: the next in sequence (state1, state2, state3 .... state1, state2, state3) is set to ON (inplicite: all other are OFF)
  • If one that is OFF is set to ON: all others are set to OFF

.

alternatively 2A:

Instead of 3 bolean use a slider with walue 1 to 3

(Note: instead of the value of slider (1,2,3) it is possible to set a caption text depending of slider-value with: SetCaption(%0, Element({"<text>","<text>","<text>"},%0)))

.

alternatively 3A:

use a drop-down list (properties / Basic / use drop-down list = ON)

.

alternatively 1B, 2B, 3B

For the user its only possible to go in the sequence circular (state1, state2, state3, ......state1, state2, state3)

--------------------------------------------

Note: Not implement in the description the "how". It's bether when you describe the task near the view of user.

photo
1

hello rami, Pls see attached.

In this i have ray rotation and where it was it all depend on the checkbox selected. and i want further rotation to next line it all depend on where it was before.

Let say : if "checkbox b" is true ray h rotated to from OD to OB. and then i select "checkbox c" ray rotate OB to OC .

but if checkbox a (where checkbox c selected previously and ray at OC) it rotate ray from OC to OD.

All depend on what was check box before.

photo
1

sorry, your description is not clear/complete. Questions:

  • when one boolean is ON and the user click to the same boolean again what must be happen ? (with the 4 boolean and with the Animation)
  • When one bolean is ON and the user click not to the next (Example a is ON, the user click to c) what must be happen ? (whit the 4 bolean and with the Animation)
  • maybe I have more questions

Note: before the request is not clear for me: I want not say something to a possible solution. And I want not a situation of a moving target or a trial and error solution.

photo
1

Pls see attached. Every check box a , b , c , d has ray (h') position OD , OB , OC , OA respectively. Let say

(A) checkbox 'a' has ray (h') position on OD (when i click checkbox 'a' it depend where the currently ray is.

(a) If it is on OB [because b is true] it rotate from OB to OD)

(b) If it is on OC [because c is true] it rotate from OC to OD)

(c) If it is on OA [because d is true] it rotate from OA to OD)

And this can be true for every checkbox.

(B) checkbox 'b' has ray (h') position on OB (when i click checkbox 'b' it depend where the currently ray is.

(a) If it is on OD [because a is true] it rotate from OD to OB)

(b) If it is on OC [because c is true] it rotate from OC to OB)

(c) If it is on OA [because d is true] it rotate from OA to OB)


and so on.

photo
1

It's possible you can read and answer my question above?

What I expect is more simple:

Example for question 1: the clicked ON remain ON and the animation is repeated.

Example for question 2: no special rules (set OFF all others and start animation with the corresponding (in the example: c) prameters)

photo
1
  • Ans : if one boolean ON (let say a boolean) ) and click same boolean ,It is always on and ray h' stay at the same place OD; nothing happen , because every boolean has unique place of ray what i defined in previous post (No animation repeated)
  • Ans. When a is ON and user click to c , then a become OFF and c become ON. also ray h' rotate from OD to OC.
  • Ans When a is ON and user click to d , then a become OFF and d become ON. also ray h' rotate from OD to OA.

same is true for other booleans. I want just ray rotation depend where it is previously. and position of ray depend on boolean.

a is ON has ray position OD

b is ON has ray position OB

c is ON has ray position OC

d is ON has ray position OA


the next boolean ON become previous boolean OFF and rotate ray to the position of boolean ON.

photo
2

OK (much better, but a lot words)

------------------------------------------------

my wording for the attached file:

There exist 4 boolean (a,b,c,d). Is one of this boolean is clicked then the clicked is on and all other off. Each boolean has a corresponding pair of Points (a=(A,B), b=(B,C), c=(C,D), d=(D,E)). After the click a Ray rotate from the first (correspondig) point to to the second point. The ray has center O and his (absolut) angle is modified by a slider increment-once.

photo
1

thanks rami. but one missing thing if a is ON and then c is ON so ray should rotate from OD to OC . not OB to OC

it depend on the previous position.

photo
1

Ok understand.

Question:

d -> a is forward or backwards

d -> b is forward or backwards

d -> c is forward or backwards

d -> d is forward or backwards

what is backwards for d?

.

a -> b is forward or backwards

a -> c is forward or backwards

a -> d is forward or backwards

a -> a is forward or backwards

what is backwards for a?

photo
1

rotation could be closest possible.

a -> b clockwise

b -> a counterclockwise


a -> c clockwise

c -> a counterclockwise


a -> d counterclockwise

d -> a clockwise


b -> c clockwise

c -> b counterclockwise


b -> d clockwise

d -> b counterclockwise


c -> d clockwise

d -> c counterclockwise

photo
1

OK

I need much more time (about 1 week)

photo
1

Thanks rami for the support.

photo
photo
2

I think now it's very close to what you're looking for.

I think static rules for the checkboxes are inappropriate, the rules must be dynamic.

photo
1

Thanks rami for your support.. How can i learn software very fast in great detail like you, so i can able to use nested multiple commands. Pls suggest better and fastest way to learn. I have always looked examples but it is very slow process. I have seen manual and etc..

photo
3

practice, practice, practice

find as many solutions as possible

know the existence of commands (not in detail)

photo
2

Nesting:

Too much is bad. It should remain legible.

Create the simple (not nested) commands.

Copy the corresponding object instead of the variable (note the order).

photo
1

rami it is slight different than i need. Does it possible as per my requirement.

photo
1

If you can describe the requirement in the same way as in "Line Rotation_F.ggb" so that I understand the requirement and when possible, then maybe.

photo
1

thanks for reply rami.

Does it possible to discuss with you on via headphone.

photo
1

sorry: not possible, try to describe.

photo
1

(A) Start

if 'a' is ON ray at line 'OA'

then after 'a' if 'b' selected 'a' become OFF ; and 'b' become ON then line rotated clockwise to 'OA to OB'


then after 'a' if 'c' selected 'a' become OFF ; and 'b' become ON then line rotated clockwise to 'OA to OC'


then after 'a' if 'd' selected 'a' become OFF ; and 'b' become ON then line to rotated counterclockwise 'OA to OD'


(B) Start


if 'b' is ON ray at line 'OB'

then after 'b' if 'a' selected 'b = OFF' ; and 'a = ON' then line rotated counterclockwise to 'OB to OA'


then after 'b' if 'c' selected 'b = OFF' ; and 'c = ON' then line rotated clockwise to 'OB to OC'


then after 'b' if 'd' selected 'b = OFF' ; and 'd = ON' then line to rotated clockwise 'OB to OD'

(C) Start


if 'c' is ON ray at line 'OC'

then after 'c' if 'a' selected 'c = OFF' ; and 'a = ON' then line rotated Counterclockwise to 'OC to OA'


then after 'c' if 'b' selected 'c = OFF' ; and 'b = ON' then line rotated Counterclockwise to 'OC to OB'


then after 'c' if 'd' selected 'c = OFF' ; and 'd = ON' then line to rotated clockwise 'OC to OD'

(D) Start


if 'd' is ON ray at line 'OD'

then after 'd' if 'a' selected 'd = OFF' ; and 'a = ON' then line rotated clockwise to 'OD to OA'


then after 'd' if 'b' selected 'd = OFF' ; and 'b = ON' then line rotated Counterclockwise to 'OD to OB'


then after 'd' if 'c' selected 'd = OFF' ; and 'd = ON' then line to rotated Counterclockwise 'OD to OC'

photo
1

It's possible I don't understand or your description make no sense.

Example 1: (A)

condition: then after 'a' if 'b' selected

action: then line rotated clockwise to 'OA to OB'

critic: I think you mean the angle between C and A clockwise, starting by C via B to A

.

Example 2.

It's not clear where the cursor start "clockwise to OA to OB". I think you mean clockwise from OB (resp. OC) to OA

.

Example 3.

It's not complete. click a after a

It's possible the new direction is also depending of the old direction

photo
photo
1

You can use the following version GH. With this you should be able to do pretty much anything by filling in the spreadsheet.

important rules

  • do not insert or delete rows or columns
  • only change cells in columns E, F or G (where a value already exists. e.g. "?"")
  • columns E and F are text and have the contents "A", "B", "C" or "D" (The two apostles must be typed.)
  • in column G set the checkbox by clicking: ON=clockwise, OFF= anticlockwise
  • Sometimes it is necessary to save and reopen the application to update the table.
  • If the contents of columns E or F are invalid, an error message appears and default values are used.

.

Example lines 14 and 15:

If checkBoxOld==a (AB) and checkBoxNew==b (BC) and clockwiseOLD == irrelevant then move red segment (OP) from C to A clockwise. Note: both lines have the same action in columns E,F and G. This means that clockwiseOLD is irrelevant.

.

Example lines 5 and 6

If a is pressed again after a, the red segment moves over the angle alpha in the opposite direction as before.

-----------------------------

PS: the next 3 days I will be offline.

photo
1

over and out

© 2019 International GeoGebra Institute