Lets say I have a file named test.m
containing some functions.
test[arg1_, arg2_] := (
Print[arg1];
Print[arg2];
)
test3[arg1_, arg2_] := (
Print[arg1];
Print[arg2];
)
What would be a good way to generate a list of butons that would allow you to invoke the functions easily? For example.
The tricky part here (and is mainly why I am asking this question) is calling the functions, which will have several different argument types? I had thought about using an InputField
with a MessageDialog
, but I would bet there is better way to incorporate Mathematica's features.
ClearAll[loadFile];
loadFile[path_String?FileExistsQ] := DeleteCases[ToExpression[
FromCharacterCode[BinaryReadList[path]]
, InputForm, HoldComplete], Null];
x = ReleaseHold[
loadFile["test.m"] /.
HoldPattern[sym_[args__] := eval_] :>
Button[sym, eval]
];
x[[0]] = List;
x