Updating Listbox / Files / Case-Switch Based on User Input
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
Hey guys, thanks in advance for any responses. I've been working on a series of GUIs that allow the user to control a stepper motor as a function of another motor's RPM and have had quite a bit of success. The current functionality I'm trying to add to the software is the ability for the user to define their own function of control, which would create a file with a name they've chosen, add a string to the listbox with the description they've chosen, and add the functionality to the code. I've run into an error in this bit because I can't seem to think of the best way to do it, I've thought about storing all the data in cells and referencing them, or writing them to a file, or trying to use structs, but I could really use some input. I'll attach some code for a better description below.
User hits "add new function" button which calls the first in a series of 4 GUIs that define fileName, functionName, functionActual, and creates the file corresponding to their function (in a sub folder) using getappdata/setappdata to transfer data between GUIs.
The main GUI has to see which function they've selected after a toggle button is pushed and call that specific file for an feval() code, which I've been doing like this ('Normal0F' is the file name):
switch get(handles.functionChoice,'Value')
case 1
functionCall = 'Normal0F';
case 2
functionCall = 'Lateral0F';
case 3
functionCall = 'Normal5A';
end
So this code needs to update with another case that corresponds to the next value. I thought about using functionList = what(<subfolder dir>); functionList.m to make some sort of array containing the file names, but the function call names (listbox) have to correspond to the right file names which the OS may send back in ABC order, or date modified, depending on how the folder is set up.
THANKS A MILLION! Looking forward to your input.
Respuesta aceptada
Más respuestas (0)
Ver también
Categorías
Más información sobre File Operations en Help Center y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!