I could use some creative minds on this one please. I have hit a brick wall.....maybe too close to it and need to take a break? ???
I need to be able to call a subroutine that is dynamic in nature.
I have over 100 pre-defined subroutines. This number will probably increase over time. I need to take user input from keyboard and use the input to run a subroutine with the name they have entered. Input may possibly come from a random word generator vs. keyboard input.
Examples:
If the entry is "abc" I want the action to be subroutine abc()
If the entry is "hello world" I want the action to be subroutine hello world()
If the entry is "bad boy" I want the action to be subroutine bad boy()
Error trapping will exist if entry is a non-existent function.
If that was the whole spec, that would not be a problem.
But here is the twist: For reasons that are not important, but part of the design spec, the entry person cannot be provided with a list of valid entries. So this eliminates a popup list or UserSelect method.
It is no problem to take the entry value and convert it into a declared variable, but that variable cannot be called as a subroutine. I am pretty sure this is the same issue that I asked about on 2/22. So, I probably need to find a work-around. Here are the details:
I could make a hundred+ IF statements like:
If entry = "hello world" then hello world() else
If entry = "bad boy" then bad boy() else
If entry = "abc" then abc() else
........
........
ErrorTrapping()
End if
OR I could use @Select with a similar listing.
But besides the time for the programming effort, these solutions are hardcoded. When new subroutines are created, then this code would also need to be modified. I am looking to create/maintain subroutines separate from the database so changes can be done without having to modify the program code.
One off the wall thought I have now is to possibly take the entry value, use @shell to open another copy of Seseme and pass the entry as a value to autoexecute some type of macro calling the subroutine somehow. Don't even want to think of the complexity that will involve, so I won't spend any time on that option yet.
I am sure your suggestions will be interesting. I just hope that Mark/Erika don't come back and say "You can't do that at all!" If they do, then maybe Tom can use this as a "Monthly Puzzler" in Inside Sesame?
I think what I need is a new function like:
@SubRoutine(x) where "x" is a variable containing the name of a subroutine.
@Function(x) would provide the same dynamic tools for functions also.
Too late to get into 1.0.2?