Re: [tw5] Storing the result of a macro in raw form and pass it to a tiddler text field

2019-02-22 Thread Mohammad
Jeremy,
 I tested your solution and it works, BUT, this is true if utility macro 
itself contains wikitext like example above.
If utility itself call other macro or have some scripts, then it will fail, 
look at the below case


\define mac2(p) {{{ [<__p__>split[]addprefix[c]] }}}
\define utility(a, b) 
This is //$a$//  and ''$b$''.
<$macrocall $name="mac2" p=<<__a__>> />
\end


\define test(a,b)
<$set name="newText" value=<>>
<$text text=<> />

\end


<>


The output is:

This is //italic// and ''bold''. <$macrocall $name="mac2" p=<<__a__>> />


While I expect;

This is //italic// and ''bold''. cictcaclcicc


--Mohammad

-- 
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 post to this group, send email to tiddlywiki@googlegroups.com.
Visit this group at https://groups.google.com/group/tiddlywiki.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/tiddlywiki/9f64d44a-d010-4e4e-9538-0450fd14a748%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [tw5] Storing the result of a macro in raw form and pass it to a tiddler text field

2019-02-22 Thread Mohammad
Hi Tony!
 Thank you! Yes, it would make life much easier!

--Mohammad

On Saturday, February 23, 2019 at 1:23:42 AM UTC+3:30, TonyM wrote:
>
> Mohammad,
>
> I think Jeremy is suggesting storing the macro output in a variable as a 
> future feature. This is a bit like allowing us to pipe the output of one 
> macro into another.
>
> I think this would be helpful, and would make some solutions much easier 
> to code.
>
> I would love to find a way to store a variable in a more permanent form 
> without a button. Or store it in a field or text reference. Even if the 
> value must be reevaluated on render.
>
> Regards
> Tony
>
>

-- 
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 post to this group, send email to tiddlywiki@googlegroups.com.
Visit this group at https://groups.google.com/group/tiddlywiki.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/tiddlywiki/44780c48-8bf1-4665-a4de-ea40fff7ae73%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [tw5] Storing the result of a macro in raw form and pass it to a tiddler text field

2019-02-22 Thread TonyM
Mohammad,

I think Jeremy is suggesting storing the macro output in a variable as a future 
feature. This is a bit like allowing us to pipe the output of one macro into 
another.

I think this would be helpful, and would make some solutions much easier to 
code.

I would love to find a way to store a variable in a more permanent form without 
a button. Or store it in a field or text reference. Even if the value must be 
reevaluated on render.

Regards
Tony

-- 
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 post to this group, send email to tiddlywiki@googlegroups.com.
Visit this group at https://groups.google.com/group/tiddlywiki.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/tiddlywiki/56fa8016-94e9-4bd7-9333-d7b7eeccd401%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [tw5] Storing the result of a macro in raw form and pass it to a tiddler text field

2019-02-22 Thread Mohammad
Thank you Jeremy!
Lets see how can I use your solution in my case and I return to you by me 
results.

By the way I am curious about the last paragraph of your reply:

An alternate solution that might be useful would be an alternate mode to 
> the <$macrocall> widget whereby it makes the result of calling the macro 
> available as a variable, instead of directly rendering it.
>

How this is possible? There is nothing in 
documentation: https://tiddlywiki.com/prerelease/#MacroCallWidget
Is it like below

<$macrocall   store=?>
scope of that var



Best regards
Mohammad


On Friday, February 22, 2019 at 1:28:58 PM UTC+3:30, Jeremy Ruston wrote:
>
> Hi Mohammad
>
> Thanks that’s great.
>
> I think the button is actually a red herring, and you can see the same 
> behaviour with this simplified version:
>
> \define utility(a, b) This is //$a$//  and ''$b$''.
>
> \define test(tidName, v1, v2)
> <$wikify name="newText" 
> text="""<$macrocall $name="utility"
> a=<<__v1__>> b=<<__v2__>>
> />""">
> <$text text=<> />
> 
> \end
>
> <>
>
> You don’t actually need the wikify widget here; the trick is to use macro 
> parameter textual substitution:
>
> \define utility(a, b) This is //$a$//  and ''$b$''.
>
> \define test(a,b)
> <$set name="newText" value=<>>
> <$text text=<> />
> 
> \end
>
> <>
>
> Using textual substitution isn’t ideal because of the issues with quoting 
> (e.g. the example above will fail if the parameter values started with 
> three double quotes).
>
> An alternate solution that might be useful would be an alternate mode to 
> the <$macrocall> widget whereby it makes the result of calling the macro 
> available as a variable, instead of directly rendering it.
>
> Best wishes
>
> Jeremy
>
>
> On 21 Feb 2019, at 14:37, Mohammad > 
> wrote:
>
> Hi Jeremy,
>
> I tried to reproduce a simple example though may seem meaningless.
>
>
> \define utility(a, b) This is //$a$//  and ''$b$''.
>
> \define test(tidName, v1, v2)
> <$wikify name="newText" 
> text="""<$macrocall $name="utility"
> a=<<__v1__>> b=<<__v2__>>
> />""">
> <$action-setfield $tiddler="""$tidName$""" $field="text" 
> $value=<> />
> 
> \end
>
> <$button>Do it
> <>
> 
>
>
> What I expect is to see the myTiddley text field as
>
> This is //italic//  and ''bold''.
>
>
>
> But I see this
>
> This is italic and bold.
>
>
> --Mohammad
>
> PS: The real story is I am developing a code to search and replace a 
> string in a tiddler text field.
>
>
>
>
>
> On Thursday, February 21, 2019 at 5:43:34 PM UTC+3:30, Jeremy Ruston wrote:
>>
>> Hi Mohammad
>>
>> Please could you post a complete example?
>>
>> Many thanks,
>>
>> Jeremy
>>
>> On 21 Feb 2019, at 14:06, Mohammad  wrote:
>>
>>
>> One way to store the result of a macro has some parameters is to store it 
>> in wikified variable as below
>>
>>
>> Example
>> See the below code extracted from a longer code. This works correctly. It 
>> calls utility, and save the results in newText and then the action-setfield 
>> passes it to a tiddler as its text field.
>>
>>
>> <$wikify name="newText"  text="""<$macrocall $name="utility" par1=<> 
>> par2=<> />""" >
>> <$action-setfield $tiddler="""$tidName$""" $field="text" $value=<
>> > />
>>
>> 
>>
>>
>>
>> Now, assume the *result *of *utility macro *is something like below
>>
>> This is //italic// and this is {{!!caption}}
>>
>>
>> What happens? $Wikify save the wikified result as expected, but I wish 
>> to store in tidName text filed the raw non-wikified result, I mean what 
>> exactly *utility  macro *returns.
>>
>> So, the question is how can I store the result of *utility macro* in 
>> non-wikified (raw form) and pass it to the text filed of some tiddler?
>>
>>
>> --Mohammad
>>
>> -- 
>> 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+...@googlegroups.com.
>> To post to this group, send email to tiddl...@googlegroups.com.
>> Visit this group at https://groups.google.com/group/tiddlywiki.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/tiddlywiki/099d67c2-8bb2-41c9-a372-f0948167bf41%40googlegroups.com
>>  
>> 
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
>>
>>
> -- 
> 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+...@googlegroups.com .
> To post to this group, send email to tiddl...@googlegroups.com 
> .
> Visit this group at https://groups.google.com/group/tiddlywiki.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/tiddlywiki/3f5cf631-8ae6-4096-bdcf-c328891cee48%40googlegroups.com
>  
> 

Re: [tw5] Storing the result of a macro in raw form and pass it to a tiddler text field

2019-02-22 Thread Jeremy Ruston
Hi Mohammad

Thanks that’s great.

I think the button is actually a red herring, and you can see the same 
behaviour with this simplified version:

\define utility(a, b) This is //$a$//  and ''$b$''.

\define test(tidName, v1, v2)
<$wikify name="newText" 
text="""<$macrocall $name="utility"
a=<<__v1__>> b=<<__v2__>>
/>""">
<$text text=<> />

\end

<>

You don’t actually need the wikify widget here; the trick is to use macro 
parameter textual substitution:

\define utility(a, b) This is //$a$//  and ''$b$''.

\define test(a,b)
<$set name="newText" value=<>>
<$text text=<> />

\end

<>

Using textual substitution isn’t ideal because of the issues with quoting (e.g. 
the example above will fail if the parameter values started with three double 
quotes).

An alternate solution that might be useful would be an alternate mode to the 
<$macrocall> widget whereby it makes the result of calling the macro available 
as a variable, instead of directly rendering it.

Best wishes

Jeremy


> On 21 Feb 2019, at 14:37, Mohammad  wrote:
> 
> Hi Jeremy,
> 
> I tried to reproduce a simple example though may seem meaningless.
> 
> 
> \define utility(a, b) This is //$a$//  and ''$b$''.
> 
> \define test(tidName, v1, v2)
> <$wikify name="newText" 
> text="""<$macrocall $name="utility"
> a=<<__v1__>> b=<<__v2__>>
> />""">
> <$action-setfield $tiddler="""$tidName$""" $field="text" $value=<> />
> 
> \end
> 
> <$button>Do it
> <>
> 
> 
> 
> What I expect is to see the myTiddley text field as
> 
> This is //italic//  and ''bold''.
> 
> 
> 
> But I see this
> 
> This is italic and bold.
> 
> 
> --Mohammad
> 
> PS: The real story is I am developing a code to search and replace a string 
> in a tiddler text field.
> 
> 
> 
> 
> 
> On Thursday, February 21, 2019 at 5:43:34 PM UTC+3:30, Jeremy Ruston wrote:
> Hi Mohammad
> 
> Please could you post a complete example?
> 
> Many thanks,
> 
> Jeremy
> 
>> On 21 Feb 2019, at 14:06, Mohammad > wrote:
>> 
>> 
>> One way to store the result of a macro has some parameters is to store it in 
>> wikified variable as below
>> 
>> 
>> Example
>> See the below code extracted from a longer code. This works correctly. It 
>> calls utility, and save the results in newText and then the action-setfield 
>> passes it to a tiddler as its text field.
>> 
>> 
>> <$wikify name="newText"  text="""<$macrocall $name="utility" par1=<> 
>> par2=<> />""" >
>> <$action-setfield $tiddler="""$tidName$""" $field="text" $value=<> 
>> />
>> 
>> 
>> 
>> 
>> 
>> Now, assume the result of utility macro is something like below
>> 
>> This is //italic// and this is {{!!caption}}
>> 
>> 
>> What happens? $Wikify save the wikified result as expected, but I wish to 
>> store in tidName text filed the raw non-wikified result, I mean what exactly 
>> utility  macro returns.
>> 
>> So, the question is how can I store the result of utility macro in 
>> non-wikified (raw form) and pass it to the text filed of some tiddler?
>> 
>> 
>> --Mohammad
>> 
>> -- 
>> 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+...@googlegroups.com <>.
>> To post to this group, send email to tiddl...@googlegroups.com <>.
>> Visit this group at https://groups.google.com/group/tiddlywiki 
>> .
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/tiddlywiki/099d67c2-8bb2-41c9-a372-f0948167bf41%40googlegroups.com
>>  
>> .
>> For more options, visit https://groups.google.com/d/optout 
>> .
> 
> 
> -- 
> 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 post to this group, send email to tiddlywiki@googlegroups.com 
> .
> Visit this group at https://groups.google.com/group/tiddlywiki 
> .
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/tiddlywiki/3f5cf631-8ae6-4096-bdcf-c328891cee48%40googlegroups.com
>  
> .
> For more options, visit https://groups.google.com/d/optout 
> .

-- 
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 post to this group, send email to tiddlywiki@googlegroups.com.
Visi

Re: [tw5] Storing the result of a macro in raw form and pass it to a tiddler text field

2019-02-21 Thread Mohammad
Hi Jeremy,

I tried to reproduce a simple example though may seem meaningless.


\define utility(a, b) This is //$a$//  and ''$b$''.

\define test(tidName, v1, v2)
<$wikify name="newText" 
text="""<$macrocall $name="utility"
a=<<__v1__>> b=<<__v2__>>
/>""">
<$action-setfield $tiddler="""$tidName$""" $field="text" $value=<> 
/>

\end

<$button>Do it
<>



What I expect is to see the myTiddley text field as

This is //italic//  and ''bold''.



But I see this

This is italic and bold.


--Mohammad

PS: The real story is I am developing a code to search and replace a string 
in a tiddler text field.





On Thursday, February 21, 2019 at 5:43:34 PM UTC+3:30, Jeremy Ruston wrote:
>
> Hi Mohammad
>
> Please could you post a complete example?
>
> Many thanks,
>
> Jeremy
>
> On 21 Feb 2019, at 14:06, Mohammad > 
> wrote:
>
>
> One way to store the result of a macro has some parameters is to store it 
> in wikified variable as below
>
>
> Example
> See the below code extracted from a longer code. This works correctly. It 
> calls utility, and save the results in newText and then the action-setfield 
> passes it to a tiddler as its text field.
>
>
> <$wikify name="newText"  text="""<$macrocall $name="utility" par1=<> 
> par2=<> />""" >
> <$action-setfield $tiddler="""$tidName$""" $field="text" $value=<> 
> />
>
> 
>
>
>
> Now, assume the *result *of *utility macro *is something like below
>
> This is //italic// and this is {{!!caption}}
>
>
> What happens? $Wikify save the wikified result as expected, but I wish to 
> store in tidName text filed the raw non-wikified result, I mean what 
> exactly *utility  macro *returns.
>
> So, the question is how can I store the result of *utility macro* in 
> non-wikified (raw form) and pass it to the text filed of some tiddler?
>
>
> --Mohammad
>
> -- 
> 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+...@googlegroups.com .
> To post to this group, send email to tiddl...@googlegroups.com 
> .
> Visit this group at https://groups.google.com/group/tiddlywiki.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/tiddlywiki/099d67c2-8bb2-41c9-a372-f0948167bf41%40googlegroups.com
>  
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>
>
>

-- 
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 post to this group, send email to tiddlywiki@googlegroups.com.
Visit this group at https://groups.google.com/group/tiddlywiki.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/tiddlywiki/3f5cf631-8ae6-4096-bdcf-c328891cee48%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [tw5] Storing the result of a macro in raw form and pass it to a tiddler text field

2019-02-21 Thread Jeremy Ruston
Hi Mohammad

Please could you post a complete example?

Many thanks,

Jeremy

> On 21 Feb 2019, at 14:06, Mohammad  wrote:
> 
> 
> One way to store the result of a macro has some parameters is to store it in 
> wikified variable as below
> 
> 
> Example
> See the below code extracted from a longer code. This works correctly. It 
> calls utility, and save the results in newText and then the action-setfield 
> passes it to a tiddler as its text field.
> 
> 
> <$wikify name="newText"  text="""<$macrocall $name="utility" par1=<> 
> par2=<> />""" >
> <$action-setfield $tiddler="""$tidName$""" $field="text" $value=<> />
> 
> 
> 
> 
> 
> Now, assume the result of utility macro is something like below
> 
> This is //italic// and this is {{!!caption}}
> 
> 
> What happens? $Wikify save the wikified result as expected, but I wish to 
> store in tidName text filed the raw non-wikified result, I mean what exactly 
> utility  macro returns.
> 
> So, the question is how can I store the result of utility macro in 
> non-wikified (raw form) and pass it to the text filed of some tiddler?
> 
> 
> --Mohammad
> 
> -- 
> 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 post to this group, send email to tiddlywiki@googlegroups.com 
> .
> Visit this group at https://groups.google.com/group/tiddlywiki 
> .
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/tiddlywiki/099d67c2-8bb2-41c9-a372-f0948167bf41%40googlegroups.com
>  
> .
> For more options, visit https://groups.google.com/d/optout 
> .

-- 
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 post to this group, send email to tiddlywiki@googlegroups.com.
Visit this group at https://groups.google.com/group/tiddlywiki.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/tiddlywiki/72C34E04-8000-4C24-AA90-E8CCC0FC8D79%40gmail.com.
For more options, visit https://groups.google.com/d/optout.