當複選框被選取和取消選取時的 If 函數Function1 = 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>內容組織</LINGO-LABEL><LINGO-LABEL>資料存取</LINGO-LABEL></LINGO-LABS>回覆:選取和取消選取複選框時的 If 函數該腳本看起來像是由 ChatGPT 或類似的東西創建的,並且確實沒有什麼問題。下面是應該有效的範例
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()
);
)
)回覆:選取和取消選取複選框時的 If 函數只需嘗試即可輕鬆測試
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();
)
)
我會在沒有複選框和新視窗的情況下開始測試類似的東西,因為它們只會增加額外的複雜性。在開始將函數新增至複選框等之前,您必須先能夠解決函數如何協同工作的問題。
回覆:選取和取消選取複選框時的 If 函數你是完全正確的。
我可以巢狀一個函數嗎? (在函數中編寫函數)
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
)
);我需要在[按鈕框(“OK”,]命令中新增匹配功能