Getting timeSincePress into a table

Hi -
I think I need a clever solution. I want to create a table that is pressCount in one column and timeSincePress in another. I’d do it as below, but cellContent won’t take variables as inputs. I may be missing something obvious – any help would be appreciated! Thanks.

a1=click.pressCount
cellContent(a1,1): “{click.pressCount}" cellContent(a1,2): "{click.timeSincePress()}”

Is this what you have in mind? I’m new to cl myself but I thought I could tackle this one (with a lot of c&p from the examples, lol). :slight_smile:
https://teacher.desmos.com/activitybuilder/custom/5f1defbf1ad2086c61e88d3a

2 Likes

Just for anyone else in general, (unless it’s changed) cellContent() doesn’t accept variables. You always have to enter a specific row and column so cellContent(a1,1) doesn’t make sense to the program.

1 Like

Thanks! However – what I’m struggling with is keeping the data. So it’s a table with multiple rows.
Column one is the number of the click, column two is the number of the last click.
My 1984 programming brain is having trouble figuring out how to store the old data. Once I get a value for, say, click 1, how do I store it in a variable or a table so that it doesn’t change? What’s new to me is the way CL recalculates everything all the time, so if I say a1=button.timeSincePress(), I need to somehow NOT have it do that for a1 next time, but for a2 instead. I only need about 6 presses, so I can do them individually. Here’s the kind of table I mean:
Screen Shot 2020-07-26 at 5.40.51 PM

Thanks!

Thanks, Daniel. I saw that in a previous post of yours from a while ago – saved me some frustration! (Would be nice if it worked, though.)

Just discovered lastValue – I think I can make this work!

1 Like

I figured it was more complicated than that… lol! Please report back if you work it out. I’ve been sitting here fiddling with it, and I haven’t managed to make it work yet. (I should be doing other things, but I enjoy these puzzles, lol!) :smiley:

I did kind of figure it out. Not sure I completely understand what I’ve done. Here’s a link:

It’s meant to gather data about reading speed. Essentially, it captures the last timeSincePress and stores the new one.

I don’t quite get the difference between Capture(“a1”) and a1=. . More investigation needed.

It will help to see what’s going on if you delete the hide commands in my different components.
Thanks for helping – let me know if you have any further insights!

Oops… I think you did not publish the finished version. That link is going to a basically “blank” activity. (This took me some time to figure out too, lol… if editing a draft, until you click “publish”, none of the changes are pushed to any shared version).

Sorry about that. This should work. I added an intro description with a little explanation.

1 Like

This is really great! I don’t fully understand all the “capture” code and how it works. These are the things I want to get better at! Thanks for sharing! I’m going to save a copy to refer to when perhaps I can understand it better, lol.

So, you actually did more than you needed to. a1 is a variable that, depending on how you define it, can change. capture(“a1”) creates a list of values for each time the button is pressed. You alternatively could’ve done this:

capture("time"): this.timeSincePress()
L=this.history("time")
a1=L.elementAt(1)
a2=L.elementAt(2)
etc...

Note: I’m using “this” to reference the current component instead of “click”, and I created “L” so I didn’t have to keep using “this.history(“time”).elementAt(#)”

1 Like

I thought I was doing too much. Thanks again – your explanation is clear and concise too.