Initialize Arrays at definition?

BlitzPlus Forums/BlitzPlus Beginners Area/Initialize Arrays at definition?

Is there any way to initialize an array when you define it? I'm trying to make a chess program and I want to store each of the possible moves that every piece can possibly make into an array (please don't tell me a better way to make the program, I'm sure that this isn't the best way, but I'd like to try it out anyways). Here's an example of what I mean, which doesn't work.

Global QueenXMove[55]={1,2,3,4,5,6,7,-1,-2,-3,-4,-5,-6,-7,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,2,3,4,5,6,7,-1,-2,-3,-4,-5,-6,-7,1,2,3,4,5,6,7,-1,-2,-3,-4,-5,-6,-7}; 16*4-8-1
Global QueenYMove[55]={0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,2,3,4,5,6,7,-1,-2,-3,-4,-5,-6,-7,1,2,3,4,5,6,7,-1,-2,-3,-4,-5,-6,-7,-1,-2,-3,-4,-5,-6,-7,1,2,3,4,5,6,7}


I don't think there is a way in blitzplus (or b3d) that you can specify the array contents upon initialisation.

However you can use data statements or load from a file if that helps.

In Blitz, arrays are automatically 'Global'. Like Matty said you can use DATA statements containing the values to load. Using the 'RESTORE' statement allows you to load different data values (moves) into the same array.

Here's an example:
Dim moves%(55)
moveSelection% = 1
;	.
;	.
;	.
;	.
;	.
;	.
;When it's time to load in the possible moves you can do something like this


	Select moveSelection
		Case 1: Restore QueenXMove
		Case 2: Restore QueenYMove
	End Select
	For i% = 0 To 55
		Read moves(i)
	Next

.QueenXMove
	Data 1,2,3,4,5,6,7,-1,-2,-3,-4,-5,-6,-7,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,2
	Data 3,4,5,6,7,-1,-2,-3,-4,-5,-6,-7,1,2,3,4,5,6,7,-1,-2,-3,-4,-5,-6,-7 ; 16*4-8-1

.QueenYMove
	Data 0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,2,3,4,5,6,7,-1,-2,-3,-4,-5,-6,-7,1,2
	Data 3,4,5,6,7,-1,-2,-3,-4,-5,-6,-7,-1,-2,-3,-4,-5,-6,-7,1,2,3,4,5,6,7