
-----------------------------------
mike200015
Sun Feb 27, 2005 11:39 am

Procedure
-----------------------------------
in a program im making, i have 2 procedures that have code which are very similar, except for about 10 lines, in a few different spots, so is there a way to make a procedure for the stuff that are similar, and then i can just add in the lines that are different?

-----------------------------------
Cervantes
Sun Feb 27, 2005 11:44 am


-----------------------------------
Pass parameters into your procedure.
If the lines that are different are just different because they use different variables, you can pass the variable into the procedure.
If the lines that are different really are different, you can wrap them inside an if statement and use a boolean parameter to determine whether to go inside that if statement or not.

-----------------------------------
mike200015
Sun Feb 27, 2005 11:52 am


-----------------------------------
yea the lines are like totally different .. not just like a different colour or sumtin.. but its not like 1 big chunk in the middle thats different, i have like 5 lines in 1 spot.. and like 3 lines in another etc.

-----------------------------------
Cervantes
Sun Feb 27, 2005 12:05 pm


-----------------------------------
Then it's up to you to decide whether you should wrap those lines in if statements (using a boolean parameter) or make a whole new procedure.  Personally, I wouldn't decide on number of lines of each method, I would make my decision based on what I'm trying to do with either procedure.  If the purpose is the same or very similar, I'd go with the boolean method.
Also, look for ways that you can clump those different lines together, so as to use less if statements.

-----------------------------------
mike200015
Sun Feb 27, 2005 12:09 pm


-----------------------------------
:) kk... thnx for ur help :!:

-----------------------------------
person
Sun Feb 27, 2005 6:05 pm


-----------------------------------
im not so sure that this is gonna help u but cant u just make wats same a procedure?

-----------------------------------
jamonathin
Sun Feb 27, 2005 6:18 pm


-----------------------------------
not necessarily, because if what's different is inside a for loop for example, and he's usin' the for loops for his array's, then he cant put everything else in a proc.

-----------------------------------
ssr
Sun Feb 27, 2005 7:08 pm


-----------------------------------
I donno
may be u can make numerous procs depending on the different codes
and make a large proc which include ifs, and put down teh small procs
 8) 
may be
just may be....
