Local question

Find quick help here to get you started with Hollywood
Post Reply
djrikki
Posts: 682
Joined: Wed Apr 06, 2011 12:26 am

Local question

Post by djrikki »

Hi,

This piece of code results in 78 being displayed by debugprint on each re-iteration of the For/Next loop.

Code: Select all

	    Local a, yoffset = 62
	    
	    If appsdownloaded[0][8] > 0
		    For a = 0 to appsdownloaded[0][8] - 1
		        ; Userdata: pass local and remote archive data to the function called
		            debugprint( 78 + (yoffset * a) )
		        MakeButton(a+1, #SIMPLEBUTTON, 672,78 + (yoffset * a), 110, 40, evtfunc, { appsdownloaded[a+imagepage][3], appsdownloaded[a+imagepage][4] })
		    Next
		EndIf
However if I drop the yoffset = 62 on to a separate line, like so:

Code: Select all

	    Local a, yoffset
	    yoffset = 62
	    
	    If appsdownloaded[0][8] > 0
		    For a = 0 to appsdownloaded[0][8] - 1
		        ; Userdata: pass local and remote archive data to the function called
		            debugprint( a )
		            debugprint( 78 + (yoffset * a) )
		        MakeButton(a+1, #SIMPLEBUTTON, 672,78 + (yoffset * a), 110, 40, evtfunc, { appsdownloaded[a+imagepage][3], appsdownloaded[a+imagepage][4] })
		    Next
		EndIf
The calculation yoffset * a --> will now be perform on each iteration.

If've seen this bug a few times on occasion, I always thought it was possible to specify a multitude of local variables and initiate them with a value(s) on the same line?
Perhaps however I am wrong? I also tried giving 'a' a value of zero, but this just returned '78' all the way through as well.
Evolve - Rapid GUI Development tool for MUI Royale and RapaGUI
http://myevolve.wordpress.com
jalih
Posts: 276
Joined: Fri Jun 18, 2010 8:08 pm
Location: Finland

Re: Local bug

Post by jalih »

djrikki wrote:I always thought it was possible to specify a multitude of local variables and initiate them with a value(s) on the same line?

Code: Select all

Local a, yoffset = 62
=> a = 62, yoffset = Nil

Code: Select all

Local a, yoffset = 62, 10
=> a = 62, yoffset = 10
Post Reply