Hi,
I am at the stage where I need to modularise my mainstack. There are bunch of common routines that I need to be able to call from any substack/object. To date I have just put them in the main stack and they become accessible. However my main stack is becoming very large (over 10k lines) and I want to take related routines out into their own code modules, yet still have them available to all substacks and objects.
Not sure how I do this in Livecode.....
Greg
Putting common functions in code modules
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller
Re: Putting common functions in code modules
How you structure your stack/s is a matter for you, but 10k lines is not something to make LiveCode shudder.
For clarity and ease of maintenance, and portability of libraries, it is simple to put all your library handlers into a substack. Then you can issue the statement:
start using stack "myLibrary"
Then all the handlers of the substack will be available. Thus it is simple to store your libraries in stacks of their own, and attach them to a new project.
But there may be other ways that suit you (or other coders - who may have more ideas) better.
For clarity and ease of maintenance, and portability of libraries, it is simple to put all your library handlers into a substack. Then you can issue the statement:
start using stack "myLibrary"
Then all the handlers of the substack will be available. Thus it is simple to store your libraries in stacks of their own, and attach them to a new project.
But there may be other ways that suit you (or other coders - who may have more ideas) better.
Re: Putting common functions in code modules
Hi.
The question to ask is why it is better to put your library code in another stack. Is it for easier access to them, or are you concerned that the list of handlers, or their length, has made the stack script difficult to work with?
I never use two stacks when one will do. Even if the list of handlers in the stack script grows quite large, it would do so also in the library stack, and then what would that accomplish?
Craig Newman
The question to ask is why it is better to put your library code in another stack. Is it for easier access to them, or are you concerned that the list of handlers, or their length, has made the stack script difficult to work with?
I never use two stacks when one will do. Even if the list of handlers in the stack script grows quite large, it would do so also in the library stack, and then what would that accomplish?
Craig Newman
Re: Putting common functions in code modules
I think Greg is concerned with code maintenance and clarity. With one stack script, in the debugger it can be daunting to find a handler and see the other handlers which are relevant to it. If all the database code is in one substack script, and all the ui code is in another substack for instance, it can help with your own thought processes. Wouldn't it be a good idea to be able to put section markers in the script and be able to see the different sections (of the same script) in a separate tab?
Re: Putting common functions in code modules
Sparkout.
Craig
That sounds as cool as the ability to add annotations to lines of code like a toolTip. I have wanted that forever. To be able to write a paragraph, if you wanted to, and read it by hovering over a single line of interest.Wouldn't it be a good idea to be able to put section markers in the script and be able to see the different sections (of the same script) in a separate tab?
Craig