# Make this code simpler anyway

In screen 5, 7, 8, and 10
Indonesia_Archer_Scoring.aia (2.3 MB)

Can anyone make this code simpler?

For starters, your Screens are basically the same screen, with different numbers of rows and columns:

You also made the mistake of using Table Arrangements instead of nested Horizontal and Vertical Arrangements, opening up your project to corruption because of bugs in the Table Arrangement component, and missing out on the opportunity to take advantage of how Horizontal and Vertical Arrangements can accommodate when some of their enclosed components switch between Visible and Invisible.

I suggest you study the code in Wordle In A Day (the full thread) to see how to use lists of components, the Any (generic) blocks, and loops over components in a list.

Regarding the specific problem of calculating subtotals and running totals over a table of scores, here is a suggestion for how to store the dependencies of which text boxes' numbers should affect which total and subtotal textbox
(I suggest using inactive textboxes instead of Labels, so the same code can be used to add subtotals into totals as used to add scores into subtotals) ...

Make a global init table with 2 columns:

• text box component that will hold a score from the right side of your display
• inactive textbox component that will be affected by changes in this score textbox

So this table would have a row for each score textbox sending (adding) its score into the subtotal textbox for that row, and each subtotal textbox would have a row sending its value into the running total textbox on that row and below it.

This table is not for display. It's only to support the loops over this table to calculate and fill in totals after a score is entered.

You could do it in two or three passes:

• zero out each subtotal and total textbox
• add each score to its row subtotal
• add each subtotal to the running totals of that row and below.
1 Like

You could also remove ALL of your "OR" blocks by using the upcase text block to handle "X" & "x".

1 Like