...the part where goals are supposed to be displayed in the ListView based on the role chosen. No roles whatsoever show up in that ListView, depsite there being goals in the DB under different roles.
The rest works great though. Hopefully, I will have some time tonight to analyze why your code works.
when Be_BackButton5_BackToMain Click do
open another screen screen screenname (BE_MENU)
initialize global roleTable to
create empty list
initialize global selectedRoleName to ""
initialize global myGoalsList to
create empty list
to GetRolesFromTinyFB do
initialize local roleList to
call TinyDB.GetValue
tag "roles"
valueIfTagNotThere
create empty list
in set global roleTable to
get roleList
to roleNames result
make new list from
call TinyDB.GetValue
tag "roles"
valueIfTagNotThere create empty list
mapping each role to
select list item
list get role
index 1
to goalNames goalTable result
make a new list from get goalTable
mapping each goal to
select list item list get goal
index 1
when BE_Role_Report Initialize do
set global roleTable to
call TinyDB.GetValue
tag "roles"
valueIfTagNotThere create empty list
set ListPicker1_RoleReport.Elements to
call roleNames
set global myGoalsList to
call TinyDB.GetValue
tag "myGoals"
valueIfTagNotThere create empty list
to GoalsWithRole roleName result
make new filtered list from
call TinyDB1. GetValue
tag "myGoals"
valueIfTagNotThere create empty list
keeping each goal passing
test =
select list item
list get goal
index
get roleName
to role roleName result
reduce
list
call TinyDB.GetValue
tag "roles"
valueIfTagNotThere create empty list
starting with initialAnswer create empty list
by combining currentRole and answersSoFar
if
=
select item
list get currentRole
index 1
then get currentRole
else get answersSoFar
when ListPicker1_RoleReport.AfterPicking do
set global selectedRoleName to ListPicker1_RoleReport.Selection
set Label_RoleSelected.Text to select list item
list call role
roleName ListPicker1_RoleReport.Selection
index 1
set Label_RoleReportVision.Text to select list item
list call role
roleName ListPicker1_RoleReport.Selection
index 2
set Label_RoleReportDOH.Text to select list item
list call role
roleName ListPicker1_RoleReport.Selection
index 3
set Label_RoleReport_Goals.Text to
call goalNames
call GoalsWithRole
roleName ListPicker1_RoleReport.Selection
(editted)
*this forum isn't preserving my identations.
Using the DoIt feature on AI companion for the first time.
Here are the results I am getting:
The problem seems to be with the "call goalNames" block.
The values are not being passed from the block where the goals are compiled into a reduced table to were the goals are being set to the ListView_RoleReport_Goals. I'm not sure why.
Working on it more now....(half an hour later.)
Ok, I think I got it.
when I DoItNow, on the "to GoalsWithRole roleName result" block, it gives me these outputs:
Do It Result: [["Run the Boston Marathon", "(Runner Run a marathon Run everyday)", "(this fall 2024-09-22 2024-12-21)", true]
["Do a gallery show", "(Artist make great art paint every day)", "(this summer 2024-06-22 2024-09-21)", true]
and so on...
I think what is happening is that it is looking at the second index of the myGoals table record, is looking for "runner" and instead of finding "runner", it is finding the entire concatenated name of the role, the "list of lists" as the entry is created in Screen 5; it is finding "Runner Run a marathon Run everyday" which is not exactly the same so it is turning up a false negative.
What do you think? Thanks in advance for your help.
Having CSV dumps of all related tables to inspect would make this clearer.
This, I think is the "dump" of what is stored in tinyDB for the relevant screens:
Do It Result: [["Run the Boston Marathon", "(Runner Run a marathon Run everyday)", "(this fall 2024-09-22 2024-12-21)", true], ["Do a gallery show", "(Artist make great art paint every day)", "(this summer 2024-06-22 2024-09-21)", true], ["test", "(Runner Run a marathon Run everyday)", "(this fall 2024-09-22 2024-12-21)", true], ["tour the Louvre", "(Artist make great art paint every day)", "(this fall 2024-09-22 2024-12-21)", false], ["run an ultrathin someday ", "(Runner Run a marathon Run everyday)", "(this fall 2024-09-22 2024-12-21)", true]]
Okay, I am working on Screen 5, where goals are saved along with their corresponding goals. At current, the block where a goal is saved (upon clicking the "add goal" button) looks like this:
The problems seems to be on this screen. I need to find a way to have the goal save the role just by the role name, not the entire concatenated record.
Just in case the problem was way back in Screen 3: Define a Role, which is the screen where roles are originally created, I did a DoItNow for when the button is clicked to create the role.
Here is the output:
Do It Result: [["Artist", "make great art", "paint every day"], ["Runner", "Run a marathon", "Run everyday"]]
As you can see, here the "records" of the "table" are not yet concatenated; as you'd you hope, they are still individual fields of the records. So there problem is not here I think.
I've been trying to fix this for two sessions now (I can only work on this on weekends for now).
Here is what I've been trying to do for Screen 05: Be_Goal and Big Rock Define.
Here's the top of my block where my variables are initialized and such:
Here is the screen initialization block:
This piece is new, in that we are trying to pull just the role name for the listpicker:
It is working: only the role's name appears in the role ListPicker.
Here are the blocks for when the "add role" gets clicked.
It know longer
a) successfully adds new roles to the goals ListView
b) successfully adds the old roles to goals ListView
However, I do believe the new goals are being add to the tinyDB, because I created a debugging notification:
...and it does show the values for the new goal added. Indeed, it even (correctly) shows the new goal with just the role name attached, not other (unwanted) fields.
Any advice any of you could provide to provide to get this working would be appreciated. I feel so close!
I've also created a notification debugger that tells us what exactly the ListView is trying to display:
This is the message it displays:
This tells me that
Insight 1: All of these are "old goals" in the sense that they were added to TinyDB a few weeks ago before we made some more radical changes to the code. None of these are "new goals" from the last 10 or so times I have attempted to add a goal since we started with this newer code.
Insight 2: The ListView is "pulling" from the Database just goal names, probably because of this code:
list ListView_myGoals.Elements
item select list item
list goal
index 1
Ideally, the ListViewer should be showing 1) goal name 2) name of the role it is associated with, 3) the name of the timeframe it is associated with 3) and whether or not is a big rock.
To be sure, in the DB, the goal should NOT be saved as a concatenated list of these values. Each value should be separate because we need to pull that apart elsewhere in the code. But the listViewer should be displaying the 4 fields.
Why is it that new goals are being added to the DB (as proven by our first test with the first debug notifier) but this is not being pulled by the ListView.
The ListPicker is indeed pulling from the database but...is it pulling from the right place, the right list? Is myGoalsList the right list to pull from? It should be because that is the variable/list that we are populating upon .click.
That's a problem with ListViews.
They don't have events like List Pickers where you can load their Elements from TinyDB before displaying their Elements.
If you love your ListViews, you must initiate an update regimen for them, and follow it faithfully in your coding of updates to their underlying data.
Typically, this is done by writing update (setter/getter) procedures with sole responsibility for those updates and the refreshing of associated display elements, and putting the setter/getter procedures in sole charge of updating that data. (No more direct global table or TinyDB updates.)
i) ABG: "They don't have events like List Pickers where you can load their Elements from TinyDB before displaying their Elements."
does this mean that we can't program the ListPicker to set its elements within a when.click-do block? In other words, is this block:
...is ineffective?
ABG: "If you love your ListViews, you must initiate an update regimen for them, and follow it faithfully in your coding of updates to their underlying data."
So, I can expect for the DB to be appropriately updated, but there to sometimes be a "lag" with how the ListView updates?
Is this issue a typical thing in programming? I am using App Inventor to learn algorithms to become a better programmer in general. Can I expect to come across this program elsewhere?
ABG: "you must initiate an update regimen for them". How does one do this? "Typically, this is done by writing update (setter/getter) procedures with sole responsibility for those updates and the refreshing of associated display elements, and putting the setter/getter procedures in sole charge of updating that data. (No more direct global table or TinyDB updates.)"
Hmmm, this explanation is "above my current paygrade". But I gather from this that we can't solve our current problem by using a global table. Perhaps some local variable?
The List Picker's Elements are filtered just In Time before its pop up happens.
The List View's elements are updated within the ListView's Selected event and on initial screen load.
They both had to be programmed, nothing is tied to any database for a free update like in some other introductory all-in-one environments like MS Access.