I understand now that I wont be able to use a Const that differs with each new function-within-a-type, because they are set at compile-time. Probably I could define a Const to a given value in the type definition but it would have to hold the same value in all the created functions. So the original idea of this thread is void.
But anyway, this is what I'm trying to do...
I have an array of function pointers - default function pointers - which is initialized at startup to hold one function pointer for each of several functions that already exist in my program. These are in a fixed order.
Then, I have another array of function pointers, this time they can be any of the function pointers taken from the default array and in any order and repeated any number of times.
In order to go through the customized array of function pointers and execute those functions, I want to use a single instruction which is something like:
myfunctionarray[index]()
This is fine for executing the functions that existed already at compile time. However, while the program runs, there will come a time when I need to branch off from the current array of function pointers and temporarily go through a second one, kind of like a `gosub`. Since there can be any number of such arrays I give each a reference number.
Now, I could insert an `immediate value` into a function pointer array which is not a function pointer (using a static bank) which could act as immediate data to be read in as the number of the array to be jumped to. But if I do that, I will need to complicate the piece of code that goes through the function pointers executing them.
So I figured that if an actual function existed that represents each new array of function pointers, I could get THAT function pointer and just refer to at any point in order to `execute` the new array.
So I was hoping that, with each new array of function pointers, I would add an instance of a type that contains a function. I would then get the function pointer for that new function and add it to the array of default function pointers. (there's a reason why I need that default array) Then I can use that function pointer in any other array to call on this new array. I know it all sounds complicated.
So what's the problem? Well, the function within the instance of the type needs to know what number I have assigned to that array. The function would then probably add that number to a list of numbers, referring to which arrays are currently active. The active arrays are the ones that are `executed`. I wanted to find a way that I could somehow customize each instance of the function in such a way that I wouldn't have to access a variable each time, otherwise with every call to a new array of function pointers there is going to be an overhead.
I have another alternative to how to do this but it would not be any faster or slower than trying to do it by adding a variable to the new type that's created, containing the array number. I am trying to find out if there are any possibilities for streamlining it further. I know this sounds like I'm niggling about a dumb little variable that means nothing but I like to explore these things. ;-)
So there you go, it sounds pretty complicated, but I just wanted to know if, when I created a new type with a function in it, I could somehow get that function to automatically activate the right program rather than having to read a variable to find out the number.
*throws hands up in the air*