Up for a challenge?

I’m fairly new to coda and recently decided to create a Bookmarks manager inside Coda.
But I soon realized that I bit off more than I could chew.

So I made this doc as a way to prompt you to help me, because if I manage to get these problems solved, I think I would be able to finish my project. This should be the hardest part.

I also plan on sharing the finished Bookmark Manager once it’s done for everyone to use and maybe we can then find ways to improve it together.

I am going to sleep now, so I’ll be able to read replies in about 8-9 hours.

Thank you in advance to everyone willing to help!

Hi @Fran_Vidicek ill have a look on it this evening if nobody checked this before (actually even if someone solved this !). I love the path you have in your project and how we could have participated in a few single bricks to help you achieve the whole final doc !

Keep in touch

1 Like

Ok, so I have 3 working buttons for the problem 1 but I’ll admit that I don’t understand what the Action 3 button is supposed to do :innocent:

To make it easier, I’ve also added a bunch of fields to Split() the various lists used :blush:
(So what’s going on in each button should be easier to read/understand :blush: )
I’ve also added specific columns to get the various results (So I could compare the results I got vs. the desired output while testing).
Those columns can of course be removed once the action formulas in each button have been adapted :blush:

Action 1

ModifyRows(
  thisRow,
  thisRow.[Result Action 1],
  thisRow.[Position to keep]
    .ForEach(
      thisRow.[Split Column 3].Nth(CurrentValue)
    )
)

As to a list of rows correspond a matching list of positions, using your field Values not in Column 1 and Column 2 I first determined the position of each Value not in Column 1 within the Column 2 which I’ve stored in the field Position to remove.
From there, I’ve added another field containing only the Position to keep of the rows in Column 2

So, the value returned by the Action 1 button is :

thisRow.[Position to keep]
    .ForEach(
      thisRow.[Split Column 3].Nth(CurrentValue)
    )

In other words, for each position to keep (stored as a CurrentValue) take the Nth() value in list of position for thisRow.[Split Column 3]

Action 2

ModifyRows(
  thisRow,
  thisRow.[Result Action 2],
  thisRow.[Position to keep]
    .ForEach(
      thisRow.[Split Column 2].Nth(CurrentValue)
    )
)

Same as previously but for the list of rows this time :blush:

As for Action 3

ModifyRows(
  thisRow,
  thisRow.[Result Action 3],
  ListCombine(
    thisRow.[Result Action 1].Nth(1),
    thisRow.[Result Action 1].Nth(2).RegexReplace("\d+",Position)
  )
)

I honestly don’t know if this is correct or not … Well, it gives the correct answer but I simply don’t understand what the button is really suppose to do :innocent: (so this might need adjustments)

Anyway, the value returned by the button is :

ListCombine(
    thisRow.[Result Action 1].Nth(1),
    thisRow.[Result Action 1].Nth(2).RegexReplace("\d+",Position)
  )

It just ListCombine() the first item in the list returned by the Action 1, as it seems that it should be untouched and for the second item, it replaces one or more digit(s) (\d+) by the number within your named canvas formula Position :blush:

Edit: Forgot to share the sample :sweat_smile:

1 Like

My bad, I have incorrectly named the buttons and their columns. It should have been like this:
image
Where each action is used for each step:

Step one = Action 1 (remove excess position spots)
Step 2 = Action 2 (Remove excess rows from column 2)
Step 3 = Action 3 (Change position value)

So in your doc it’s:
image

When it comes to Step 3 (action 3) This could have been missing:


There should be r22 in the text field.

So action 3 should find any amount of numbers that are after corresponding position spot of r22 (that happens to be 13) and change that number to 11.


I can’t believe I’m finally going to find out how this is solved😁

I’ve updated the sample :relaxed: and re-ordered the field so the results of each button appear next to it :blush:

I’ve also added buttons acting directly on Column 3, Column 2 and then Column 3 splitting what needs to be splitted and joining what needs to be joined afterwards :wink:

1 Like

Going above and beyond, thank you!

btw, column 9 and 10 are there by accident, I was trying to figure out the solutions myself and forgot to delete them.

This might need re-work and/or refinements to fit your actual use case but I think it’s a start :wink:

As always, no problem :wink: !

I can’t wait to see the final result :raised_hands: :grin: !

2 Likes

Yes, I will try to implement this today and see if it works.

1 Like

I have something for problem 2 but I might have overcomplicated the thing :sweat_smile: (I got lost somewhere I think :innocent: … or I’m simply a bit too tired :relaxed: )

I think I’m just not sure why you need to recreate a list using 2 columns when for the updated list of rows the value seem to be the same as the value within Column 1 …
I mean, for the example in the Problem 2 page, Column 1 is already what’s expected in Column 2 :thinking:

But lol, I re-created the list anyway :innocent: … It’s just a thought I had :blush:

So the first thing I did was to add a column to store the position of the each row in Column 2 and each row in the column Rows to add to column 2 relative to Column 1 (as they are supposed to follow that order) … That new column is called Position Column 2 + Row to add (relative to Column 1) (:sweat_smile: )

Action 1 : “Add” the rows to Column 2

ModifyRows(
  thisRow,
  thisRow.[Result - Column 2],
  ListCombine(
    thisRow.[Column 2].Split("/"),
    thisRow.[Rows to add to column 2].Split("/")
  ).WithName(
      C,
      Sequence(1, C.Count()).ForEach(
          C.Nth(thisRow.[Position Column 2 + Row to add (relative to Column 1)].Nth(CurrentValue
               )
            )
        )
    ).Join("/")
)

So, I ListCombine() the 2 field to somewhat “merge” and I give to that list the name C using WithName() and then in the expression part of WithName() we have this :

Sequence(1, C.Count()).ForEach(
       C.Nth(thisRow.[Position Column 2 + Row to add (relative to Column 1)].Nth(CurrentValue)
            )
        )

And what this does is : it first create a Sequence() (i.e.: a list) going from 1 to count of values in C (each value being stored as CurrentValue) and for each value in that sequence it will return the Nth() value in C with the appropriate position relative to Column 1

I’m sorry, I have no idea how to explain this clearly at the moment :sweat_smile:

But if I take your example and the very first CurrentValue in that ForEach() with the list in Position Column 2 + Row to add (relative to Column 1) being 1,3,2,4

Let’s say CurrentValue = 1C.Nth([Position relative to Column 1].Nth(1)) and as [Position relative to Column 1].Nth(1) is 1 the result of that 1st iteration is the first value in Cr1.

For CurrentValue = 2C.Nth([Position relative to Column 1].Nth(2))[Position relative to Column 1].Nth(2) = 3C.Nth(3)r444

Etc… (Sorry, I really can’t do better right now :pensive: )

As for Action 2, it follows the same principle but for the position this time :blush:

ModifyRows(
  thisRow,
  thisRow.[Result - Column 3],
  ListCombine(
    thisRow.[Column 3].Split("/"),
    thisRow.[Rows to add to column 2].Split("/").ForEach(CurrentValue.RegexReplace("r\d+", "p0"))
  ).WithName(D,
      Sequence(1,D.Count()).ForEach(
          D.Nth(thisRow.[Position Column 2 + Row to add (relative to Column 1)].Nth(CurrentValue))
        )
    ).Join("/")
)

Once again, this might need some adjustments :blush: … But I hope it helps a little :innocent: !

Edit: As the field Position Column 2 + Row to add (relative to Column 1) uses both Column 2 and Rows to add to column 2 as they are and the list is used in both buttons, this field would need to stay as it it until both rows and positions are fully updated :no_mouth:

1 Like

Hey Pch, I already managed to figure out how to to the problem 2, using what you showed my in the Problem 1.

I should have told you that sooner, so that you don’t spend unnecessary time on this. So apologies for that, however this is appreciated, I will look into it later, I see you used WithName() function so there will be something new to learn at least.

I implemented what I learned here into my Bookmarks Manger and it works fine so far, not quite finished yet so I might discover bugs later on when testing. But as I said, everything looks good :+1:.

2 Likes

No worries @Fran_Vidicek :smile: !

I didn’t take any of this as a waste of time, quite the contrary :wink:
It was a perfect brain teaser which helped to unwind after a rather long Saturday and allowed me to practice lists manipulations :grin: !

There’s absolutely no need to apologise :wink:

That’s awesome :raised_hands: ! Congratulations :tada: !

I’ll just wait patiently to see what you’ve done with all this :grin: !

1 Like