Code: Select all
Procedure Test1(val1,val2,val3...)
...Code1A - Never the same code...
...Code1B - ThisPart is ever the same...
EndProcedure
Procedure Test2(val1,val2,val3...)
...Code2A - Never the same code...
...Code2B - ThisPart is ever the same...
EndProcedure
Procedure Test3(val1,val2,val3...)
...Code3A - Never the same code...
...Code3B - ThisPart is ever the same...
EndProcedure

So i thought about a subroutine to store only the CodeB part and call this subroutine with GOSUB inside a procedure, like:
Code: Select all
Procedure Test1(val1,val2,val3...)
...Code1A - Never the same code...
Gosub SubRoutine
EndProcedure
Procedure Test2(val1,val2,val3...)
...Code2A - Never the same code...
Gosub SubRoutine
EndProcedure
Procedure Test3(val1,val2,val3...)
...Code3A - Never the same code...
Gosub SubRoutine
EndProcedure
SubRoutine:
...CodeB
Return

So i thought and stored the subroutine code into a new procedure, which works! But this way is very bad for my code, because when calling the main procedure and this is calling a such called sub-procedure, my program runs about factor 100 slower ;( (here an example of the way, that slow down my program)
Code: Select all
Procedure SubRoutine(val1,val2,val3...)
...CodeB
EndProcedure
;---------------------------------------------------
Procedure Test1(val1,val2,val3...)
...Code1A - Never the same code...
SubRoutine(val1,val2,val3...)
EndProcedure
Procedure Test1(val1,val2,val3...)
...Code1A - Never the same code...
SubRoutine(val1,val2,val3...)
EndProcedure
Code: Select all
good reasons would be:
-------------------------------------------------------------
* no performance loose
* small exe filesize
bad reasons would be:
-------------------------------------------------------------
* if you will change or modify anything of the CodeB part, you have not
to change this only onces! You have to change this all there, where you use the same code... (still silly, even if you only want to change one value and have 50 procedures for example)
* filesize of the exe will be bloody big (instead having the routine only once in the whole program)