How do i refer to labels inside a table by index? (ie. in a loop instead of one by one)?

i wrote a simple number guessing game that works (using binary magic!) see attached aia. however i'm simply displaying the list of numbers as a simple list! i would like to populate a table of labels (by index) so i can simply loop over my list and set each corresponding labe's textl to the value of the list item - instead of coding 32 blocks.

did i define my table right? a verticalarrangement containing several horizontaarrangements? or should i have used a talbearrangement ( i didn't know how to use it)?

i can see the any component category but i do not see how to map the board (ie. table) to a list of numbers.


here's my aia
guesser.aia (7.4 KB)

this is what my screen1 looks like:

here's the whole program

this is how it looks now when i play it (lame)

Please post all your relevant blocks, not just an aia.

as snapshots of the blocks?

Rightclick on some white space in the block editor and choose Download Blocks as Image.

Don't use the table arrangement since it doesn't work as it should.

Did you make this game?

you wrote it too! it's the same concept but i show the selections one at a time so the pattern is not apparent.

1 Like

Search this board for Wordle in a Day.

1 Like

Also see:

1 Like

thanks for the link - it had a perfect example that i could adapt immediately.

your examples have additional extra's in them (ie. use of csv, html, highlighting) - thanks for the tips i've learned.

thanks to @ABG and @TIMAI2 , their tips enabled me to understand the concept and strategy how to index into tables of elements.

here's my final program
guesser.aia (7.4 KB)

it doesn't look so bare anymore:

If you're submitting this for grade, here are two things to tidy up ...

  • global variable inits should have values, to clear those yellow error flags in the blocks editor.
  • to return to screen1 from screen2, close screen2 instead of reopening screen1, which would eventually fill memory.

thank you.
here's the new version.
guesser.aia (7.5 KB)

another way to build guess list:


That's the other alternative i was contemplating - start with the binary notation for each number from 1 to 63, for each "card", select only those where the nth base-2 exponent is used in the representation of that number - ie. first get all numbers where 2^0 is used, then get all numbers where 2^1 is used, then 2^2, etc..

it's classic and it reflects the "magic" part of the trick!

thanks for the blocks. it's a pleasant alternative.

but i'm happy with what i got. someday, i'll rewrite it using this approach. next time i learn another block based language!

While we're on the subject, here's a photo of my magic number guessing deck I constructed when I was a kid. (Instructions were probably from scientific American). This prompted me to write this program in the first place. The magic of this deck was that it was self working! To use it, start with the cards in your hand in this order (1,2,4,8,16,32), if you find your number in the card, lay it on the table, face up, (over any earlier cards) with the side marked YES or NO on the top. After you're done, turn the deck over and voila- your number appears in a single tiny window, which resulted
from all the combinations of holes! It was amazing!

I'm posting 2 photos so you can see that the last (#32) has 2 faces ( ie. both sides have data). Only 6 cards are used in the trick.


This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.