GOSUB instead PROCEDURE barrier ?

Everything else that doesn't fall into one of the other PB categories.
User avatar
Rescator
Addict
Addict
Posts: 1769
Joined: Sat Feb 19, 2005 5:05 pm
Location: Norway

More examples!

Post by Rescator »

This time If/elseif instead of select, and a more complete example.

Code: Select all

Procedure Test(val1,val2,val3,val4,val5,val6,val7,val8)

 If val1=0 And val2=0 And val3=0 And val8=0 ;if val 4,5,6,7
  Debug "code1 stuff here"
   color=200
 ElseIf val2=0 And val5=0 And val6=0 And val8=0 ;if val 1,3,4,7
   Debug "code2 stuff here"
   color=100
 ElseIf val1=0 And val3=0 And val5=0 And val7=0 ;if val 2,4,6,8
   Debug "code3 stuff here"
   color=255
 Else ;if none of the conditions above was met
  Debug "oops"
 EndIf

 ;B code stuff here
 Debug "Weeee, zoom zoom"
 Debug color

EndProcedure

; Let's test it :)

Test(2,0,5,1,0,0,9,0)
Here is a alternative way. That might help you keep your sanity compared to the one above :P

Code: Select all

Procedure Test2(method,val1,val2,val3,val4,val5,val6,val7,val8)

 If method=1
  Debug "code1 stuff here"
   color=200
 ElseIf method=2
   Debug "code2 stuff here"
   color=100
 ElseIf method=3
   Debug "code3 stuff here"
   color=255
 Else ;if none of the conditions above was met
  Debug "oops"
 EndIf

 ;B code stuff here
 Debug "Weeee, zoom zoom"
 Debug color

EndProcedure

Test2(3,0,0,0,0,0,0,0,0) ;I just used 0, to lazy to come up with nice numbers :P

;In this 2nd example, just keep the argument names as they are, val1 etc.
;however their contents/value will obviously be different,
;and each if block will treat i.e val1 differently.
;as long as you use the correct method when you call the procedure this shouldn't be a issue.
Getting some ideas how to do it now? :)
Ralf
Enthusiast
Enthusiast
Posts: 203
Joined: Fri May 30, 2003 1:29 pm
Location: Germany

Re: More examples!

Post by Ralf »

Many thanks for all who helped me with this issue! I have started to rewrite my very complex routines! But now the next problem comes... see new topic (DIM : AllocMem)
Post Reply