Question from "Test the Whiskers"

Hello,
I am following a series of tutorials by Parallax to program my Activitybot. In the Test the Whiskers tutorial there is the following assignment:

Write a for loop with a print call that uses CRSRXY to create this output:

Whisker-your-turn.png

I would really appreciate help with what the code should look like, I am a little stuck. Thanks!
431 x 312 - 24K

Comments

  • Which part don't you understand?

    How to write a FOR/NEXT loop? On page 21, Go to the StartSimple tutorial and try the programming examples, then come back here when you are done.

    How to use print? Look at the previous project.

    how to use CRSRXY? Study the table on the previous page and look at the example.
  • Which part don't you understand?

    How to write a FOR/NEXT loop? On page 21, Go to the StartSimple tutorial and try the programming examples, then come back here when you are done.

    How to use print? Look at the previous project.

    how to use CRSRXY? Study the table on the previous page and look at the example.

    Thanks for the response. I think I understand how to use a for loop, a print command, and CRSRXY. What's stumping me is how to combine the components to display the numbers as shown in the picture.

  • Think of the screen as an X-Y grid. Observe that the characters are sort of in a diagonal line with a slope of 1. You will have two print statements inside the loop; one to set the cursor X, Y and one to print a single character (1...9).
  • Think of the screen as an X-Y grid. Observe that the characters are sort of in a diagonal line with a slope of 1. You will have two print statements inside the loop; one to set the cursor X, Y and one to print a single character (1...9).

    Will do. Thanks!
  • parkerparkour,

    I would start with the "Try This" example and make changes to it.
    As Tom pointed out, what do you notice about the positions for each line? How are they related?
    Also, do you see a pattern between the positions and the printed line number?

    The upper-left corner of the screen is position 0,0 and increasing values move the cursor towards the lower-right corner.
  • Genetix wrote: »
    parkerparkour,

    I would start with the "Try This" example and make changes to it.
    As Tom pointed out, what do you notice about the positions for each line? How are they related?
    Also, do you see a pattern between the positions and the printed line number?

    The upper-left corner of the screen is position 0,0 and increasing values move the cursor towards the lower-right corner.

    Great. Thanks.
  • Genetix wrote: »
    parkerparkour,

    I would start with the "Try This" example and make changes to it.
    As Tom pointed out, what do you notice about the positions for each line? How are they related?
    Also, do you see a pattern between the positions and the printed line number?

    The upper-left corner of the screen is position 0,0 and increasing values move the cursor towards the lower-right corner.

    I tried this (see photo) and did not get the right result. I know I am missing something, most likely with the cursor positioning. Any ideas? Thanks!
    screenshot for loop.png
    1366 x 768 - 129K
  • Genetix wrote: »
    parkerparkour,

    I would start with the "Try This" example and make changes to it.
    As Tom pointed out, what do you notice about the positions for each line? How are they related?
    Also, do you see a pattern between the positions and the printed line number?

    The upper-left corner of the screen is position 0,0 and increasing values move the cursor towards the lower-right corner.

    I tried this (see photo) and did not get the right result. I know I am missing something, most likely with the cursor positioning. Any ideas? Thanks!
    screenshot for loop.png

    To match the screen shot in the first post you want to position the cursor at column 0, row 1 (remember the upper right corner is 0,0) and print the number 1.

    Next you want to position the cursor at column 1, row 2 and print 2. Repeat for numbers up to and including 9.

    What you program in the last post is doing is print 1 in column 0, row 0.
    Then position the cursor in column 1, row 1 and print n. Each value of n (1 through 9) prints at 1,1 overwriting the previous number. You need to fix the arguments of the cursor positioning function.

    I would also print n after positioning the cursor (move the n print statement below the cursor statement.

    Give it a try, and if you still have problems let us know.

    Tom


  • parkerparkour,

    Very good job but you forgot something.

    Look at the position values in the second print statement.
  • Genetix wrote: »
    parkerparkour,

    Very good job but you forgot something.

    Look at the position values in the second print statement.

    I fixed the position values and it worked. Thanks for the help!
  • twm47099 wrote: »
    Genetix wrote: »
    parkerparkour,

    I would start with the "Try This" example and make changes to it.
    As Tom pointed out, what do you notice about the positions for each line? How are they related?
    Also, do you see a pattern between the positions and the printed line number?

    The upper-left corner of the screen is position 0,0 and increasing values move the cursor towards the lower-right corner.

    I tried this (see photo) and did not get the right result. I know I am missing something, most likely with the cursor positioning. Any ideas? Thanks!
    screenshot for loop.png

    To match the screen shot in the first post you want to position the cursor at column 0, row 1 (remember the upper right corner is 0,0) and print the number 1.

    Next you want to position the cursor at column 1, row 2 and print 2. Repeat for numbers up to and including 9.

    What you program in the last post is doing is print 1 in column 0, row 0.
    Then position the cursor in column 1, row 1 and print n. Each value of n (1 through 9) prints at 1,1 overwriting the previous number. You need to fix the arguments of the cursor positioning function.

    I would also print n after positioning the cursor (move the n print statement below the cursor statement.

    Give it a try, and if you still have problems let us know.

    Tom


    It worked. Thanks!
Sign In or Register to comment.