locked
the for loop... RRS feed

  • Question

  • Well :

    bullet[1][1] = 10
    bullet[1][2] = 11
    bullet[1][3] = 12
    bullet[1][4] = 13
    bullet[1][5] = 14
    bullet[2][1] = 15
    bullet[2][2] = 16
    bullet[2][3] = 17
    bullet[2][4] = 18
    bullet[2][5] = 19
    
    For i = 1 To 2
      For j = 1 To 5
        TextWindow.WriteLine(bullet[i][j])
      EndFor
    EndFor


    This works, but how do i do this one... :

    bullet[1][1] = 10
    bullet[1][2] = 11
    bullet[1][3] = 12
    bullet[1][4] = 13
    bullet[1][5] = 14
    bullet[2][1] = 15
    bullet[2][2] = 16
    bullet[2][3] = 17
    bullet[2][4] = 18
    bullet[2][5] = 19
    
    For i = 2 To 1
      For j = 5 To 1
        TextWindow.WriteLine(bullet[i][j])
      EndFor
    EndFor



    I love game design and game programing.


    • Edited by Primoz128 Wednesday, May 30, 2012 6:37 PM better to read
    Wednesday, May 30, 2012 6:29 PM

Answers

  • Use the keyword Step w/ -1!

    bullet[1][1] = 10
    bullet[1][2] = 11
    bullet[1][3] = 12
    bullet[1][4] = 13
    bullet[1][5] = 14
    bullet[2][1] = 15
    bullet[2][2] = 16
    bullet[2][3] = 17
    bullet[2][4] = 18
    bullet[2][5] = 19
    
    For i = 2 To 1 Step -1
      For j = 5 To 1 Step -1
        TextWindow.WriteLine(bullet[i][j])
      EndFor
    EndFor
    • Marked as answer by Primoz128 Wednesday, May 30, 2012 6:57 PM
    Wednesday, May 30, 2012 6:46 PM
    Answerer

All replies

  • Use the keyword Step w/ -1!

    bullet[1][1] = 10
    bullet[1][2] = 11
    bullet[1][3] = 12
    bullet[1][4] = 13
    bullet[1][5] = 14
    bullet[2][1] = 15
    bullet[2][2] = 16
    bullet[2][3] = 17
    bullet[2][4] = 18
    bullet[2][5] = 19
    
    For i = 2 To 1 Step -1
      For j = 5 To 1 Step -1
        TextWindow.WriteLine(bullet[i][j])
      EndFor
    EndFor
    • Marked as answer by Primoz128 Wednesday, May 30, 2012 6:57 PM
    Wednesday, May 30, 2012 6:46 PM
    Answerer
  • Ah nice i knew there was a keyword for that ... im just no BASIC user... though i did love the power of Pure Basic but it's BASIC syntax made me quit <.< it was too evil...

    ...


    I love game design and game programing.

    Wednesday, May 30, 2012 6:57 PM
  • Another fancy method:  ;-D

    bullet[1] = "1=10;2=11;3=12;4=13;5=14;"
    bullet[2] = "1=15;2=16;3=17;4=18;5=19;"
    
    For i = 1 To Array.GetItemCount( bullet )
      For j = 1 To Array.GetItemCount( bullet[i] )
        store = bullet[i][j]
        TextWindow.WriteLine(store)
        Stack.PushValue("Storage"  store)
      EndFor
    EndFor
    
    While Stack.GetCount("Storage") > 0
      TextWindow.WriteLine( Stack.PopValue("Storage") )
    EndWhile
    Wednesday, May 30, 2012 7:02 PM
    Answerer