![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Programmer
Join Date: Feb 2005
Posts: 62
Rep Power: 4
![]() |
how to create functions across projects?
hey all, long time no see.
i had to pick up VB programming again after i noticed a flaw in my previous masterpiece, went back to edit it and found that i had deleted the source files and everything. time to dust off the books and start over... ![]() anyway, i'm trying to be a more efficient programmer this time around and use functions instead of subroutines to do repetitive work with different parameters. i am about to write a function that will parse a long filename and shrink it down to the old DOS format. i can handle that much. what i need is some advice with how to properly set up such a function so that in the future if i ever need such a function again in a different program, i can easily pull it up and access it without having to vivisect the program i'm currently working on. what would i have to do to go about this? from what i can tell modules have some part in this but i am unsure of how to set them up to do what i want to do here. do i make a new module for every specific function i may want to port? thanks |
|
|
|
|
|
#2 |
|
Programmer
|
Try to isolate it as much as possible. You don't need a new module for each function, rather, I'd recommend grouping all related functions in one module. So, in other words, put everything you're doing here in one module, and it can be called from anywhere else in the project.
|
|
|
|
|
|
#3 | |
|
Programmer
Join Date: Feb 2005
Posts: 62
Rep Power: 4
![]() |
Quote:
are there any drawbacks in actually going and making individual modules for every function i wish to possibly use elsewhere? |
|
|
|
|
|
|
#4 | |
|
SEXY SHOELESS GOD OF WAR!
![]() Join Date: Jun 2005
Location: Wet west coast of Canada
Posts: 1,193
Rep Power: 5
![]() |
Quote:
If you're linking your modules statically, then (in theory) it would be most efficient to have every function in a module of its own, so the linker would link in only those functions referenced in your code (linkers include code on a module-by-module basis). In practice, however, many functions go together. For example, if you use a function to close files, it is implicit that you will also be needing a function to open files, and so these two can go in the same module, not to mention functions to handle the file reading and writing. Thus what niteice reommended: separate the functions into groups based on related functionality, and make a module for each group.
__________________
And once again, Probability proves itself willing to sneak into a back alley and service Drama as would a copper-piece harlot. - Vaarsuvius, Order of the Stick |
|
|
|
|
|
|
#5 |
|
Programmer
Join Date: Feb 2005
Posts: 62
Rep Power: 4
![]() |
interesting. thanks.
|
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|