[tw5] Re: how to set a global variable with a tiddler field value

2021-08-18 Thread vpl
Hi,

Much much simplier .. indeed
I've turned around this simple solution for some time without finding it ..

Thanks a lot for your very quick help 

Regards

Le mercredi 18 août 2021 à 12:53:31 UTC+2, Eric Shulman a écrit :

> On Wednesday, August 18, 2021 at 3:25:22 AM UTC-7 vpl wrote:
>
>> In fact my problem was linked to a button action and thanks to  
>> https://tiddlytools.com/timer.html code sample I was able to find a work 
>> an option 
>> \define tasks_delete()
>> <$vars  projectId={{{ [get[projectId]] }}}>
>> <$reveal default="show" type="match" text="show">
>> <$button class="tc-button tt-button" tooltip="delete this alarm"> 
>> {{$:/core/images/delete-button}}
>> <$action-listops $tiddler=<> $field="tasks" 
>> $subfilter="-[[$(this_alarm)$]]" />
>>   
>> 
>> \end
>> The $reveal seems to be mandatory to get access to my projectId variable 
>> withing the button action-listops
>>
>
> Here's a trimmed down version that eliminates the unneeded excess syntax:
> \define tasks_delete()
> <$button class="tc-button" tooltip="delete this task"> 
> {{$:/core/images/delete-button}}
><$action-listops $tiddler={{{ [get[projectId]] }}} 
> $field="tasks" $subfilter="-[[$(this_alarm)$]]" />
> 
> \end
>
> Notes:
> * The $vars is not needed.  Instead, use $tiddler={{{ 
> [get[projectId]] }}} directly in the $action-listops 
> widget
> * Eliminate the $reveal and /$reveal.  Quite obviously, "show" will always 
> match "show", so this does nothing.
> * Remove "tt-button" from the $button class="...";  this is a TiddlyTools 
> custom classname that is almost certainly not defined in your TiddlyWiki.
> * Fix the tooltip text to say "task" instead of "alarm"
> * $(this_alarm)$ references a variable defined outside the tasks_delete() 
> macro and should probably be changed to whatever variable holds the name of 
> the task you are deleting.
>
> -e
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"TiddlyWiki" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to tiddlywiki+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/tiddlywiki/8376d887-f7f0-4319-90c3-fbd08f6252d9n%40googlegroups.com.


[tw5] Re: how to set a global variable with a tiddler field value

2021-08-18 Thread Eric Shulman
On Wednesday, August 18, 2021 at 3:25:22 AM UTC-7 vpl wrote:

> In fact my problem was linked to a button action and thanks to  
> https://tiddlytools.com/timer.html code sample I was able to find a work 
> an option 
> \define tasks_delete()
> <$vars  projectId={{{ [get[projectId]] }}}>
> <$reveal default="show" type="match" text="show">
> <$button class="tc-button tt-button" tooltip="delete this alarm"> 
> {{$:/core/images/delete-button}}
> <$action-listops $tiddler=<> $field="tasks" 
> $subfilter="-[[$(this_alarm)$]]" />
>   
> 
> \end
> The $reveal seems to be mandatory to get access to my projectId variable 
> withing the button action-listops
>

Here's a trimmed down version that eliminates the unneeded excess syntax:
\define tasks_delete()
<$button class="tc-button" tooltip="delete this task"> 
{{$:/core/images/delete-button}}
   <$action-listops $tiddler={{{ [get[projectId]] }}} 
$field="tasks" $subfilter="-[[$(this_alarm)$]]" />

\end

Notes:
* The $vars is not needed.  Instead, use $tiddler={{{ 
[get[projectId]] }}} directly in the $action-listops widget
* Eliminate the $reveal and /$reveal.  Quite obviously, "show" will always 
match "show", so this does nothing.
* Remove "tt-button" from the $button class="...";  this is a TiddlyTools 
custom classname that is almost certainly not defined in your TiddlyWiki.
* Fix the tooltip text to say "task" instead of "alarm"
* $(this_alarm)$ references a variable defined outside the tasks_delete() 
macro and should probably be changed to whatever variable holds the name of 
the task you are deleting.

-e

-- 
You received this message because you are subscribed to the Google Groups 
"TiddlyWiki" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to tiddlywiki+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/tiddlywiki/d20c117b-04c5-42a1-b023-1210d7e835d9n%40googlegroups.com.


[tw5] Re: how to set a global variable with a tiddler field value

2021-08-18 Thread vpl
Thanks a lot for this detailed answer which is going beyond my current 
expertise and understanding of these languages suptilities
In fact my problem was linked to a button action and thanks to  
https://tiddlytools.com/timer.html code sample I was able to find a work an 
option 

\define tasks_delete()
<$vars  projectId={{{ [get[projectId]] }}}>
<$reveal default="show" type="match" text="show">
<$button class="tc-button tt-button" tooltip="delete this alarm"> 
{{$:/core/images/delete-button}}
<$action-listops $tiddler=<> $field="tasks" 
$subfilter="-[[$(this_alarm)$]]" />
  

\end

The $reveal seems to be mandatory to get access to my projectId variable 
withing the button action-listops

Thanks a lot for  your help

Regards

Vpl

Le mardi 17 août 2021 à 17:06:55 UTC+2, Soren Bjornstad a écrit :

> vpl,
>
> First of all, the syntax for incorporating a variable into a filter 
> expression is not <> but :
>
> \define test_project() {{{ [get[projectId]] }}}
>
> However, this still may not work, depending on how you use the macro. It's 
> tempting to think of macro transclusions as "function calls", where when 
> you say <> you get the result of evaluating their contents as 
> wikitext. But this is not how macros work – instead, *the exact text of 
> the macro* (with any $text substitutions$ the macro might include) is 
> inserted wherever the <> is used, which in this case is 
> a filter expression in triple curly braces.
>
> Now, this will still work fine if you just say, for instance:
>
> <>
>
> In this case, TW replaces <> with {{{ 
> [get[projectId]] }}}, then sees that wikitext in the body of a 
> tiddler, evaluates it, and gets the project ID. But it won't work if you 
> try to use it within another filter expression, or as the value of an HTML 
> or widget attribute, e.g., suppose you had a tiddler whose title was this 
> project ID and wanted to transclude it:
>
> <$transclude tiddler=<>/>
>
> In this case, TW will be looking for a tiddler called "{{{ 
> [get[projectId]] }}}", and it presumably won't find it.
>
> If you need to, you can get around this with the $wikify widget:
>
> <$wikify name="myProjectId" text=<>>
>   <$transclude tiddler="myProjectId"/>
> 
>
> In this case, you explicitly tell TW to evaluate the wikitext "{{{ 
> [get[projectId]] }}}", then use the result to transclude the 
> appropriate tiddler.
>
> You can read more on this in the Wikification section 
>  of *Grok TiddlyWiki*.
> On Tuesday, August 17, 2021 at 9:56:51 AM UTC-5 vpl wrote:
>
>> Hi,
>>
>> I want to define a global variable in my script with the value contained 
>> into a tiddler field
>> When I hard code the global variable like
>>
>> \define test_project() project-1
>>
>> I can use the <> variable without issue 
>>
>> But when I want this <> to be initialised to a tiddler's  
>> field like the following this does not work
>>
>> \define test_project() {{{ [<>get[projectId]] }}}
>>
>> Any "magic" idea ..??
>>
>> Thanks a lot for your support
>>
>> Regards vpl
>>
>

-- 
You received this message because you are subscribed to the Google Groups 
"TiddlyWiki" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to tiddlywiki+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/tiddlywiki/4a75eee9-5f0a-4464-8af9-05399befe939n%40googlegroups.com.


[tw5] Re: how to set a global variable with a tiddler field value

2021-08-17 Thread Soren Bjornstad
vpl,

First of all, the syntax for incorporating a variable into a filter 
expression is not <> but :

\define test_project() {{{ [get[projectId]] }}}

However, this still may not work, depending on how you use the macro. It's 
tempting to think of macro transclusions as "function calls", where when 
you say <> you get the result of evaluating their contents as 
wikitext. But this is not how macros work – instead, *the exact text of the 
macro* (with any $text substitutions$ the macro might include) is inserted 
wherever the <> is used, which in this case is a filter 
expression in triple curly braces.

Now, this will still work fine if you just say, for instance:

<>

In this case, TW replaces <> with {{{ 
[get[projectId]] }}}, then sees that wikitext in the body of a 
tiddler, evaluates it, and gets the project ID. But it won't work if you 
try to use it within another filter expression, or as the value of an HTML 
or widget attribute, e.g., suppose you had a tiddler whose title was this 
project ID and wanted to transclude it:

<$transclude tiddler=<>/>

In this case, TW will be looking for a tiddler called "{{{ 
[get[projectId]] }}}", and it presumably won't find it.

If you need to, you can get around this with the $wikify widget:

<$wikify name="myProjectId" text=<>>
  <$transclude tiddler="myProjectId"/>


In this case, you explicitly tell TW to evaluate the wikitext "{{{ 
[get[projectId]] }}}", then use the result to transclude the 
appropriate tiddler.

You can read more on this in the Wikification section 
 of *Grok TiddlyWiki*.
On Tuesday, August 17, 2021 at 9:56:51 AM UTC-5 vpl wrote:

> Hi,
>
> I want to define a global variable in my script with the value contained 
> into a tiddler field
> When I hard code the global variable like
>
> \define test_project() project-1
>
> I can use the <> variable without issue 
>
> But when I want this <> to be initialised to a tiddler's  
> field like the following this does not work
>
> \define test_project() {{{ [<>get[projectId]] }}}
>
> Any "magic" idea ..??
>
> Thanks a lot for your support
>
> Regards vpl
>

-- 
You received this message because you are subscribed to the Google Groups 
"TiddlyWiki" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to tiddlywiki+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/tiddlywiki/0cdcb9ac-2f0a-4f50-a6a8-fd9dfac7819cn%40googlegroups.com.