troublehooting: how to see macro variables

50 views
Skip to first unread message

Dave Parker

unread,
Jun 30, 2020, 1:34:01 AM6/30/20
to TiddlyWiki
When you're working on a macro, how do you view a variable to make sure its actually doing what you think its doing?

For example:
\define vassum2(here myfield)
<$text text={{{=[title[$here$.VAShi]get[$myfield$]] =[title[$here$.VASlo]get[$myfield$]] =[title[$here$.disAbil]get[$myfield$]]  +[sum[]]}}}/>
\end

\define vassum()
<$list filter="[all[current]addsuffix[.VAShi]fields[]regexp[\d\d\d\d-\d\d-\d\d]]" variable="field">
<$macrocall $name=vassum2 here="$(currentTiddler)$" myfield=$field$ /> *<-- here?
</$list>
\end
<<vassum>>

Like if I want to check on the contents of the variable "field" in the vassum macro, how would I view that? At the asterisk I tried $field$ <field> <<field>> and $(field)$

I also tried $myfield$ and <$text text=$myfield$/> in the vassum2 macro


Thanks,
- Dave 

Eric Shulman

unread,
Jun 30, 2020, 2:25:31 AM6/30/20
to TiddlyWiki
On Monday, June 29, 2020 at 10:34:01 PM UTC-7, Dave Parker wrote:
\define vassum2(here myfield)
<$text text={{{=[title[$here$.VAShi]get[$myfield$]] =[title[$here$.VASlo]get[$myfield$]] =[title[$here$.disAbil]get[$myfield$]]  +[sum[]]}}}/>
\end

\define vassum()
<$list filter="[all[current]addsuffix[.VAShi]fields[]regexp[\d\d\d\d-\d\d-\d\d]]" variable="field">
<$macrocall $name=vassum2 here="$(currentTiddler)$" myfield=$field$ /> *<-- here?
</$list>
\end
<<vassum>>


Inside the
<$list ... variable="field">...</$list>
you would use
<<field>>
to see the current value of the variable.

Also note that in your
<$macrocall ... myfield=$field$ />
there is NO ***macro parameter*** named "field", so $field$ is always blank.

I think perhaps you mean to write
<$macrocall ... myfield=<<field>> />
which would pass the current value of the "field" ***variable*** into the vassum2() macro.

I'm also thinking that you could skip the macros and just write this:
<$list filter="[<currentTiddler>addsuffix[.VAShi]fields[]regexp[\d\d\d\d-\d\d-\d\d]]" variable="field">
<$text text={{{ =[
<currentTiddler>addsuffix[.VAShi]get<field>] =[<currentTiddler>addsuffix[.VASlo]get<field>] =[<currentTiddler>addsuffix[.disAbil]get<field>] +[sum[]] }}}/>
</$vars>

First, use $list to extract the matching fieldnames from "...VAShi" (I assume your fieldnames are probably dates like "2020-06-30")
Then, for each matching fieldname, get the value of that field from the "...VAShi", "...VASlo", and "...disAbil" tiddlers and show the sum of the three values

-e

Dave Parker

unread,
Jun 30, 2020, 2:51:09 AM6/30/20
to TiddlyWiki
Does the ending "</$vars>" act somehow as the closing "bracket" to the "<$list" widget?

Eric Shulman

unread,
Jun 30, 2020, 2:55:08 AM6/30/20
to TiddlyWiki
On Monday, June 29, 2020 at 11:51:09 PM UTC-7, Dave Parker wrote:
Does the ending "</$vars>" act somehow as the closing "bracket" to the "<$list" widget?

no... that was editing error when i wrote the message.  It should be </$list>, not </$vars> 

-e

Dave Parker

unread,
Jun 30, 2020, 11:36:42 AM6/30/20
to TiddlyWiki
Ok, thank you so much!
Reply all
Reply to author
Forward
0 new messages