2017년 7월 15일 토요일

List Changing Without Me Telling It To — Perhaps Bug?


I have two variables.  The first is a list of the names of images (horse, cat, dog, etc.).  The second is a list of the images' urls, in the same order (horse image url, cat image url, dog image url, etc.).  Both lists do not have duplicates.  Both variables are set to the lists (the lists are from a file) when the screen initializes.  They are not changed (set) in the code anywhere after that.

I'm using an adaption of Tim Carter's image listview solution, here, 3rd post from the last.
My program (app) is set up with 2 listviews.  One listview contains the names of images that are not being supposed to be displayed in the webviewer.  The second listview contains the names of images that are supposed to be displayed in the webviewer.  When you select an item from one listview, it goes to the other.  As I said before there are no duplicates.

And, as I also said before, the lists are not changed (set) in the code anywhere after they are set in the screen's initialize handler.
But the image names list, is being changed.  Mysteriously, it just so happens that it is always the first listview's elements.

In the initialize handler, the first listview's elements block is set to the first variable (the image names variable).  Perhaps that is the problem?  Because of that, the first variable (image names variable) is (probably) always being set to the first listview's elements whenever the first listview is changed.

Is this common?  Did I do something wrong?




--
Your removal is premature.

In each of the list picker selection events, reverse the order of
the remove and add blocks.

Also, when your file arrives, it's good practice to 
clear out the lists you are loading before you start adding to them.
That makes it possible for you to rerun that code if you need to debug it,
without extra copies piling up in the lists you are loading.

I generally avoid operating directly on my picker elements lists,
instead working on a global list backing that picker, and
then doing a total refresh of the Elements from that global list.
I vaguely remember fixing flakey behavior with that technique.

--
Also,  for your removal by picker blocks, the SelectionIndex block
is more appropriate for the removal operation.

Taking the Selection and then going back to look up its position
is redundant.

Also, if there are duplicate values in the Elements list,
you might pick the wrong one if you go by value instead
of by position.

--
Thank you so much!  I will commence upon this endeavor!

My listpickers have search enabled, so SelectionIndex won't work...

--
Hmm.  I did all that, and it's still... well, flaky.  The list of image names is still always the elements in the add list...






--
 The list of image names is still always the elements in the add list...
Does either List Picker have values in its Designer ElementsFromString ?
Maybe that's overriding Elements?

--
Very possibly...  This is totally silly, but I can't find ElementsFromString value block, even with a search.

--
Sorry, that's a List Picker feature and you are using a List View?

--
I'm using a list picker, but I don't see it (image attached).



--
No, they both have it in the Designer, second attribute in the alphabetical list.

--
Oh, there!  Both are empty.

--
The blocks look reasonable.

Maybe you should show us before and after screen shots of the live app,
interspersed with commentary on what you did and how the results differed from what you were expecting,

along with current blocks image and .aia export?

--
Okay.  First item attached is the image of all the blocks.

So, I did the other thing.  Sorry this commentary text is very long, but I was recording my e-v-e-r-y move.  Will include screenshots in 2nd post in a few minutes (once I get them from my phone).
    1.    Clicked Reset.  Clicked Al Companion.  Scanned in code.  Connected with code.
    2.    Took screenshot.
    3.    Clicked "Remove Image".
    4.    Took screenshot.
    5.    Pressed back button on phone.
    6.    Pressed "Add Image".
    7.    Took screenshot.
    8.    Chose "horse".
    9.    Took screenshots
    10.    Clicked "Okay".
    11.    Took screenshot.
    12.    Clicked "Okay".
    13.    Took screenshot.
    14.    Clicked "Okay".
    15.    Took screenshot.
    16.    Clicked "Remove Image".
    17.    Took screenshot.
    18.    Pressed back button on phone.  Oops, shouldn't have.
    19.    Clicked "Remove Image".
    20.    Selected "horse".
    21.    Took screenshot.
    22.    Clicked "Okay".
    23.    Took screenshot.
    24.    Clicked "Okay".
    25.    Took screenshot.
    26.    Clicked "Okay".
    27.    Clicked "Add Image".  "horse" is now at the end.
    28.    Selected "mare and foal".
    29.    Took screenshot.
    30.    Clicked "Okay".
    31.    Took screenshot.
    32.    Clicked "Okay".
    33.    Clicked "Remove Image".
    34.    Took screenshot.
    35.    Pressed back button on phone.
    36.    Clicked "Add Image".
    37.    Took screenshot.
    38.    Selected "cat".
    39.    Took screenshot.
    40.    Clicked "Okay".
    41.    Took screenshot.
    42.    Clicked "Okay".
    43.    All alerts gone.  Must have forgotten to type "Clicked 'Okay'" one of those times.  Pretty sure there I clicked Okay 3 times in total.
    44.    Clicked "Remove Image".
    45.    Took screenshot.
    46.    Pressed back button on phone.
    47.    Clicked "Add Image".
    48.    Took screenshot.
    49.    Clicked "horse".
    50.    Took screenshot.
    51.    Clicked "Okay".
    52.    Took screenshot.
    53.    Clicked "Okay".
    54.    Took screenshot.
    55.    Clicked "Okay".
    56.    Clicked "Remove Images".
    57.    Took screenshot.
    58.    Pressed back button on phone.
    59.    Clicked "Add Image".
    60.    Accidentally rotated phone as took screenshot.
    61.    Phone back vertical.
    62.    Clicked "dog".
    63.    Took screenshot.
    64.    Clicked "Okay".
    65.    Took screenshot.
    66.    Clicked "Okay".
    67.    Took screenshot.
    68.    Took another screenshot by accident I think.
    69.    Clicked "Okay".
    70.    Accidentally rotated phone as took screenshot.
    71.    Phone back vertical.
    72.    Clicked "Add Image".
    73.    Took screenshot.
    74.    Pressed back button on phone.
    75.    Clicked "Remove Image".
    76.    Took screenshot.
    77.    Selected "horse".
    78.    Took screenshot.
    79.    Clicked "Okay".
    80.    Took screenshot.
    81.    Clicked "Okay".
    82.    Took screenshot.
    83.    Clicked "Okay".
    84.    Clicked "Add Image".
    85.    Took screenshot.  Did NOT select.
    86.    Pressed back button on phone.
    87.    Clicked "Remove Image".
    88.    Took screenshot.








--
Sorry it took me so long you get you the screenshots.  Had a bit of technical fanangling, but here they are.  Let's just hope they're in the right order.  If they're not, I'll go through them one by one and straighten things out.







































--
Also need interspersed with commentary on what you did and how the results differed from what you were expecting,

--
I'll be away for a day or two, so I throw this post to any one who can figure it out.

--
I expect the global variables imageUrls and imageNames to not change after they are set in the GotText handler.
Evidentally, though, imageNames does change.  Its value is shown in the 2nd notification message displayed when the refreshPickers function is called.

--
If you're going somewhere pleasant, have a good time!  If not, good luck!
--
If you wish, post an .aia. I am not good at debugging pictures.

--
Sorry I forgot to include that.  It is attached.  Thanks!

ImageView.aia

--
This is a classic mistake: you did "set global addPickerElements to get global imageNames", while you should have dome:
"set global addPickerElements to copy list list get global imageNames".
The reason is that the gloabl variables are merely pointers to the list, so if you change the list in one place, it will affect the other too.
By making a copy, each variable points to, well, its own copy.
Change this and all (for at least this part) will be fine.

By the way, I did not see any images appear. Another question, how does ClearCaches help?


--
Just one tiny tiny block and one barely audible click and it's fixed!!!  I had no idea what copy list did.  Thank you so much!!!

Hmm.  I do not see any images either.  Oh, yeah!  Now I remember.  I didn't feed the web viewer anything in its webViewString.  I'll change that now.


--

댓글 없음:

댓글 쓰기