TW5 $(variable)$ doesn't work

197 views
Skip to first unread message

Artem Ivanov

unread,
Feb 6, 2019, 2:03:42 PM2/6/19
to TiddlyWiki
Newbie here,

In a plugin i recently installed (simplecalendar), when calling out a defined variable as $(style)$, it doesn't return the data but the variable itself.
Not sure how else to put this. This is from the plugin's default code of $:/plugins/frd/simplecalendar/DaysTemplate:

<$set name="style" value=<<now "ItemYYYY0MM0DD0hh0mm0ss">>>
 <$wikify name="itemTitle" text="$:/simplecalendar/$(style)$">
 <$button class="tc-btn-invisible btn-toolbar-item" tooltip="Create new item" actions=<
<actions-createItem>>>
 {{$:/core/images/new-button}}
 </$button>
 </$wikify>
</$set>

So here the itemTitle is defined as literally "$:/simplecalendar/$(style)$" and not that defined by style.

Am I missing a setting?

tia


FrD

unread,
Feb 6, 2019, 4:05:29 PM2/6/19
to TiddlyWiki
Hi Ivanov,

I'm the author of that plugin. I didn't test it with the last version of TW (5.1.19). And indeed as you've found there is a new bug. I'll investigate and get back to you.

Regards

FrD

FrD

unread,
Feb 6, 2019, 5:04:16 PM2/6/19
to TiddlyWiki
Hi,

I've made some changes in the tiddler $:/plugins/frd/simplecalendar/DaysTemplate.
Could you test the new version of the plugin from http://simplecalendar5-1-19.tiddlyspot.com/ ?
And let me know how it works ...

Regards

FrD

Le mercredi 6 février 2019 20:03:42 UTC+1, Artem Ivanov a écrit :

FrD

unread,
Feb 6, 2019, 5:30:10 PM2/6/19
to TiddlyWiki
Hi,

Following the bug just reported here, I tried the following code in a 5.1.17 and a 5.1.19 TW :

<$set name="style" value=<<now "ItemYYYY0MM0DD0hh0mm0ss">
>>
 <$wikify name="itemTitle" text="Prefix_$(style)$">
 <
<itemTitle>>
 </$wikify>
</$set>

 <$wikify name="itemTitle" text="""Prefix_<
<now "ItemYYYY0MM0DD0hh0mm0ss">>""">
 <
<itemTitle>>
 </$wikify>


The result of these two expressions is the same in the 5.1.17 version.
And not in the 5.1.19.

I couldn't test on 5.1.18.

Could someone explain this behaviour ?

Thanks and regards

FrD

TonyM

unread,
Feb 6, 2019, 5:34:20 PM2/6/19
to TiddlyWiki
FrD,

I was just testing the update, and realised I wanted to make a change to include a tag of "Journal" and add a field with the full date in it eg; journal-date with the value 
journal-date=<<now "YYYY0MM0DD0hh0mm0ss000">>

However my initial attempt failed. 

Would you be able to advise where I can do this please?

I am also keen to bring forward week numbers and make a few other adjustments, I would be happy to share back, but I need to work it out in the first place

Thanks
Tony

TonyM

unread,
Feb 6, 2019, 5:47:52 PM2/6/19
to TiddlyWiki
An answer to your Question?

The $(variable)$ format is used Within macro definitions / macro body and is a substitution like $paramname$ but refers to a variable from outside the macro. Is your use complying with this?

Regards
tony

Mark S.

unread,
Feb 6, 2019, 5:51:34 PM2/6/19
to TiddlyWiki
Before 5.1.18, there was a bug (or a feature) that allowed the Set widget to set variables as $(variable)$. That was fixed. Or at least I think that's the source. See this comment by Jeremy:


So you'll need to work with variety of <<variable>> instead of $(variable)$.

Good luck!
-- Mark

Mohammad

unread,
Feb 6, 2019, 11:13:47 PM2/6/19
to TiddlyWiki
See the note by Mark.
The problem is with $(style)$.

The below show the same result in TW5.1.17, 5.1.18 and 5.1.19

\define concat() Prefix_$(style)$

<$set name="style" value=<<now "ItemYYYY0MM0DD0hh0mm0ss">> >

 
<$wikify name="itemTitle" text=<<concat>> >

 
<<itemTitle>>
 
</$wikify>
</
$set>


 
<$wikify name="itemTitle" text="""Prefix_<<now ItemYYYY0MM0DD0hh0mm0ss">>""">
 <<itemTitle>>
 </$wikify>




Name the macro whatever you wish.


--Mohammad

FrD

unread,
Feb 7, 2019, 2:26:47 AM2/7/19
to TiddlyWiki
Hi Mohammad and Mark !

Thanks for your answers. I think you're right on the spot.
I'll need to inspect my (old) code to see if I'm using this kind of construct.

Regards

FrD

FrD

unread,
Feb 7, 2019, 2:45:27 AM2/7/19
to TiddlyWiki
Hi TonyM,

I'd be pleased to help you. Can you bring me bit more of the context ?

I assume you want to create a "journal" tiddler by clicking on a cell on the calendar. The macro invoked by clicking on a date is the one declared in the config tiddler : see for instance

$:/plugins/frd/simplecalendar/CalendarConfigDefault


The macro is the value of the "cellContent" index.
There are 4 different values corresponding to 4 different macros. The code of the macros is in
$:/plugins/frd/simplecalendar/CalendarCellContentMacros

sc_basic : doesn't open or create a journal tiddler
sc_linkNavigateToJournal : navigate to the journal tiddler
sc_linkNavigateToOrCreateViewModeJournal : navigate to a journal or create it in view mode
sc_linkNavigateToOrCreateEditModeJournal : navigate to a journal or create it in edit mode

So if you tell me the desired behavior (from the four described above) I could write a 5th macro as a modified version that could set a tag and a field as required.

Hope this clarifies a bit

Regards

FrD

Artem Ivanov

unread,
Feb 7, 2019, 7:29:13 PM2/7/19
to TiddlyWiki
Hi FrD,

Thank you, this version solved the issue. However, now when I use

<<simplecalendar mycalendar yearState:"MyStateTiddler!!year" monthState:"MyStateTiddler!!month">>

I get this error:

The state tiddler for the year does not exist ; create it before calling the simplecalendar macro

Should I just use 5.1.17 for now?

TonyM

unread,
Feb 7, 2019, 8:13:39 PM2/7/19
to TiddlyWiki
FrD,

Thanks, I suppose if I had to choose it would be;

sc_linkNavigateToOrCreateEditModeJournal : navigate to a journal or create it in edit mode

  • Does this mean if it exists it opens in view mode, if it does not the new one opens in edit mode?

Could you perhaps include user defined actions such as <<simplecal-onclickday-actions>> where the user can then define

\define simplecal-onclickday-actions()
<$action-sendmessage $message="tm-add-tag" param="Journal">>/>
<$action-setfield $field=journal-date $value=<<now "YYYY0MM0DD0hh0mm0ss000">>/>
\end
and the above will add the tag and fieldname the user desires, and if not defined will do nothing?

Thanks
Tony

FrD

unread,
Feb 8, 2019, 3:35:28 AM2/8/19
to TiddlyWiki
Hi,

For now you need to create the state tiddler before calling the simplecalendar macro. This behavior didn't change from the previous version.
The reason is that a macro can only return a string and should not modify a tiddler or create a new one (only widgets should do that). So it was easier for me to build the simplecalendar macro this way.

But the code could be improved and the state tiddler could be created at the first click on a month or year button. I'll have a look and hopefully will come back with a new version ...

Regards

FrD

FrD

unread,
Feb 8, 2019, 3:58:41 AM2/8/19
to TiddlyWiki
Hi TonyM,



Le vendredi 8 février 2019 02:13:39 UTC+1, TonyM a écrit :
FrD,

Thanks, I suppose if I had to choose it would be;

sc_linkNavigateToOrCreateEditModeJournal : navigate to a journal or create it in edit mode

  • Does this mean if it exists it opens in view mode, if it does not the new one opens in edit mode?

Yes.
 

Could you perhaps include user defined actions such as <<simplecal-onclickday-actions>> where the user can then define

\define simplecal-onclickday-actions()
<$action-sendmessage $message="tm-add-tag" param="Journal">>/>
<$action-setfield $field=journal-date $value=<<now "YYYY0MM0DD0hh0mm0ss000">>/>
\end
and the above will add the tag and fieldname the user desires, and if not defined will do nothing?

Thanks
Tony
 
Inside the <$button> widget of the "sc_linkNavigateToOrCreateEditModeJournal" macro, put the following code :

<$action-setfield $tiddler=<<journalTitle>> $field="journal-date" $value=<<now "YYYY0MM0DD0hh0mm0ss000">>/>
<$action-setfield $tiddler=<
<journalTitle>> tags="Journal"/>
<$action-sendmessage $message="tm-edit-tiddler" param=<
<journalTitle>>/>
                //$day$//

Or better, copy the macro, rename it and change the content of the <$button> widget.
That should do what you want.

Regards

FrD

Artem Ivanov

unread,
Feb 8, 2019, 11:25:01 AM2/8/19
to TiddlyWiki
What I mean is, after uninstalling the plugin and a fresh install of the 5.1.19 version,

<<simplecalendar mycalendar yearState:"MyStateTiddler!!year" monthState:"MyStateTiddler!!month">>

does not work.

tia

FrD

unread,
Feb 8, 2019, 11:59:21 AM2/8/19
to TiddlyWiki
Hi,

Just create the tiddler "MyStateTiddler" and then your macro call should work.

After having created the tiddler, open the tiddler containing your macro call (<<simplecalendar mycalendar yearState:"MyStateTiddler!!year" monthState:"MyStateTiddler!!month">>) and close it. It will refresh its content and display your calendar.

Regards

FrD

FrD

unread,
Feb 8, 2019, 4:25:20 PM2/8/19
to TiddlyWiki
Hi,

I've updated the simplecalendar plugin ; in the latest version  you don't need to create the state tiddler anymore before calling the macro. It will be created when needed.

Regards
FrD

Artem Ivanov

unread,
Feb 9, 2019, 4:16:34 PM2/9/19
to TiddlyWiki
Installed your latest.

Now, for some reason the td class in the table is coming up as "calendar-undefined" and the styles aren't working.

I'm running 5.1.19 on Node.js

Thanks again,

Art

FrD

unread,
Feb 10, 2019, 2:30:32 AM2/10/19
to TiddlyWiki
Hi,

Sorry for yours problems with the plugin. Will be absent for a week and will tackle that just after.

Regards

FrD

FrD

unread,
Feb 10, 2019, 12:07:16 PM2/10/19
to TiddlyWiki
Hi,

I am on my phone so not easy to post. You could try this fix :

Locate the tiddler $:/plugins/frd/simplecalendar/DaysTemplate

Edit it.
Just after all the "define", locate <$wikify .../> ... </$wikify>
Replace with

<$set name="style" value=<<now "ItemYYYY0MM0DD0hh0mm0ss">>>

<$wikify name="itemTitle" text="$:/simplecalendar/<<style>>">


<$button class="tc-btn-invisible btn-toolbar-item" tooltip="Create new item" actions=<<actions-createItem>>>
{{$:/core/images/new-button}}
</$button>
</$wikify>
</$set>

I'll update the plugin when I'm back home.
Let me know how it works.

Regards

FrD


FrD

unread,
Feb 18, 2019, 6:48:12 AM2/18/19
to TiddlyWiki
Hi,

Two fixes :
  • styles "manager" is working again
  • state tiddler doesn't need to exist before creating the calendar
Let me know how it goes ...

Regards

FrD

TonyM

unread,
Feb 18, 2019, 9:39:29 PM2/18/19
to TiddlyWiki
Thanks for maintaining and Developing this FrD

Looking good.
Reply all
Reply to author
Forward
0 new messages