none
Array help RRS feed

  • Question

  •  currently need help with constructing an array. i have the following code
    array[1] =1
    array[2] = 2
    array[3] = 3
    array[4] = 4
    array[5] = 5
    array[6] = 6
    array[7] = 7
    array[8] = 8
    array[9] = 9


    is there any way i can shorten that code?
    for example in c++ i can write
    int array[] = {1,2,3,4,5,6,7,8,9}
    
    Sunday, July 25, 2010 5:38 PM

Answers

  •  

    for i = 0 to 9

    arr[i] = i

    endfor

    or you can cheat as thats how arrays are stored underneath.

    arr = "1=1;2=2;3=3;4=4;5=5;6=6;7=7;8=8;9=9;"

    • Marked as answer by avono Sunday, July 25, 2010 5:46 PM
    Sunday, July 25, 2010 5:42 PM

All replies

  •  

    for i = 0 to 9

    arr[i] = i

    endfor

    or you can cheat as thats how arrays are stored underneath.

    arr = "1=1;2=2;3=3;4=4;5=5;6=6;7=7;8=8;9=9;"

    • Marked as answer by avono Sunday, July 25, 2010 5:46 PM
    Sunday, July 25, 2010 5:42 PM
  • thanks for the quick reply , it helped alot
    Sunday, July 25, 2010 5:47 PM