Wenn Funktion, wenn das Kontrollkästchen aktiviert und deaktiviert istFunction1 = Function( {},
// Code for function 1 goes here
Print("Checkbox is checked! Function 1 executed.");
);
// Define function 2
Function2 = Function( {},
// Code for function 2 goes here
Print("Checkbox is unchecked! Function 2 executed.");
);<BR /><BR />
// Create a new window
nw = New Window( "Checkbox Example",
<< Modal,
// Add a checkbox to the window
cb = Checkbox( "Toggle Function", Value( 0 ) )
);
// Add an OK button to the window
nw << Append( Button Box( "OK",
// Function to execute when OK button is clicked
<<SET function=""></SET>Hi, The code above is similar to what I am trying to do. I have a check box, and if I select it, and then click ok, function 1 should be displayed; and if i do not select it and click ok, function 2 should be displayed. <BR /><BR />
<LINGO-LABS id="lingo-labs-738594" slang="en-US" mode="CREATE"><LINGO-LABEL>Inhaltsorganisation</LINGO-LABEL><LINGO-LABEL>Datenzugriff</LINGO-LABEL></LINGO-LABS>Betreff: Wenn Funktion, wenn checkBox aktiviert und deaktiviert istDieses Skript sieht aus, als wäre es von ChatGPT oder einem ähnlichen Anbieter erstellt worden und weist einige Probleme auf. Unten finden Sie ein Beispiel, das funktionieren sollte
Names Default To Here(1);
func1 = function({}, {Default Local},
Show(1)
);
func2 = function({}, {Default Local},
Show(2)
);
nw = New Window("",
window:cb = Check Box({""}),
Button Box("OK",
If(window:cb << get,
func1()
,
func2()
);
)
)Betreff: If-Funktion, wenn Kontrollkästchen aktiviert und deaktiviert istGanz einfach durch Ausprobieren testen
Names Default To Here(1);
a = function({}, {Default Local},
Show("a");
);
b = function({}, {Default Local},
Show("b");
);
func1 = function({input_value = 1}, {Default Local},
Match(input_value,
1, a(),
2, b()
);
);
func2 = function({}, {Default Local},
Show(2)
);
func3 = function({}, {Default Local},
If(window:cb << get,
func1()
,
func2()
);
);
nw = New Window("",
window:cb = Check Box({""}),
Button Box("OK",
func3();
)
)
Ich würde mit dem Testen von so etwas ohne Kontrollkästchen und neues Fenster beginnen, da diese nur eine zusätzliche Komplexitätsebene hinzufügen. Sie müssen zuerst herausfinden, wie Funktionen zusammenarbeiten, bevor Sie sie zu Kontrollkästchen usw. hinzufügen.
Betreff: If-Funktion, wenn Kontrollkästchen aktiviert und deaktiviert istSie haben absolut recht.
Kann ich eine Funktion verschachteln? (eine Funktion innerhalb einer Funktion schreiben)
CheckBoxHandler = Function ({cb},
If ( cb << Get,
//Call function with apple/banana if checkbox is checked
checkedbox ()
,
//Else
//Call function with mango/watermelon if checkbox is not checked
uncheckedbox ()
),
);//Function 1 - box is checked
checkedbox = Function ({},
Match ( x,
"a", callapple,
"b", callbanana
)
);
//Function 2 - box is not checked
uncheckedbox = Function ({},
Match (x,
"a", callmango,
"b", callwatermelon
)
);Ich muss eine Match-Funktion im Befehl [ Button Box ("OK", ] hinzufügen