Saving two properties of an object to an array in an variable

Screenshot 2021-08-09 at 14.34.36

This sounds definitely like what I am looking for, but I’m not sure how I can save the Text and Date as separate properties if I do it this way. I want to be able to pick these up in the “start-up block” later:
ex:

I actually started my thinking-process with an idea like this from the beginning but ended up with the object-idea cause of this issue. Wouldn’t I need to create some kind of properties for these fields somewhere?

1 Like

You can manage it this way
image

I don’t mean to enter the vales when initializing but this can present what I mean better.
The first entry in the “myList” is another list with 2 entries (Text and Date). The other entries in “myList” are the normal entries for the app.

You can access them this way

This is the output
image

Hi and thanks for your help in this.
I have tried the above solution in many different ways but I can’t get it work. And for some reason this method above just doesn’t “klick” in my brain. I can’t get it in…

So… I tried the other method to use Screenshot 2021-08-10 at 09.24.11
That I have better understanding in at least, and I get very close, but now the issue is that for every time I click I get the list PLUS the latest item. That means that the list gets duplicated every time I klick, but for each time there will be a new item at the end.
So, if I add “a|+Date” I will get “a|Date”, When add “B|+Date” I will get "a|Date + “b|Date” and the previous item are still there, so that will give me a|Date+a|Date+b|Date…
I can’t figure out how to come around this…
Any tips?
Thanks!

1 Like

Hi

Can anyone help me with some advice in how I can come around the issue named above…?
I am stuck here. I have tried like a million different methods but nothing gives me what I want. The method above is the closest so far, but I understand that I am saving a list, and that gives me a new list for every time I am pushing the button, plus the new item for every time. But I haven’t come up with any other solution that doesn’t give me Null or some other problem…
So, what I want is to get that object within that variable “myList” to a list which I can see as text separated with “,” in my label. For every time I click I want to see what’s already in that list + the new added item. All this is to be able to control that my variable “myTempList” indeed are containing everything I have added into this list.
Simply said: When I create a new row in my DVL I also want that to a variable, with info from the two fields.

Thanks a lot for any advice! (this is fun but my brain starts to get really wrinkly now :grin:)

1 Like

Is there a reason that you need the information in a list rather than just in the data source? Why not just retrieve the data from the data source when you need it instead of trying to build your own data source within a list as you’ve struggled with above.

Are you needing to create app variable myList and app variable myTempList because you want to display different information than what’s in the N.A.O data source? Because if not, I’d forego using lists and just keep everything simple and use data source blocks for that.

You did mention this above:

A Data Viewer List (DVL) syncs to a data source, not to a list. So no, you don’t have to have a list. In fact, if you use a list then you have to convert everything from the list to the data source… which is just extra work!

1 Like

Hi tatiang
Thanks for your answer. No there are no other reason then newbie-acts :blush:
Of course, now when you say it, I do know about the data source for the DVL, just didn’t think about that.

I will re-think the whole and hopefully things will fall in place. Otherwise I’ll come back, thanks! (Sometimes you need someone to ask these kind of questions to wake up)
I’ll have a look later tonight… :+1:

2 Likes

I just wanted to share…
I got inspired and tried out this, and it seem to work. Now it does what I want (so far anyway) :slightly_smiling_face:
It may not be the best and most clever way to do it, but at least it shows all my entries in my variable.
Thanks again to both you and Muneer! You guys are awesome! :+1:t3:


2 Likes

Hi

May I ask, I get this to work fine, but the info in my variable will get wiped out after relaunch the app.
My entries are still in the DVL but my variable are now empty.
How can I do to make it stay in my variable even after relaunch?

I was thinking of something similar to what I am doing in this working block above but put it in the start-up plock. But then I don’t understand what to put in the “for row ID” block…

I also tried this solution but it will not display the data as “Text|Date,” it will display firs all Text, then all Dates…

Any tips?
Thanks!

1 Like

You need something like this

Hi. Yes this works perfectly! Thanks! May I ask, what is really the different between "count with I from 1 to 1 by 1, and for each item J in list? It feels I would also be able to use “for each item J in list” and put the “number of rows test in Table 1” as the list there? But I do for fact know it won’t work as I have tried, and it didn’t work, but why? What is the different?

1 Like

There are a few differences between those loops:

Count with i from 1 to 10 by 1
. loops through values by 1 or another multiple (e.g. count from 10 to 100 by 10)
. . The variable i cycles through integers: i=1, i=2, i=3, etc.
. best when needing an index/count

For each item j in list
. loops through each list item
. . The variable j cycles through items: j=[first list item], j=[second list item], j=[third list item], etc.
. best when looping through a list

But yes, to some extent, you can use them interchangeably.

However, your example of putting number of rows in test in Table 1 as a list value won’t work. That block returns an integer, not a list. For example, if your test column contained 15 rows, you would be asking the loop to cycle through each item in 15. That makes no sense. Lists are a particular kind of variable in Thunkable and when they are required such as in the for each item j in list block, you have to use a list, not something else.

A list (aka array) is like a set of numbers that you probably learned about in math class: {1, 2, 3} or {5, 8, 22}. So it makes sense to loop through a list because each value is a separate item. A list can hold all sorts of things including text strings: {“red”, “orange”, “purple”}. That’s what makes the for each item j in list block powerful. Because as you loop through the list, the variable j holds the value of that item. In the list {"red, “orange”, “purple”}, the second time through the loop, j=“orange”.

1 Like

For this specific case, this should work

Thanks. Yes it does. And the reason this works is that when I use “ID” I get the complete row? With all active columns in it? Instead of pick just one column (which was what I tried earlier before getting this up here…)

It doesn’t matter for me which method I use. Both works so fine, I just want to understand.

Thanks!

1 Like

The list of values block is explained in the documentation. It returns the data from a column as a list. The reason @muneer is using the ID field from the data source is that that’s a special field that contains the row ID for each row of the data source.

So in this case, that block will return a list of row IDs. And since you’re looping through it with the for each item j in list block, each iteration/cycle through the loop, the j variable will have a different row ID value that refers to a unique row in your data source.

2 Likes

even variables can work

1 Like

Thanks a lot for all your feedback in this! It’s so much appreciated, really! Thanks

This code shouldn’t work and could cause crashes in some phones unless your list has lists as elements.

1 Like

Dear @andreas.sjdtomypv
I notice that you open a lot of posts but never close any of them. To help others who would come across a similar issue it is better to mark the post [SOLVED] or select one of the replies as [SOLUTION]. Other users will benefit from this.

Now, it looks like all the issues you posted here are remained unsolved.

I would really appreciate if you start closing the posts that you got answer to.

Oh sorry, where and how do I do that? Of course I will! I would say most of them are solved. I will take a look at that right away!

2 Likes

I don’t know that list property divides text into pieces like

  • T

  • E

  • X

  • T
    even though list viewer is a list property, it always shows this:

  • T

  • E

  • X

  • T
    like you told data to DVL, you can you this property
    Screenshot 2021-08-20 123305
    like @munner said, no need of variables. j and i which are numerical variables count on number of rows on the DVL

this can be

j and i which are numerical variables count on number of rows on the DVL

as well as app variable data which data reflected from the DVL is
Screenshot 2021-08-20 124656
this is the reason for

means your technical idea can solve it


sense, that could work. but my problem is… if that problem occurred, please report