none
Anyway to loop this? RRS feed

  • Question

  • TextWindow.WriteLine ("Enter Variable 'a'")
    a = TextWindow.ReadNumber()
    TextWindow.WriteLine ("Enter Variable 'b'")
    b = TextWindow.ReadNumber()
    TextWindow.WriteLine ("Enter Variable 'c'")
    c = TextWindow.ReadNumber()
    TextWindow.WriteLine ("Enter Variable 'd'")
    d = TextWindow.ReadNumber()
    TextWindow.WriteLine ("Enter Variable 'e'")
    e = TextWindow.ReadNumber()
    TextWindow.WriteLine ("Enter Variable 'f'")
    f = TextWindow.ReadNumber()

    it looks spaghetti coding:/
    Saturday, July 31, 2010 3:48 AM

Answers

  • No it is not spaghetti coding. Better you use arry whith a loop like this:

    for i = 1 to 6
      TextWindow.WriteLine ("Enter "+i". Variable'")
      VarArray[i] = TextWindow.ReadNumber()
    endfor

     


    Best Regards Martin
    • Proposed as answer by Jacob Brown Saturday, July 31, 2010 3:06 PM
    • Marked as answer by litdevModerator Friday, August 6, 2010 9:34 PM
    Saturday, July 31, 2010 4:25 AM
  • TextWindow.WriteLine ("Enter "+i + ". Variable'") - this will result:

    Enter 1. Variable

    Enter 2. Variable

    and so on.

    If You want to see the letters, do:

    for i = 1 to 6
     TextWindow.WriteLine ("Enter Variable '" + Text.GetCharacter( 96 + i) + "'")
     VarArray[i] = TextWindow.ReadNumber()
    endfor
    
    
    Just a little tip.


    • Proposed as answer by _msanders_ Saturday, July 31, 2010 3:17 PM
    • Marked as answer by litdevModerator Friday, August 6, 2010 9:34 PM
    Saturday, July 31, 2010 3:13 PM

All replies

  • No it is not spaghetti coding. Better you use arry whith a loop like this:

    for i = 1 to 6
      TextWindow.WriteLine ("Enter "+i". Variable'")
      VarArray[i] = TextWindow.ReadNumber()
    endfor

     


    Best Regards Martin
    • Proposed as answer by Jacob Brown Saturday, July 31, 2010 3:06 PM
    • Marked as answer by litdevModerator Friday, August 6, 2010 9:34 PM
    Saturday, July 31, 2010 4:25 AM
  • TextWindow.WriteLine ("Enter "+i + ". Variable'") - this will result:

    Enter 1. Variable

    Enter 2. Variable

    and so on.

    If You want to see the letters, do:

    for i = 1 to 6
     TextWindow.WriteLine ("Enter Variable '" + Text.GetCharacter( 96 + i) + "'")
     VarArray[i] = TextWindow.ReadNumber()
    endfor
    
    
    Just a little tip.


    • Proposed as answer by _msanders_ Saturday, July 31, 2010 3:17 PM
    • Marked as answer by litdevModerator Friday, August 6, 2010 9:34 PM
    Saturday, July 31, 2010 3:13 PM
  • Just to Add to Jacob's response, the getCharacter gets the character from its ASCII character value. You can see what values = letters look here: http://www.asciitable.com/  As it can be somewhat confusing to understand how 96 is actually a :)
    Saturday, July 31, 2010 3:17 PM