Macro with ext. Link

87 views
Skip to first unread message

tobaisch

unread,
Jan 6, 2018, 12:42:15 AM1/6/18
to tiddl...@googlegroups.com
I would like to make a macro for a link to a website on every tiddler.
Onyl the ID on the end of the website is changing.
e.g.:
www.verylongdomain.com/id1234567545
The prefix of the website is very long and should therefore be fix integrated into the macro.
The variable and authoritative ID at the bottom of the page is in the field: "webid".
I would now like to write with the help of the macro only <<mymacro>> in the Tiddler and get a link in the form
Linktext

as output.
Where is my mistake?

\define mymacro() [ext[Linktext[$(web)$$(id)$]]
<$vars web="www.verylongdomain.com/" id={{!!webid}}>
</$vars>
\end

Thanks for your help
Regards
Tob

Mark S.

unread,
Jan 6, 2018, 1:12:29 AM1/6/18
to TiddlyWiki
Maybe try:

\define mymacro2(web id) [ext[Linktext|$web$$id$]]
\define mymacro() <$macrocall $name="mymacro2" web="https://mydomain.com/files/" id={{!!webid}}/>

<<mymacro>>
 

-- Mark

Eric Shulman

unread,
Jan 6, 2018, 2:19:18 AM1/6/18
to TiddlyWiki
On Friday, January 5, 2018 at 10:12:29 PM UTC-8, Mark S. wrote:
\define mymacro2(web id) [ext[Linktext|$web$$id$]]
\define mymacro() <$macrocall $name="mymacro2" web="https://mydomain.com/files/" id={{!!webid}}/>
<<mymacro>>

good answer...  I was preparing a similar response, with somewhat different syntax to stay as close as possible to the OP "spec by example".  Here's my solution:
\define mymacro()          <$vars webid={{!!webid}}<<mymacro_makelink>></$vars>
\define mymacro_makelink() [ext[Linktext|https://verylongdomain.com/$(webid)$]]

The approach is basically the same as yours, except I avoided passing the $web$ parameter by using a fixed literal value directly in place.  I also avoided passing the id parameter by using the <$vars> widget to fetch the "{{!!webid}}" field value and set the $(webid)$ variable.  Lastly, as a matter of style, I prefer to use more description naming for "worker" macros rather than simply adding a number.  If there are a lot of worker macros involved, it would be hard to remember which numbered function does what!  Thus, "mymacro_link()" instead of "mymacro2()".

enjoy,
-e
Eric Shulman
TiddlyTools.com: "Small Tools for Big Ideas!" (tm)
InsideTiddlyWiki: The Missing Manuals

tobaisch

unread,
Jan 6, 2018, 3:20:26 AM1/6/18
to TiddlyWiki
Many thanks guys,
Mark your version works fine.
Eric yours make: https://verylongdomain.com/$(webid)$
Regards
Tob

Eric Shulman

unread,
Jan 6, 2018, 4:06:13 AM1/6/18
to TiddlyWiki
On Saturday, January 6, 2018 at 12:20:26 AM UTC-8, tobaisch wrote:
Many thanks guys,
Mark your version works fine.
Eric yours make: https://verylongdomain.com/$(webid)$

I think you invoked it wrong.... just invoke <<mymacro>>.  That is the "entry point".... "mymacro_makelink" is an "internal" function... if you invoke THAT directly, you get the results you report...

Also... a slight typo.... there a  ">" was missing following "{{!!webid}}"

The corrected syntax... and the example are:
\define mymacro()          <$vars webid={{!!webid}}><<mymacro_makelink>></$vars>
\define mymacro_makelink() [ext[Linktext|https://verylongdomain.com/$(webid)$]]
<<mymacro>>

-e

tobaisch

unread,
Jan 6, 2018, 5:20:35 AM1/6/18
to TiddlyWiki
it works now too.
Thanks
Regards

Reply all
Reply to author
Forward
Message has been deleted
Message has been deleted
0 new messages