NxtDisplayTextLine(3, "%3d apples", num_apples) When you’ve figured it out, run it and check out the results. Take a look at the next program and see if you can spot the subtle difference. What if there was a way to get the firmware to take care of that stuff for you?
#ROBOTC NXT CODE#
Int num_apples = 0 // how do you like them apples?ĭoesn’t it get super annoying to see those lines jumping back and forth, depending on whether it’s a 1, 2 or 3-digit number? You work around it by checking how many digits the number is long and printing some spaces in front of the number but that would be cumbersome and would only make your code look cluttered. However, consider the scenario when the number of items change rapidly, what do you think will happen to the words “apples”, “pears” and “cherries”? try the program below and you’ll see what I mean: task main() The items are not arranged very neatly and most of the time that doesn’t really matter that much. The screen will look something like the one below, which is fine if you don’t care about layout. NxtDisplayTextLine(5, "%d cherries", num_cherries) NxtDisplayTextLine(4, "%d pears", num_pears) NxtDisplayTextLine(3, "%d apples", num_apples) NxtDispla圜enteredTextLine(1, "Fruit Stand") Int num_apples = 10 // how do you like them apples?
Your code may, or may not have looked something like this: task main() If you’ve ever had to output anything on the screen in ROBOTC, you’ve probably used nxtDisplayTextLine() or one of its many siblings.