Why macro for SafariURL not work with condition "ends with"

Why macro for SafariURL not work with condition "ends with"

I'm building macros for easy modification of dokuwiki pages and want to run macro only in "edit" mode, what in practice means that %SafariURL% is ended with do=edit
If I set condition ends with, it doesn't work, but if I set contain - works correctly.

I'm curious why?

If Then Else.kmactions (1.5 KB)

Could you "test" what it contains by adding a token inside your second Notification action, in order to display %SafariURL%. I highly recommend that you display %SafariURL% in parentheses within your notification so you can see if the are any trailing spaces.

So I've put curly braces around %SafariURL} and display it in window. No spaces and any other characters.

The obfuscated uri pasted here directly copied from display window

{https://.../dokuwiki/doku.php?id=trainings:vctl:db2:basic:install&do=edit}

I don't know why it's failing, but if you change the If/Then to Matches, you could use this:

^.*do=edit$

And that should work.

-rob.

Yes , I know regex very good, but using them to the string ending with character sequence seems to be exaggeration.

I was simply saying that you could use it as a way to test to make sure the concept works. If the regex fails, then there's something else going on with the token.

As for exaggeration or not, when I'm solving a problem, I use the tools available. If one doesn't work, but another one does, I'll use the other every time rather than try to figure out why the first one doesn't work—I just want my problem solved :).

-rob.

Oppps - sorry
I misunderstood you - I've treated your answer as proposal final solution not as path for diagnostic.

Excellent troubleshooting. It looks to me that the line doesn't end with "do=edit", rather it ends with "do=edit}" so all you have to do is add "}" to your string.

No - sorry!
My text in the macro was (for diagnosis):

{%SafariURL%}

so the curly brace in the end is from text in the macro. There is no any other character between end of URL and the curly brace.

I'm so stupid and embarrassed. Sorry. Let me re-think. (The whole purpose of me asking for those braces was to make sure we spotted the correct end of the string, and my braces fooled me!)

Hmm. Right now, it works for me, as you can see in this image:

image

So try doing what I did above (just paste both values into an IF action like shown above) and see if you get "true" or "false".

Another thing to try, for testing purposes, is to assign that string %SafariURL% into a variable first, then do your test on that variable. I'm not saying that's the final fix, it's just for diagnostic purposes.

Now it works!

I've checked variant with variable first - worked.
Next I once more put condition with text and %SafariURL% - also works.

So I've started thinking what was wrong - and added space after %SafariURL% - this time of course not work.
So probably I had space in the end of the text, but because space has the same background color as the rest of entry area, I didn't see that, but result of evaluation of course was false.

I'm not sure but there is no option to set different color for background of entered text than rest of entry area, so I have to be careful in modifying text fields.

Thanks a lot and sorry for this meaningless question/topic.

That's good news. Glad I played a small role in helping. Don't worry about this being "meaningless".

That would have been my first thought, but I just checked the If Then Else.kmactions you posted and there does not seem to be any spaces or other invisible characters in there.

At the moment your macro will run in any mode but (presumably) exit if not in edit mode.

If your DokuWiki behaves the same as the Playground you'll have a "pencil" character -- ✎ -- in the document's title, and therefore in the window name:

image

So you can put your macros in a Group that is only available when the focused window is a DokuWiki editor:

image

...and avoid the URL test altogether.

That doesn't work if you want to run the macro when in Edit mode but with another app/window frontmost, of course...

2 Likes

Wow!

Fantastic observation - I never noticed this pencil character :face_holding_back_tears: and I'm impressed. I use dokuwiki above 15 years!

Very good solution - much better than my current evaluations (two - because edition of section, not page, doesn't change the URL).

Thank you very much.

1 Like

BTW
I'm very "young" user of Mac, I've begun three years ago, coming here after using Unix/Linux above 25 years.

I bought KM after two hours of testing (YES :grin:) and first I had many problems to understand KM concepts. But now I have very big "internal pressure" to learn it and create new macros because KM directs me in so many different and new areas of using MacOS. It is fantastic! (BTW as programmer in C, Java, Python and other Unix languages I had also very hard start to understand how to write in Apple Script - it was terrible :sob:).

Thanks a lot to @peternlewis for KM and others for support here!

2 Likes