Endif Expected ?

Blitz3D Forums/Blitz3D Beginners Area/Endif Expected ?

StOrM3(Posted 2004) [#1]
Function LoadMyStuff()
Local count%

count% = 0


For count% = 0 To 18
  hold.gameitems(count%) = New gameitems
Next

If count% = 0
  hold(count%)\item = nS_LoadImage("../media/image0.jpg",4,True)
  hold(count%)\anim1 = nS_LoadAnimImage("../media/particle1.jpg",GX#,GY#,0,10,4,True)
  hold(count%)\anim2 = nS_LoadAnimImage("../media/particle2.jpg",GX#,GY#,0,10,4,True)
  hold(count%)\gridx% = -1
  hold(count%)\gridy% = -1
  hold(count%)\points% = 0 ;0=stopped
  hold(count%)\time% = 0
  hold(count%)\lives% = 0
  hold(count%)\ID% = count%
  hold(count%)\status% = 0 ;0=stopped
  hold(count%)\puzzle% = 0 ;not a puzzle piece
  hold(count%)\nextitem% = ID_free
  count% = count% + 1
EndIf


In the above code segment, I am getting an EndIf Expected error message from blitz right after hold(count%)\item right here before \item. Any ideas why ? I thought it might be my blitz3d is corrupted or something, but then I compiled and ran a different blitz app and it worked fine. I am pulling my hair out, as I can find no reason for this error.


puki(Posted 2004) [#2]
Surely count% won't equal 0 coz it is looping to 18?


Rimmsy(Posted 2004) [#3]
are you sure you've declared the 'hold' array in the main program somewhere? Also, you don't need the % after integer vars, it only makes your code slower to type and harder to read. Onece you've declared a variable you don't need to type the data type char again.


GfK(Posted 2004) [#4]
I don't see an 'End Function'...


StOrM3(Posted 2004) [#5]
yes the end function is there, and I have declared hold array in the main program.. here is the Main Program code which calls this function.

Graphics3D 1024,768,16,2

Include "load.bb"

Type gameitems
  Field item
  Field anim1
  Field anim2
  Field gridx%
  Field gridy%
  Field points%
  Field time%
  Field lives%
  Field ID%
  Field status%
  Field puzzle%
  Field nextitem%
End Type

Global GX#
Global GY#
Global Current_Piece%  ;use this to track what piece player should hit.
Global currlevel% ;use this to track the current level we are on.
Global countx%

Dim hold.gameitems(18)

For countx% = 0 To 18
  hold.gameitems(countx%) = New gameitems
Next

GX# = 64
GY# = 64

LoadMyStuff()

Repeat
RenderWorld



Flip
Until KeyHit(1)


Then the load.bb file code is:
Function LoadMyStuff()

count% = 0



If count% = 0
  hold(count%)\item = nS_LoadImage("../media/image0.jpg",4,True)
  hold(count%)\anim1 = nS_LoadAnimImage("../media/particle1.jpg",GX#,GY#,0,10,4,True)
  hold(count%)\anim2 = nS_LoadAnimImage("../media/particle2.jpg",GX#,GY#,0,10,4,True)
  hold(count%)\gridx% = -1
  hold(count%)\gridy% = -1
  hold(count%)\points% = 0 ;0=stopped
  hold(count%)\time% = 0
  hold(count%)\lives% = 0
  hold(count%)\ID% = count%
  hold(count%)\status% = 0 ;0=stopped
  hold(count%)\puzzle% = 0 ;not a puzzle piece
  hold(count%)\nextitem% = ID_free
  count% = count% + 1
EndIf

If count% = 1 Then
  hold(count%)\item = nS_LoadImage("../media/image1.jpg",4,True)
  hold(count%)\anim1 = nS_LoadAnimImage("../media/particle1.jpg",GX#,GY#,0,10,4,True)
  hold(count%)\anim2 = nS_LoadAnimImage("../media/particle2.jpg",GX#,GY#,0,10,4,True)
  hold(count%)\gridx% = -1
  hold(count%)\gridy% = -1
  hold(count%)\points% = 0 ;0=stopped
  hold(count%)\time% = 0
  hold(count%)\lives% = 0
  hold(count%)\ID% = count%
  hold(count%)\status% = 0 ;0=stopped
  hold(count%)\puzzle% = 0 ;not a puzzle piece
  hold(count%)\nextitem% = ID_free
  count% = count% + 1
EndIf

If count% = 2 Then
  hold(count%)\item = nS_LoadImage("../media/image2.jpg",4,True)
  hold(count%)\anim1 = nS_LoadAnimImage("../media/particle1.jpg",GX#,GY#,0,10,4,True)
  hold(count%)\anim2 = nS_LoadAnimImage("../media/particle2.jpg",GX#,GY#,0,10,4,True)
  hold(count%)\gridx% = -1
  hold(count%)\gridy% = -1
  hold(count%)\points% = 0 ;0=stopped
  hold(count%)\time% = 0
  hold(count%)\lives% = 0
  hold(count%)\ID% = count%
  hold(count%)\status% = 0 ;0=stopped
  hold(count%)\puzzle% = 0 ;not a puzzle piece
  hold(count%)\nextitem% = ID_free
  count% = count% + 1
EndIf

If count% = 3 Then
  hold(count%)\item = nS_LoadImage("../media/image3.jpg",4,True)
  hold(count%)\anim1 = nS_LoadAnimImage("../media/particle1.jpg",GX#,GY#,0,10,4,True)
  hold(count%)\anim2 = nS_LoadAnimImage("../media/particle2.jpg",GX#,GY#,0,10,4,True)
  hold(count%)\gridx% = -1
  hold(count%)\gridy% = -1
  hold(count%)\points% = 0 ;0=stopped
  hold(count%)\time% = 0
  hold(count%)\lives% = 0
  hold(count%)\ID% = count%
  hold(count%)\status% = 0 ;0=stopped
  hold(count%)\puzzle% = 0 ;not a puzzle piece
  hold(count%)\nextitem% = ID_free
  count% = count% + 1
EndIf

If count% = 4 Then
  hold(count%)\item = nS_LoadImage("../media/image4.jpg",4,True)
  hold(count%)\anim1 = nS_LoadAnimImage("../media/particle1.jpg",GX#,GY#,0,10,4,True)
  hold(count%)\anim2 = nS_LoadAnimImage("../media/particle2.jpg",GX#,GY#,0,10,4,True)
  hold(count%)\gridx% = -1
  hold(count%)\gridy% = -1
  hold(count%)\points% = 0 ;0=stopped
  hold(count%)\time% = 0
  hold(count%)\lives% = 0
  hold(count%)\ID% = count%
  hold(count%)\status% = 0 ;0=stopped
  hold(count%)\puzzle% = 0 ;not a puzzle piece
  hold(count%)\nextitem% = ID_free
  count% = count% + 1
EndIf

If count% = 5 Then
  hold(count%)\item = nS_LoadImage("../media/image5.jpg",4,True)
  hold(count%)\anim1 = nS_LoadAnimImage("../media/particle1.jpg",GX#,GY#,0,10,4,True)
  hold(count%)\anim2 = nS_LoadAnimImage("../media/particle2.jpg",GX#,GY#,0,10,4,True)
  hold(count%)\gridx% = -1
  hold(count%)\gridy% = -1
  hold(count%)\points% = 0 ;0=stopped
  hold(count%)\time% = 0
  hold(count%)\lives% = 0
  hold(count%)\ID% = count%
  hold(count%)\status% = 0 ;0=stopped
  hold(count%)\puzzle% = 0 ;not a puzzle piece
  hold(count%)\nextitem% = ID_free
  count% = count% + 1
EndIf

If count% = 6 Then
  hold(count%)\item = nS_LoadImage("../media/image6.jpg",4,True)
  hold(count%)\anim1 = nS_LoadAnimImage("../media/particle1.jpg",GX#,GY#,0,10,4,True)
  hold(count%)\anim2 = nS_LoadAnimImage("../media/particle2.jpg",GX#,GY#,0,10,4,True)
  hold(count%)\gridx% = -1
  hold(count%)\gridy% = -1
  hold(count%)\points% = 0 ;0=stopped
  hold(count%)\time% = 0
  hold(count%)\lives% = 0
  hold(count%)\ID% = count%
  hold(count%)\status% = 0 ;0=stopped
  hold(count%)\puzzle% = 0 ;not a puzzle piece
  hold(count%)\nextitem% = ID_free
  count% = count% + 1
EndIf

If count% = 7 Then
  hold(count%)\item = nS_LoadImage("../media/image7.jpg",4,True)
  hold(count%)\anim1 = nS_LoadAnimImage("../media/particle1.jpg",GX#,GY#,0,10,4,True)
  hold(count%)\anim2 = nS_LoadAnimImage("../media/particle2.jpg",GX#,GY#,0,10,4,True)
  hold(count%)\gridx% = -1
  hold(count%)\gridy% = -1
  hold(count%)\points% = 0 ;0=stopped
  hold(count%)\time% = 0
  hold(count%)\lives% = 0
  hold(count%)\ID% = count%
  hold(count%)\status% = 0 ;0=stopped
  hold(count%)\puzzle% = 0 ;not a puzzle piece
  hold(count%)\nextitem% = ID_free
  count% = count% + 1
EndIf

If count% = 8 Then
  hold(count%)\item = nS_LoadImage("../media/image8.jpg",4,True)
  hold(count%)\anim1 = nS_LoadAnimImage("../media/particle1.jpg",GX#,GY#,0,10,4,True)
  hold(count%)\anim2 = nS_LoadAnimImage("../media/particle2.jpg",GX#,GY#,0,10,4,True)
  hold(count%)\gridx% = -1
  hold(count%)\gridy% = -1
  hold(count%)\points% = 0 ;0=stopped
  hold(count%)\time% = 0
  hold(count%)\lives% = 0
  hold(count%)\ID% = count%
  hold(count%)\status% = 0 ;0=stopped
  hold(count%)\puzzle% = 0 ;not a puzzle piece
  hold(count%)\nextitem% = ID_free
  count% = count% + 1
EndIf

If count% = 9 Then
  hold(count%)\item = nS_LoadImage("../media/image9.jpg",4,True)
  hold(count%)\anim1 = nS_LoadAnimImage("../media/particle1.jpg",GX#,GY#,0,10,4,True)
  hold(count%)\anim2 = nS_LoadAnimImage("../media/particle2.jpg",GX#,GY#,0,10,4,True)
  hold(count%)\gridx% = -1
  hold(count%)\gridy% = -1
  hold(count%)\points% = 0 ;0=stopped
  hold(count%)\time% = 0
  hold(count%)\lives% = 0
  hold(count%)\ID% = count%
  hold(count%)\status% = 0 ;0=stopped
  hold(count%)\puzzle% = 0 ;not a puzzle piece
  hold(count%)\nextitem% = ID_free
  count% = count% + 1
EndIf

If count% = 10 Then
  hold(count%)\item = nS_LoadImage("../media/image10.jpg",4,True)
  hold(count%)\anim1 = nS_LoadAnimImage("../media/particle1.jpg",GX#,GY#,0,10,4,True)
  hold(count%)\anim2 = nS_LoadAnimImage("../media/particle2.jpg",GX#,GY#,0,10,4,True)
  hold(count%)\gridx% = -1
  hold(count%)\gridy% = -1
  hold(count%)\points% = 0 ;0=stopped
  hold(count%)\time% = 0
  hold(count%)\lives% = 0
  hold(count%)\ID% = count%
  hold(count%)\status% = 0 ;0=stopped
  hold(count%)\puzzle% = 0 ;not a puzzle piece
  hold(count%)\nextitem% = ID_free
  count% = count% + 1
EndIf

If count% = 11 Then
  hold(count%)\item = nS_LoadImage("../media/image11.jpg",4,True)
  hold(count%)\anim1 = nS_LoadAnimImage("../media/particle1.jpg",GX#,GY#,0,10,4,True)
  hold(count%)\anim2 = nS_LoadAnimImage("../media/particle2.jpg",GX#,GY#,0,10,4,True)
  hold(count%)\gridx% = -1
  hold(count%)\gridy% = -1
  hold(count%)\points% = 0 ;0=stopped
  hold(count%)\time% = 0
  hold(count%)\lives% = 0
  hold(count%)\ID% = count%
  hold(count%)\status% = 0 ;0=stopped
  hold(count%)\puzzle% = 0 ;not a puzzle piece
  hold(count%)\nextitem% = ID_free
  count% = count% + 1
EndIf

If count% = 12 Then
  hold(count%)\item = nS_LoadImage("../media/image12.jpg",4,True)
  hold(count%)\anim1 = nS_LoadAnimImage("../media/particle1.jpg",GX#,GY#,0,10,4,True)
  hold(count%)\anim2 = nS_LoadAnimImage("../media/particle2.jpg",GX#,GY#,0,10,4,True)
  hold(count%)\gridx% = -1
  hold(count%)\gridy% = -1
  hold(count%)\points% = 0 ;0=stopped
  hold(count%)\time% = 0
  hold(count%)\lives% = 0
  hold(count%)\ID% = count%
  hold(count%)\status% = 0 ;0=stopped
  hold(count%)\puzzle% = 0 ;not a puzzle piece
  hold(count%)\nextitem% = ID_free
  count% = count% + 1
EndIf

If count% = 13 Then
  hold(count%)\item = nS_LoadImage("../media/image13.jpg",4,True)
  hold(count%)\anim1 = nS_LoadAnimImage("../media/particle1.jpg",GX#,GY#,0,10,4,True)
  hold(count%)\anim2 = nS_LoadAnimImage("../media/particle2.jpg",GX#,GY#,0,10,4,True)
  hold(count%)\gridx% = -1
  hold(count%)\gridy% = -1
  hold(count%)\points% = 0 ;0=stopped
  hold(count%)\time% = 0
  hold(count%)\lives% = 0
  hold(count%)\ID% = count%
  hold(count%)\status% = 0 ;0=stopped
  hold(count%)\puzzle% = 0 ;not a puzzle piece
  hold(count%)\nextitem% = ID_free
  count% = count% + 1
EndIf

If count% = 14 Then
  hold(count%)\item = nS_LoadImage("../media/image14.jpg",4,True)
  hold(count%)\anim1 = nS_LoadAnimImage("../media/particle1.jpg",GX#,GY#,0,10,4,True)
  hold(count%)\anim2 = nS_LoadAnimImage("../media/particle2.jpg",GX#,GY#,0,10,4,True)
  hold(count%)\gridx% = -1
  hold(count%)\gridy% = -1
  hold(count%)\points% = 0 ;0=stopped
  hold(count%)\time% = 0
  hold(count%)\lives% = 0
  hold(count%)\ID% = count%
  hold(count%)\status% = 0 ;0=stopped
  hold(count%)\puzzle% = 0 ;not a puzzle piece
  hold(count%)\nextitem% = ID_free
  count% = count% + 1
EndIf

If count% = 15 Then
  hold(count%)\item = nS_LoadImage("../media/image15.jpg",4,True)
  hold(count%)\anim1 = nS_LoadAnimImage("../media/particle1.jpg",GX#,GY#,0,10,4,True)
  hold(count%)\anim2 = nS_LoadAnimImage("../media/particle2.jpg",GX#,GY#,0,10,4,True)
  hold(count%)\gridx% = -1
  hold(count%)\gridy% = -1
  hold(count%)\points% = 0 ;0=stopped
  hold(count%)\time% = 0
  hold(count%)\lives% = 0
  hold(count%)\ID% = count%
  hold(count%)\status% = 0 ;0=stopped
  hold(count%)\puzzle% = 0 ;not a puzzle piece
  hold(count%)\nextitem% = ID_free
  count% = count% + 1
EndIf

If count% = 16 Then
  hold(count%)\item = nS_LoadImage("../media/image16.jpg",4,True)
  hold(count%)\anim1 = nS_LoadAnimImage("../media/particle1.jpg",GX#,GY#,0,10,4,True)
  hold(count%)\anim2 = nS_LoadAnimImage("../media/particle2.jpg",GX#,GY#,0,10,4,True)
  hold(count%)\gridx% = -1
  hold(count%)\gridy% = -1
  hold(count%)\points% = 0 ;0=stopped
  hold(count%)\time% = 0
  hold(count%)\lives% = 0
  hold(count%)\ID% = count%
  hold(count%)\status% = 0 ;0=stopped
  hold(count%)\puzzle% = 0 ;not a puzzle piece
  hold(count%)\nextitem% = ID_free
  count% = count% + 1
EndIf

If count% = 17 Then
  hold(count%)\item = nS_LoadImage("../media/image17.jpg",4,True)
  hold(count%)\anim1 = nS_LoadAnimImage("../media/particle1.jpg",GX#,GY#,0,10,4,True)
  hold(count%)\anim2 = nS_LoadAnimImage("../media/particle2.jpg",GX#,GY#,0,10,4,True)
  hold(count%)\gridx% = -1
  hold(count%)\gridy% = -1
  hold(count%)\points% = 0 ;0=stopped
  hold(count%)\time% = 0
  hold(count%)\lives% = 0
  hold(count%)\ID% = count%
  hold(count%)\status% = 0 ;0=stopped
  hold(count%)\puzzle% = 0 ;not a puzzle piece
  hold(count%)\nextitem% = ID_free
  count% = count% + 1
EndIf

If count% = 18 Then
  hold(count%)\item = nS_LoadImage("../media/image18.jpg",4,True)
  hold(count%)\anim1 = nS_LoadAnimImage("../media/particle1.jpg",GX#,GY#,0,10,4,True)
  hold(count%)\anim2 = nS_LoadAnimImage("../media/particle2.jpg",GX#,GY#,0,10,4,True)
  hold(count%)\gridx% = -1
  hold(count%)\gridy% = -1
  hold(count%)\points% = 0 ;0=stopped
  hold(count%)\time% = 0
  hold(count%)\lives% = 0
  hold(count%)\ID% = count%
  hold(count%)\status% = 0 ;0=stopped
  hold(count%)\puzzle% = 0 ;not a puzzle piece
  hold(count%)\nextitem% = ID_free
  count% = count% + 1
EndIf

End Function


Hope this helps, as I think I either have a logic error, or my blitz3d installation is messed up.


fredborg(Posted 2004) [#6]
Try removing the '%' signs after all but the first count.

Also try saving and reloading the code, sometimes there are hidden characters if you copy paste from another program into Blitz.


KiwiSteve(Posted 2004) [#7]
Shouldn't

If count% = 0

be

If count% = 0 Then

like in the rest of your If statements?


Rimmsy(Posted 2004) [#8]
I copied it all, deleted the include line and ran this fine. See if you can.

Graphics3D 1024,768,16,2


Type gameitems
  Field item
  Field anim1
  Field anim2
  Field gridx%
  Field gridy%
  Field points%
  Field time%
  Field lives%
  Field ID%
  Field status%
  Field puzzle%
  Field nextitem%
End Type

Global GX#
Global GY#
Global Current_Piece%  ;use this to track what piece player should hit.
Global currlevel% ;use this to track the current level we are on.
Global countx%

Dim hold.gameitems(18)

For countx% = 0 To 18
  hold.gameitems(countx%) = New gameitems
Next

GX# = 64
GY# = 64

LoadMyStuff()

Repeat
RenderWorld



Flip
Until KeyHit(1)


Function nS_LoadImage(txt$,a,b)

End Function

Function nS_LoadAnimImage(txt$,GX#,GY#,a,b,c,d)

End Function


Function LoadMyStuff()

count% = 0



If count% = 0
  hold(count%)\item = nS_LoadImage("../media/image0.jpg",4,True)
  hold(count%)\anim1 = nS_LoadAnimImage("../media/particle1.jpg",GX#,GY#,0,10,4,True)
  hold(count%)\anim2 = nS_LoadAnimImage("../media/particle2.jpg",GX#,GY#,0,10,4,True)
  hold(count%)\gridx% = -1
  hold(count%)\gridy% = -1
  hold(count%)\points% = 0 ;0=stopped
  hold(count%)\time% = 0
  hold(count%)\lives% = 0
  hold(count%)\ID% = count%
  hold(count%)\status% = 0 ;0=stopped
  hold(count%)\puzzle% = 0 ;not a puzzle piece
  hold(count%)\nextitem% = ID_free
  count% = count% + 1
EndIf

If count% = 1 Then
  hold(count%)\item = nS_LoadImage("../media/image1.jpg",4,True)
  hold(count%)\anim1 = nS_LoadAnimImage("../media/particle1.jpg",GX#,GY#,0,10,4,True)
  hold(count%)\anim2 = nS_LoadAnimImage("../media/particle2.jpg",GX#,GY#,0,10,4,True)
  hold(count%)\gridx% = -1
  hold(count%)\gridy% = -1
  hold(count%)\points% = 0 ;0=stopped
  hold(count%)\time% = 0
  hold(count%)\lives% = 0
  hold(count%)\ID% = count%
  hold(count%)\status% = 0 ;0=stopped
  hold(count%)\puzzle% = 0 ;not a puzzle piece
  hold(count%)\nextitem% = ID_free
  count% = count% + 1
EndIf

If count% = 2 Then
  hold(count%)\item = nS_LoadImage("../media/image2.jpg",4,True)
  hold(count%)\anim1 = nS_LoadAnimImage("../media/particle1.jpg",GX#,GY#,0,10,4,True)
  hold(count%)\anim2 = nS_LoadAnimImage("../media/particle2.jpg",GX#,GY#,0,10,4,True)
  hold(count%)\gridx% = -1
  hold(count%)\gridy% = -1
  hold(count%)\points% = 0 ;0=stopped
  hold(count%)\time% = 0
  hold(count%)\lives% = 0
  hold(count%)\ID% = count%
  hold(count%)\status% = 0 ;0=stopped
  hold(count%)\puzzle% = 0 ;not a puzzle piece
  hold(count%)\nextitem% = ID_free
  count% = count% + 1
EndIf

If count% = 3 Then
  hold(count%)\item = nS_LoadImage("../media/image3.jpg",4,True)
  hold(count%)\anim1 = nS_LoadAnimImage("../media/particle1.jpg",GX#,GY#,0,10,4,True)
  hold(count%)\anim2 = nS_LoadAnimImage("../media/particle2.jpg",GX#,GY#,0,10,4,True)
  hold(count%)\gridx% = -1
  hold(count%)\gridy% = -1
  hold(count%)\points% = 0 ;0=stopped
  hold(count%)\time% = 0
  hold(count%)\lives% = 0
  hold(count%)\ID% = count%
  hold(count%)\status% = 0 ;0=stopped
  hold(count%)\puzzle% = 0 ;not a puzzle piece
  hold(count%)\nextitem% = ID_free
  count% = count% + 1
EndIf

If count% = 4 Then
  hold(count%)\item = nS_LoadImage("../media/image4.jpg",4,True)
  hold(count%)\anim1 = nS_LoadAnimImage("../media/particle1.jpg",GX#,GY#,0,10,4,True)
  hold(count%)\anim2 = nS_LoadAnimImage("../media/particle2.jpg",GX#,GY#,0,10,4,True)
  hold(count%)\gridx% = -1
  hold(count%)\gridy% = -1
  hold(count%)\points% = 0 ;0=stopped
  hold(count%)\time% = 0
  hold(count%)\lives% = 0
  hold(count%)\ID% = count%
  hold(count%)\status% = 0 ;0=stopped
  hold(count%)\puzzle% = 0 ;not a puzzle piece
  hold(count%)\nextitem% = ID_free
  count% = count% + 1
EndIf

If count% = 5 Then
  hold(count%)\item = nS_LoadImage("../media/image5.jpg",4,True)
  hold(count%)\anim1 = nS_LoadAnimImage("../media/particle1.jpg",GX#,GY#,0,10,4,True)
  hold(count%)\anim2 = nS_LoadAnimImage("../media/particle2.jpg",GX#,GY#,0,10,4,True)
  hold(count%)\gridx% = -1
  hold(count%)\gridy% = -1
  hold(count%)\points% = 0 ;0=stopped
  hold(count%)\time% = 0
  hold(count%)\lives% = 0
  hold(count%)\ID% = count%
  hold(count%)\status% = 0 ;0=stopped
  hold(count%)\puzzle% = 0 ;not a puzzle piece
  hold(count%)\nextitem% = ID_free
  count% = count% + 1
EndIf

If count% = 6 Then
  hold(count%)\item = nS_LoadImage("../media/image6.jpg",4,True)
  hold(count%)\anim1 = nS_LoadAnimImage("../media/particle1.jpg",GX#,GY#,0,10,4,True)
  hold(count%)\anim2 = nS_LoadAnimImage("../media/particle2.jpg",GX#,GY#,0,10,4,True)
  hold(count%)\gridx% = -1
  hold(count%)\gridy% = -1
  hold(count%)\points% = 0 ;0=stopped
  hold(count%)\time% = 0
  hold(count%)\lives% = 0
  hold(count%)\ID% = count%
  hold(count%)\status% = 0 ;0=stopped
  hold(count%)\puzzle% = 0 ;not a puzzle piece
  hold(count%)\nextitem% = ID_free
  count% = count% + 1
EndIf

If count% = 7 Then
  hold(count%)\item = nS_LoadImage("../media/image7.jpg",4,True)
  hold(count%)\anim1 = nS_LoadAnimImage("../media/particle1.jpg",GX#,GY#,0,10,4,True)
  hold(count%)\anim2 = nS_LoadAnimImage("../media/particle2.jpg",GX#,GY#,0,10,4,True)
  hold(count%)\gridx% = -1
  hold(count%)\gridy% = -1
  hold(count%)\points% = 0 ;0=stopped
  hold(count%)\time% = 0
  hold(count%)\lives% = 0
  hold(count%)\ID% = count%
  hold(count%)\status% = 0 ;0=stopped
  hold(count%)\puzzle% = 0 ;not a puzzle piece
  hold(count%)\nextitem% = ID_free
  count% = count% + 1
EndIf

If count% = 8 Then
  hold(count%)\item = nS_LoadImage("../media/image8.jpg",4,True)
  hold(count%)\anim1 = nS_LoadAnimImage("../media/particle1.jpg",GX#,GY#,0,10,4,True)
  hold(count%)\anim2 = nS_LoadAnimImage("../media/particle2.jpg",GX#,GY#,0,10,4,True)
  hold(count%)\gridx% = -1
  hold(count%)\gridy% = -1
  hold(count%)\points% = 0 ;0=stopped
  hold(count%)\time% = 0
  hold(count%)\lives% = 0
  hold(count%)\ID% = count%
  hold(count%)\status% = 0 ;0=stopped
  hold(count%)\puzzle% = 0 ;not a puzzle piece
  hold(count%)\nextitem% = ID_free
  count% = count% + 1
EndIf

If count% = 9 Then
  hold(count%)\item = nS_LoadImage("../media/image9.jpg",4,True)
  hold(count%)\anim1 = nS_LoadAnimImage("../media/particle1.jpg",GX#,GY#,0,10,4,True)
  hold(count%)\anim2 = nS_LoadAnimImage("../media/particle2.jpg",GX#,GY#,0,10,4,True)
  hold(count%)\gridx% = -1
  hold(count%)\gridy% = -1
  hold(count%)\points% = 0 ;0=stopped
  hold(count%)\time% = 0
  hold(count%)\lives% = 0
  hold(count%)\ID% = count%
  hold(count%)\status% = 0 ;0=stopped
  hold(count%)\puzzle% = 0 ;not a puzzle piece
  hold(count%)\nextitem% = ID_free
  count% = count% + 1
EndIf

If count% = 10 Then
  hold(count%)\item = nS_LoadImage("../media/image10.jpg",4,True)
  hold(count%)\anim1 = nS_LoadAnimImage("../media/particle1.jpg",GX#,GY#,0,10,4,True)
  hold(count%)\anim2 = nS_LoadAnimImage("../media/particle2.jpg",GX#,GY#,0,10,4,True)
  hold(count%)\gridx% = -1
  hold(count%)\gridy% = -1
  hold(count%)\points% = 0 ;0=stopped
  hold(count%)\time% = 0
  hold(count%)\lives% = 0
  hold(count%)\ID% = count%
  hold(count%)\status% = 0 ;0=stopped
  hold(count%)\puzzle% = 0 ;not a puzzle piece
  hold(count%)\nextitem% = ID_free
  count% = count% + 1
EndIf

If count% = 11 Then
  hold(count%)\item = nS_LoadImage("../media/image11.jpg",4,True)
  hold(count%)\anim1 = nS_LoadAnimImage("../media/particle1.jpg",GX#,GY#,0,10,4,True)
  hold(count%)\anim2 = nS_LoadAnimImage("../media/particle2.jpg",GX#,GY#,0,10,4,True)
  hold(count%)\gridx% = -1
  hold(count%)\gridy% = -1
  hold(count%)\points% = 0 ;0=stopped
  hold(count%)\time% = 0
  hold(count%)\lives% = 0
  hold(count%)\ID% = count%
  hold(count%)\status% = 0 ;0=stopped
  hold(count%)\puzzle% = 0 ;not a puzzle piece
  hold(count%)\nextitem% = ID_free
  count% = count% + 1
EndIf

If count% = 12 Then
  hold(count%)\item = nS_LoadImage("../media/image12.jpg",4,True)
  hold(count%)\anim1 = nS_LoadAnimImage("../media/particle1.jpg",GX#,GY#,0,10,4,True)
  hold(count%)\anim2 = nS_LoadAnimImage("../media/particle2.jpg",GX#,GY#,0,10,4,True)
  hold(count%)\gridx% = -1
  hold(count%)\gridy% = -1
  hold(count%)\points% = 0 ;0=stopped
  hold(count%)\time% = 0
  hold(count%)\lives% = 0
  hold(count%)\ID% = count%
  hold(count%)\status% = 0 ;0=stopped
  hold(count%)\puzzle% = 0 ;not a puzzle piece
  hold(count%)\nextitem% = ID_free
  count% = count% + 1
EndIf

If count% = 13 Then
  hold(count%)\item = nS_LoadImage("../media/image13.jpg",4,True)
  hold(count%)\anim1 = nS_LoadAnimImage("../media/particle1.jpg",GX#,GY#,0,10,4,True)
  hold(count%)\anim2 = nS_LoadAnimImage("../media/particle2.jpg",GX#,GY#,0,10,4,True)
  hold(count%)\gridx% = -1
  hold(count%)\gridy% = -1
  hold(count%)\points% = 0 ;0=stopped
  hold(count%)\time% = 0
  hold(count%)\lives% = 0
  hold(count%)\ID% = count%
  hold(count%)\status% = 0 ;0=stopped
  hold(count%)\puzzle% = 0 ;not a puzzle piece
  hold(count%)\nextitem% = ID_free
  count% = count% + 1
EndIf

If count% = 14 Then
  hold(count%)\item = nS_LoadImage("../media/image14.jpg",4,True)
  hold(count%)\anim1 = nS_LoadAnimImage("../media/particle1.jpg",GX#,GY#,0,10,4,True)
  hold(count%)\anim2 = nS_LoadAnimImage("../media/particle2.jpg",GX#,GY#,0,10,4,True)
  hold(count%)\gridx% = -1
  hold(count%)\gridy% = -1
  hold(count%)\points% = 0 ;0=stopped
  hold(count%)\time% = 0
  hold(count%)\lives% = 0
  hold(count%)\ID% = count%
  hold(count%)\status% = 0 ;0=stopped
  hold(count%)\puzzle% = 0 ;not a puzzle piece
  hold(count%)\nextitem% = ID_free
  count% = count% + 1
EndIf

If count% = 15 Then
  hold(count%)\item = nS_LoadImage("../media/image15.jpg",4,True)
  hold(count%)\anim1 = nS_LoadAnimImage("../media/particle1.jpg",GX#,GY#,0,10,4,True)
  hold(count%)\anim2 = nS_LoadAnimImage("../media/particle2.jpg",GX#,GY#,0,10,4,True)
  hold(count%)\gridx% = -1
  hold(count%)\gridy% = -1
  hold(count%)\points% = 0 ;0=stopped
  hold(count%)\time% = 0
  hold(count%)\lives% = 0
  hold(count%)\ID% = count%
  hold(count%)\status% = 0 ;0=stopped
  hold(count%)\puzzle% = 0 ;not a puzzle piece
  hold(count%)\nextitem% = ID_free
  count% = count% + 1
EndIf

If count% = 16 Then
  hold(count%)\item = nS_LoadImage("../media/image16.jpg",4,True)
  hold(count%)\anim1 = nS_LoadAnimImage("../media/particle1.jpg",GX#,GY#,0,10,4,True)
  hold(count%)\anim2 = nS_LoadAnimImage("../media/particle2.jpg",GX#,GY#,0,10,4,True)
  hold(count%)\gridx% = -1
  hold(count%)\gridy% = -1
  hold(count%)\points% = 0 ;0=stopped
  hold(count%)\time% = 0
  hold(count%)\lives% = 0
  hold(count%)\ID% = count%
  hold(count%)\status% = 0 ;0=stopped
  hold(count%)\puzzle% = 0 ;not a puzzle piece
  hold(count%)\nextitem% = ID_free
  count% = count% + 1
EndIf

If count% = 17 Then
  hold(count%)\item = nS_LoadImage("../media/image17.jpg",4,True)
  hold(count%)\anim1 = nS_LoadAnimImage("../media/particle1.jpg",GX#,GY#,0,10,4,True)
  hold(count%)\anim2 = nS_LoadAnimImage("../media/particle2.jpg",GX#,GY#,0,10,4,True)
  hold(count%)\gridx% = -1
  hold(count%)\gridy% = -1
  hold(count%)\points% = 0 ;0=stopped
  hold(count%)\time% = 0
  hold(count%)\lives% = 0
  hold(count%)\ID% = count%
  hold(count%)\status% = 0 ;0=stopped
  hold(count%)\puzzle% = 0 ;not a puzzle piece
  hold(count%)\nextitem% = ID_free
  count% = count% + 1
EndIf

If count% = 18 Then
  hold(count%)\item = nS_LoadImage("../media/image18.jpg",4,True)
  hold(count%)\anim1 = nS_LoadAnimImage("../media/particle1.jpg",GX#,GY#,0,10,4,True)
  hold(count%)\anim2 = nS_LoadAnimImage("../media/particle2.jpg",GX#,GY#,0,10,4,True)
  hold(count%)\gridx% = -1
  hold(count%)\gridy% = -1
  hold(count%)\points% = 0 ;0=stopped
  hold(count%)\time% = 0
  hold(count%)\lives% = 0
  hold(count%)\ID% = count%
  hold(count%)\status% = 0 ;0=stopped
  hold(count%)\puzzle% = 0 ;not a puzzle piece
  hold(count%)\nextitem% = ID_free
  count% = count% + 1
EndIf

End Function



Jeppe Nielsen(Posted 2004) [#9]
It won't compile, as the array is used before it is declared:
This example shows it:
array(0)=New blah
array(0)\a=1
Type blah
	Field a
End Type
Dim array.blah(1)

Move the Dim to the top and it will compile.


StOrM3(Posted 2004) [#10]
Okay rims, I got it to work using your copy, what was wrong with it ? I had the same type error on another program I coded, is why I made this small example to find out what is wrong. Was it the included file ? Because it was including the function before the type was declared ?

I added the nSprite.bb include file at the top of the code, and commented your placeholder functions, and it still worked. So with that function in a seperate file, why won't it compile ?


GfK(Posted 2004) [#11]
erm....

You can replace that really long function with a much shorter version:
Function LoadMyStuff()
	For count% = 0 To 18
	  hold(count%)\item = nS_LoadImage("../media/image"+Str$(count)+".jpg",4,True)
	  hold(count%)\anim1 = nS_LoadAnimImage("../media/particle1.jpg",GX#,GY#,0,10,4,True)
	  hold(count%)\anim2 = nS_LoadAnimImage("../media/particle2.jpg",GX#,GY#,0,10,4,True)
	  hold(count%)\gridx% = -1
	  hold(count%)\gridy% = -1
	  hold(count%)\points% = 0 ;0=stopped
	  hold(count%)\time% = 0
	  hold(count%)\lives% = 0
	  hold(count%)\ID% = count%
	  hold(count%)\status% = 0 ;0=stopped
	  hold(count%)\puzzle% = 0 ;not a puzzle piece
	  hold(count%)\nextitem% = ID_free
	Next
End Function



Jeppe Nielsen(Posted 2004) [#12]
But I think it is because the array dimentioning has to be before you refer to it. Unlike arrays the types declarations can be anywhere, I don't know why this is so.
Anyway try moving the dim:
Dim hold.gameitems(18)

Up to before:
Include "load.bb"

Anyway always have your dims in the top of the code.


Rimmsy(Posted 2004) [#13]
I forgot about the dims being before the includes. Strange that, but always put them above everything as you might refer to the array in one of the include files before you've declared it. This works:
Dim hold.gameitems(18)

; include "load.bb"



Graphics3D 1024,768,16,2

Type gameitems
  Field item
  Field anim1
  Field anim2
  Field gridx%
  Field gridy%
  Field points%
  Field time%
  Field lives%
  Field ID%
  Field status%
  Field puzzle%
  Field nextitem%
End Type




Global GX#
Global GY#
Global Current_Piece%  ;use this to track what piece player should hit.
Global currlevel% ;use this to track the current level we are on.
Global countx%



GX# = 64
GY# = 64

LoadMyStuff()



; loop

Repeat
RenderWorld
Flip
Until KeyHit(1)



Function nS_LoadImage(txt$,a,b)

End Function

Function nS_LoadAnimImage(txt$,GX#,GY#,a,b,c,d)

End Function


Function LoadMyStuff()
	For countx = 0 To 18
		hold(countx) = New gameitems
	Next

	For i=0 To 18
	  hold(i)\item = nS_LoadImage("../media/image"+i+".jpg",4,True)
	  hold(i)\anim1 = nS_LoadAnimImage("../media/particle1.jpg",GX#,GY#,0,10,4,True)
	  hold(i)\anim2 = nS_LoadAnimImage("../media/particle2.jpg",GX#,GY#,0,10,4,True)
	  hold(i)\gridx = -1
	  hold(i)\gridy = -1
	  hold(i)\points = 0 ;0=stopped
	  hold(i)\time = 0
	  hold(i)\lives = 0
	  hold(i)\ID = i
	  hold(i)\status = 0 ;0=stopped
	  hold(i)\puzzle = 0 ;not a puzzle piece
	  hold(i)\nextitem = ID_free
	Next
End Function



Jeppe Nielsen(Posted 2004) [#14]
Thats because now the Dim comes before the hold(i)\item, whereas before it was vica versa due to the Include. Remember the Include command is just like a Cut-And-Paste.


StOrM3(Posted 2004) [#15]
yea, I finally got it all cleaned up and it semi-compiles, but now I am getting objects do not exist, after it loads all the pictures in LoadStuff, then moves onto creategrid, all creategrid does is loop through from 0 to 9 twice to create a two dimensional grid, and assign it different pictures from hold based on a random number, and as far as I can tell, the rand numbers it picks are lower than the number of pictures in hold, so not sure, why I'm getting this. Will have to investigate that function thoroughly, any ideas how to make finding this kind of error easier ?


StOrM3(Posted 2004) [#16]
Gfk, yea, that is the way I had it to begin with, before I started getting the wierd errors, about the endif or when it was the way you have it, I was getting expecting next error message.

I think, that Visual Blitz, Blitz3D needs to have better debugging help, such as these types of situations, would be much better if it said, variable used before dimensioned. or Attempted usage of an undefined variable, I don't know how hard it would be to put this debugging in, but it desperately needs it, I have realized here lately just how hard it is to debug a program with 1000's of lines of code in it, even with debug mode turned on.

Maybe I need to put some kind of object checking code in my code, to make sure each array / variable I am using is initialized before allowing it to be used, and if it is not throw a runtime error with the message variable not initialized <variable name> or something

Any ideas, how to do this ? Especially with Image handles returned from the nSprite lib functions like LoadImage and ns_LoadAnimImage or nS_CopyImage functions.

Thanks for all your help guys, as I am pulling my hair out all weekend over this, I learned a valuable lesson about coding a little, error checking, code a little more, error check etc.. as I go along. Because when I code 3 or more functions, then try to find the bugs, I was losing my mind, and smoking far more often then I should.

Thanks,

Ken


GfK(Posted 2004) [#17]
I think, that Visual Blitz, Blitz3D needs to have better debugging help, such as these types of situations, would be much better if it said, variable used before dimensioned. or Attempted usage of an undefined variable, I don't know how hard it would be to put this debugging in, but it desperately needs it, I have realized here lately just how hard it is to debug a program with 1000's of lines of code in it, even with debug mode turned on.
Its not Visual Blitz's fault - it can only report errors as they are returned from the compiler.


StOrM3(Posted 2004) [#18]
I agree, I'm going to email Mark, and see what could be done about it. Aside from that, any ideas how to put in a runtime error statement to check that a variable for an image handle is actually initialized or not ?


Kanati(Posted 2004) [#19]
If count% = 0
  hold(count%)\item = nS_LoadImage("../media/image0.jpg",4,True)
  hold(count%)\anim1 = nS_LoadAnimImage("../media/particle1.jpg",GX#,GY#,0,10,4,True)
  hold(count%)\anim2 = nS_LoadAnimImage("../media/particle2.jpg",GX#,GY#,0,10,4,True)
  hold(count%)\gridx% = -1
  hold(count%)\gridy% = -1
  hold(count%)\points% = 0 ;0=stopped
  hold(count%)\time% = 0
  hold(count%)\lives% = 0
  hold(count%)\ID% = count%
  hold(count%)\status% = 0 ;0=stopped
  hold(count%)\puzzle% = 0 ;not a puzzle piece
  hold(count%)\nextitem% = ID_free
  count% = count% + 1
EndIf


Your original problem... (I don't know if anyone caught it cuz I didn't read ALL of the posts)... But it was pretty obvious. :)

If count% = 0


Should be

If count% = 0 Then 


:)

Kanati


GfK(Posted 2004) [#20]
Your original problem... (I don't know if anyone caught it cuz I didn't read ALL of the posts)... But it was pretty obvious. :)

[/code]If count% = 0[/code]

Should be

[/code]If count% = 0 Then [/code]

:)

That wasn't the problem at all. 'If count% = 0 ... EndIf' is perfectly normal syntax.


Kanati(Posted 2004) [#21]
Yer $%#%ing me... really? I would almost swear that you HAVE to have "THEN" in an if..then..endif.

/me runs off to check that. :)

[EDIT] Well @#$% me runnin. Learn something new every day.


StOrM3(Posted 2004) [#22]
Nope.. then is not required.. but I do use it normally, but only took it out, when I was getting the strange errors in my feeble attempts to find out what was going on.


StOrM3(Posted 2004) [#23]
Anyone familiar enough with nSprite lib to tell me why hold(i)\item = nS_LoadImage("../media/image"+i+".jpg",4,True)
is only generating a white square block instead of the image it is loading ? I made a test function that draws the items loaded into hold(count%)\item and I am getting pale looking whiteish blocks the size of my images, but not the image.. maybe the texture flags ? 4 is supposed to mean load with alpha level, but jpg's don't have an alpha channel is this where I'm messing Up ?


ashmantle(Posted 2004) [#24]
Exacly.. "then" is optional.