Local variables or constants (a la Hypercard)?

Anybody remember Hypercard? Ahhh, first love…

Anyhow, if I recall correctly, Hypercard gave you the ability to define local and global variables. The local variable type was specific to the card it was one, while the global variable applied across all cards. Translating to Coda-ese, I’m wondering if there are section-specific variables as opposed to variables which apply across the entire document.

My use case: I have a table of projects, where each project is a row. I want to have a section in my document for each project. On that section, I use formulas to dynamically insert data from columns (from both the base table and related tables). The only thing that differentiates the formula for the Project A section from the formula on the Project B section is the value of Nth(). On Project A section, the formula includes “Nth(1)” and on Project B section the formula includes “Nth(2),” etc.

Right now, I have to manually change every formula on every section, and do the same for new section. What I would like to do is use a local variable (or even a constant) from the page, as in Nth(thisPage). I would set the value for each page manually, but I wouldn’t have to change the formulas from page to page.

Anybody have an idea of how this could be done?

Thanks,
John

1 Like

Hi John

Unfortunately at the moment there is no better option compared to what you are doing. If you have multiple sections, one for each project that all look similar and the only difference is that they display different projects, then at the moment you need to update all the formulas in the section.

Several other customers and we ourselves have run into this issue and are considering how to address this. Few of the options that we think might help are

  1. When copy/pasting content, if the content includes controls (like select list etc) and formulas/tables, re-write all formulas in the content that point to existing controls to point to new controls that are created as part of copy/paste. With this approach you would be able to create a select list on the section to control the project for that section. This would be closest to the constant approach you described. The copy/paste would work across documents as well so.

  2. Add support for scoped variables in a manner similar to what you described. The main behavioral aspect we will need to add support for over here is a mechanism to allow users to refer to global scoped variables with the same name vs local.

In your opinion which of these would you prefer?

Thanks
Himanshu

1 Like

Hi Himanshu,

Thanks for your generous response. The two options you describe both have merits. The first one seems simpler, especially for users without any database or coding background. It is very intuitive if you copy/paste the control and the formulas that reference it at the same time (as in my use case).

But I think I would prefer the second approach, personally, for two reasons. First, because it forces me to be explicit about the expected behavior when I write the formula (or when I set up the control, depending on your implementation). Second, it probably applies to a broader set of use cases.

In any case, thank you for thinking about this. Loving Coda so far and excited for the future!

John

4 Likes

Thanks for your feedback John. Definitely keep it coming!

We will keep your input in mind as we work on handling for these use cases. You are right, both of these options could be used, and option 2 provide more power and is probably applicable to more options, but at the same time is a bit more involved.

What are your thoughts on both the options can co-existing. So simpler scenarios could benefit from copy-paste and more involved scenarios could benefit from the second approach.

1 Like

Both is better! But I think it will need to be well documented.

1 Like

Hey guys, I am in need on pretty much the same thing. And I am pushing this up a bit, if you are ok. Maybe you have updated your roadmap since then :slight_smile:
Here is my use case:
I am working on a CRM based on one of the template I found, with user dashboards (with one user per page) that include a few buttons and tables view that I want to filter. All of these of course would depend on the user that the page is for.
So in my page I just want to see my contacts, my todos, etc.
I have added a select list on top with the team member.
So when I copy paste this on a new page, I have to change the name of the control.

Any way to have a local control name? Maybe in the future?

Hi Utku

We are working on an improved copy/paste experience that should hopefully help with your scenario. We will start rolling it an initial version to users you would like to try it out and provide feedback. If you are interested we can include you in that rollout.

Thanks
Himanshu

Sure!
I am not sure a better copy paste is exactly what I meant though :slight_smile:
But I understand that this idea of local variables can make it more complex for many users. Anyway, let’s try this improved copy/paste :wink:

1 Like