[TW5] Local macro doesn't work with <$maketid> widget

152 views
Skip to first unread message

Tomás Iglesias

unread,
Sep 23, 2014, 6:18:15 PM9/23/14
to tiddl...@googlegroups.com
Hi, after playing a little with TW5 I'm very pleased with the results. The only problem that I can't solve is the folowing tiddler, in wich I define a local macro to concatenate two inputs that I save in various sites (in the 'autor' and 'titulo' fields of the tiddler containing data from an article, and concatenated for the title of that same tiddler):

\define tituloPaper(autor:"Anónimo",titulo:"No se sabe")
$autor$
: "$titulo$"
\end

The input fields:

|>|!Título |<$edit-text tiddler="$:/temp/paper" field="titulo" placeholder="Título de la publicación" size="60"/>|
|>|!Autor |<$edit-text tiddler="$:/temp/paper" field="autor" placeholder="Autor de la publicación"  size="60"/>|


The button that creates the tiddler with the article information:

<$set name="au" value={{$:/temp/paper!!autor}}>
<$set name="ti" value={{$:/temp/paper!!titulo}}>
<$maketid  title=<<tituloPaper {{$:/temp/paper!!autor}} {{$:/temp/paper!!titulo}} >> tags="paper referencia" template="PaperSkeleton" edit="yes"><$button message="tw-new-tiddler">Agregar paper</$button></$maketid>
</$set></$set>

This is a test of the macro that works:
<<tituloPaper {{$:/temp/paper!!autor}} {{$:/temp/paper!!titulo}}>>

A button to clean de temp tiddler fields
:

<$setfield tiddler="$:/temp/paper" set="!!titulo" setTo="">
<$setfield tiddler="$:/temp/paper" set="!!autor" setTo="">
<$button message="tw-set-field" param="SetField Target">Limpiar</$button>
</
$setfield></$setfield>

Everything works as expected (correct tags, fields with the 'autor' and 'titulo' data and contents from a template tiddler), but the title is set to 

{{$:/temp/paper!!autor}}: "{{$:/temp/paper!!titulo}}"


This happens in TW 5.1.0 and 5.1.1

So, what should I do? Use the MacroCall widget? (Can you use a widget inside a widget?) Change everything?. If this approach is completely wrong I accept suggestions as I'm learning.

As you can see, this way of titling is inspired in TW for Scholars from Alberto Molina.

Thanks!

Tomás

c pa

unread,
Sep 23, 2014, 7:07:06 PM9/23/14
to tiddl...@googlegroups.com
Tomas. You can't set variables and use them in the same code block.

Try This it worked for me. You can see it on http://cpashow.tiddlyspot.com/#Tomas


\define tituloPaper(autor:"Anónimo",titulo:"No se sabe")
$autor$: "$titulo$"
\end
\define missingdefine()
<$maketid  title="$(au)$ $(ti)$"tags="paper referencia" template="PaperSkeleton" edit="yes"><$button message="tw-new-tiddler">Agregar paper</$button></$maketid>

\end

The input fields:

|>|!Título |<$edit-text tiddler="$:/temp/paper" field="titulo" placeholder="Título de la publicación" size="60"/>|
|>|!Autor |<$edit-text tiddler="$:/temp/paper" field="autor" placeholder="Autor de la publicación"  size="60"/>|


The button that creates the tiddler with the article information:

<$set name="au" value={{$:/temp/paper!!autor}}>
<$set name="ti" value={{$:/temp/paper!!titulo}}>
    <<missingdefine>>

</$set></$set>

This is a test of the macro that works:
<<tituloPaper {{$:/temp/paper!!autor}} {{$:/temp/paper!!titulo}}>>

A button to clean de temp tiddler fields:

<$set tiddler="$:/temp/paper" set="!!titulo" setTo="">
<$set tiddler="$:/temp/paper" set="!!autor" setTo="">

<$button message="tw-set-field" param="SetField Target">Limpiar</$button>
</$set></$set>

Tomás Iglesias

unread,
Sep 23, 2014, 8:04:23 PM9/23/14
to tiddl...@googlegroups.com
Thanks it worked!

The final macro is:

\define missingdefine()
<$maketid  title="""$(au)$: "$(ti)$" """ tags="paper referencia" template="PaperSkeleton" edit="yes"><$button message="tw-new-tiddler">Agregar paper</$button></$maketid>
\end

so the title can have the 'Someone et al (2014): "Something we investigated" ' format.

Thanks again!

Tomás

Stephan Hradek

unread,
Sep 24, 2014, 2:44:27 AM9/24/14
to tiddl...@googlegroups.com
Why do you set the variables "au" and "ti" and don't use it in your tituloPaper macro? It should work.

Tomás Iglesias

unread,
Sep 24, 2014, 10:00:58 AM9/24/14
to tiddl...@googlegroups.com
Do'h!

It's been years since my first and only course on programming on Java, and I don't know anything about HTML so I didn't knew that I was defining a variable (now it seems so obvius). So, maybe this is a silly question, but when you use the <$set name="" value="">      </$set>  your are just defining a variable? Is this variable available to all macros/widgets/tiddlers in the current TW?

PMario

unread,
Sep 24, 2014, 11:19:01 AM9/24/14
to tiddl...@googlegroups.com
Hi Tomás,


On Wednesday, September 24, 2014 4:00:58 PM UTC+2, Tomás Iglesias wrote:
It's been years since my first and only course on programming on Java,
and I don't know anything about HTML so I didn't knew that I was defining a variable (now it seems so obvius).
 
TiddlyWiki can use plain HTML tags [1] like <ol><li>text test</li></ol>  .. which creates an ordered list with one list element.

and it can combine it with TW5 specific widgets [2]. eg: <$set> .... </$set>  So if you use the set widget in a standard HTML page it won't work. Widgets need TiddlyWiki to create there magic :)


So, maybe this is a silly question, but when you use the <$set name="" value="">      </$set>  your are just defining a variable? Is this variable available to all macros/widgets/tiddlers in the current TW?

<$set name="" value="">  ..context..    </$set>
The variable is only visible between the start and the end marker. I did name it ..context.. here.

-mario

[1] https://developer.mozilla.org/en-US/docs/Web/HTML/Element  ... This is a good source for everything web related
[2] http://tiddlywiki.com/#Widgets






Stephan Hradek

unread,
Sep 24, 2014, 2:19:38 PM9/24/14
to tiddl...@googlegroups.com


Am Mittwoch, 24. September 2014 17:19:01 UTC+2 schrieb PMario:
<$set name="" value="">  ..context..    </$set>
The variable is only visible between the start and the end marker. I did name it ..context.. here.

Please also note that in

\define macro()
here
\end
<$set name="" value="">  context…<<macro>>…context    </$set>


the variables are also visible in the macro as it was called in the context. So it does not have lexical- but dynamic-scope.


Tomás Iglesias

unread,
Sep 24, 2014, 3:10:23 PM9/24/14
to tiddl...@googlegroups.com
PMario,

Thanks for the links! They are going to the reference tiddler right now. There are lots of things to learn.

Stephan,

The concepts of context and scope are new to me, and the Wikipedia link is really useful to understand them well.

The work in the last month learning Latex, Git and now with TW (and R in October) are time-comsuming because there is a lot of reading and trial and error involved, but it's so fun! At least it's not lost time because you end up with quite a few tools that can help you in the future.

Thanks to all!

Tomás

--
You received this message because you are subscribed to a topic in the Google Groups "TiddlyWiki" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/tiddlywiki/MhJUz71sIcM/unsubscribe.
To unsubscribe from this group and all its topics, send an email to tiddlywiki+...@googlegroups.com.
To post to this group, send email to tiddl...@googlegroups.com.
Visit this group at http://groups.google.com/group/tiddlywiki.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages