Skip to first unread message

John Bradford

unread,
Mar 3, 2018, 1:41:42 PM3/3/18
to MIT App Inventor Forum
Hi all, getting an error I don't quite understand enough to figure out the resolution.

I'm building a multi-choice questionnaire. There will be some questions (in rows, currently 6 per page) with 5 options per question (in columns). I'm using checkboxes to select options for each row. I started out hard coding for each checkbox which worked, but was very messy, so decided to try and do everything in a procedure loop that could be called by each checkbox passing the row / column reference.


I create a list of lists for the checkbox components, each row is a list of the checkboxes in columns

Then each checkbox gets a simple call when it's state changes

What should then happen is that the code looks up the relevant checkbox component from the list-of-lists, and proceeds based on whether or not it is checked

Not sure if that image is readable, so the first 'line' reads:
If Checkbox.Checked of component (select list item from list "globalCheckBoxComponents", index (select list item from list (get row, index (get column))))

And it throws the following error:

Which I assume means I can't use "Select List Item" Index to reference a list within a list. but then I'm not sure how to reference them?

I also tried loading the list of checkboxes into a local list so I was only navigating one layer deep:


And yeah, that didn't work either - but gave a *much* bigger error. So really didn't work!



Any thoughts?

Taifun

unread,
Mar 3, 2018, 2:47:00 PM3/3/18
to MIT App Inventor Forum
use 2 nested select list item blocks to get the value like this

select list item select list item get global checkboxComponents
                                                get row
                        get column



you might want to use Do it to debug your blocks, see tip 4 here https://puravidaapps.com/learn.php

Taifun

Trying to push the limits of App Inventor! Snippets, Tutorials and Extensions from Pura Vida Apps by Taifun. 

Abraham Getzler

unread,
Mar 3, 2018, 6:59:52 PM3/3/18
to MIT App Inventor Forum
This is similar to a radio button, which is a group of buttons,
but you have added an extra dimension of a lot of them.



to avoid burying yourself in components.

abg

SteveJG

unread,
Mar 3, 2018, 7:12:48 PM3/3/18
to MIT App Inventor Forum
Here is a link to making 'Radio Buttons' from CheckBoxes (which ABG believes is similar to your coding problem.)  https://groups.google.com/forum/#!searchin/mitappinventortest/radio/mitappinventortest/i4MJIXFIWoA/5ac6_9AVz5EJ   If only one answer is correct in your 'quiz' then you could add two checkboxes to this example for each row and use similar coding.  This will prevent anyone from checking more than one box in a row.  It may not solve other issues.

Regards,
Steve

John Bradford

unread,
Mar 4, 2018, 8:39:24 AM3/4/18
to MIT App Inventor Forum
Thanks for the comments.

Tried re-organising @Taifun it produced a different error, so might be making progress....


Steve / ABG - ensuring only one check box is selected isn't the issue. It's being able to select a checkbox from a list of lists. It seems to be something to do with passing arguments through the select list item. Will take a look at the examples and see if that works.

thanks

Taifun

unread,
Mar 4, 2018, 10:00:17 AM3/4/18
to MIT App Inventor Forum

Taifun

John Bradford

unread,
Mar 4, 2018, 10:15:37 AM3/4/18
to MIT App Inventor Forum
Doh! And solution found!

Many thanks Taifun.

The final error was that when I cycled through the "row" list of checkboxes, I was actually returning the component, not it's column number. So introduced a local index "localBox" and everything worked perfectly.

Many thanks!


Reply all
Reply to author
Forward
0 new messages