[tw] Re: [TW5] How to create a button that replaces a field value based on the current field value?

2015-10-04 Thread BJ
Hi Antaneus,

you ca
this.getVariable("

On Saturday, October 3, 2015 at 10:53:12 PM UTC+1, Antaeus Feldspar wrote:
>
> Tobias, Mark, thank you for your suggestions...  The use of SetWidgets to 
> set variables is something I didn't understand before, and I can tell I'll 
> eventually be able to use it to achieve a much cleaner solution.
>
> Right now, though, I still have a problem that's completely blocking me: 
>  how do I get the *results* of a macro call into a variable?
>
> The project I'm working on will involve dates.  I can write a macro in 
> Javascript which takes a date in TW's format and adds or subtracts a given 
> amount of time.  But how can I have TiddlyWiki call that macro *and* store 
> it in a field rather than simply rendering the result on the screen?
>
You should be able to use Tobias suggestion

<$set name="js-macro-link-text" value={{!!test}}>
<$button set=!!test setTo=<>>Test button

In your javascript macro you can read the value of "js-macro-link-text" 
like so:

var input = this.getVariable("js-macro-link-text");

cheers

BJ

-- 
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 http://groups.google.com/group/tiddlywiki.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/tiddlywiki/3f2fdefd-6dc0-4243-90a2-754753ff0653%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[tw] Re: [TW5] How to create a button that replaces a field value based on the current field value?

2015-10-03 Thread 'Mark S.' via TiddlyWiki
Hello,

What I've found so far is:

1) Macros and widgets may look something like javascript functions and 
variables, but they often behave differently
2) You can't use a widget's output inside a widget
3) You can use a macro inside a widget IF it doesn't have a parameter
4) Therefore, you will most often need to use <$set ...> to set a variable 
to be used by a macro that gets fed to your widget

Mark

On Saturday, October 3, 2015 at 10:49:00 AM UTC-7, Antaeus Feldspar wrote:
>
> Or, to express it a different way from the subject line, how can I create 
> a button widget that will:
> a) take the current value of a tiddler field;
> b) use that current value as a parameter to a macro to calculate a new 
> value; and
> c) put that new value back into the tiddler field that was read?
>
> WHAT I TRIED:
>
> I've tried various things; my most recent attempt is this:
>
> <$button set=!!test setTo=<$macrocall $name=".js-macro-link" 
> text={{!!test}}/> >Test button
>
> However, the parser can't seem to handle the angle brackets of the 
> macrocall widget appearing in the middle of the button widget declaration. 
>  Everything after the "/>" that closes the macrocall widget appears as 
> WikiText following a blank button.
>
> Before that I tried calling the macro through the standard syntax, and 
> discovered that (unless there's some way to do it that I missed) you can't 
> use a macro call as an element attribute.
>
> It occurred to me that since a ButtonWidget can contain multiple 
> ActionWidgets, that might be the solution - except that there's nothing in 
> the documentation guaranteeing an order in which such widgets execute, so 
> assigning the output of a macro to a temporary tiddler and then copying it 
> back to the original field does not seem to be an option.
>
> PLEASE NOTE:
>
> Please note that I am trying to get an answer to the GENERAL question, not 
> "how do I get the same effect as if I was applying this particular macro?" 
>  I am sure that there would be a simple way to apply the effect of THIS 
> macro with template transclusion, but that does not answer my question, 
> because sooner or later I will be using the technique for Javascript macros 
> that do mathematical calculations.
>
> DOCUMENTATION SUGGESTION:
>
> A chart which shows the various forms of data sourcing (plain text, 
> TextReference, macro output, etc.) in columns and then shows in rows what 
> they can and can't be used for (macro parameters, element attributes, etc.) 
> would be useful.
>
>

-- 
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 http://groups.google.com/group/tiddlywiki.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/tiddlywiki/b9f31e05-bf09-4170-a63e-5e57225f3cc0%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[tw] Re: [TW5] How to create a button that replaces a field value based on the current field value?

2015-10-03 Thread Tobias Beer
Hi Antaeus,

One (perhaps) clumsy way to go about it would be
to not try and pass a ("text") *parameter* to your inner macro,
but rather set a *variable* outside of all that via the SetWidget,
so you could then do...

<$set name="js-macro-link-text" value={{!!test}}>
<$button set=!!test setTo=<>>Test button


Best wishes,

— tb

-- 
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 http://groups.google.com/group/tiddlywiki.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/tiddlywiki/adf5e48f-4791-4e5d-ad87-c5609f8ec758%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[tw] Re: [TW5] How to create a button that replaces a field value based on the current field value?

2015-10-03 Thread Tobias Beer
 Hi
 

> 4) Therefore, you will most often need to use <$set ...> to set a variable 
> to be used by a macro that gets fed to your widget
>

Not much of a fan of this part either...

Best wishes,

— tb 

-- 
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 http://groups.google.com/group/tiddlywiki.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/tiddlywiki/203c8c53-2674-45e6-bd1d-ec3053707dfd%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[tw] Re: [TW5] How to create a button that replaces a field value based on the current field value?

2015-10-03 Thread Antaeus Feldspar
By the way, if macros with parameters don't work as widget attributes...  does 
that mean that the last example shown for the MacroCall Widget doesn't actually 
work?

>From http://tiddlywiki.com/#MacroCallWidget :

<$macrocall $name="italicise" text=<>/>

Does this not work, and it got included as an example without testing?  Or, if 
it does work, why does it work when other attempts to use macros as attributes 
fail?

-- 
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 http://groups.google.com/group/tiddlywiki.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/tiddlywiki/feb97456-c7b2-488b-beb0-b0916de7e6a8%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[tw] Re: [TW5] How to create a button that replaces a field value based on the current field value?

2015-10-03 Thread 'Mark S.' via TiddlyWiki
Apparently you can use static text. But this is of limited value IMO. What 
you want is something more like <> .

I just know whenever I've tried making a bit of simple widget code work 
with some macros, I usually end up needing to use <$set>.

Mark

On Saturday, October 3, 2015 at 3:23:44 PM UTC-7, Antaeus Feldspar wrote:
>
> By the way, if macros with parameters don't work as widget attributes... 
>  does that mean that the last example shown for the MacroCall Widget 
> doesn't actually work?
>
> From http://tiddlywiki.com/#MacroCallWidget :
>
> <$macrocall $name="italicise" text=< the text to be italicised">>/>
>
> Does this not work, and it got included as an example without testing? 
>  Or, if it does work, why does it work when other attempts to use macros as 
> attributes fail?
>
>

-- 
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 http://groups.google.com/group/tiddlywiki.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/tiddlywiki/ddaf33ec-3b96-47c0-a4d0-89e5ac16700e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[tw] Re: [TW5] How to create a button that replaces a field value based on the current field value?

2015-10-03 Thread Antaeus Feldspar
Tobias, Mark, thank you for your suggestions...  The use of SetWidgets to set 
variables is something I didn't understand before, and I can tell I'll 
eventually be able to use it to achieve a much cleaner solution.

Right now, though, I still have a problem that's completely blocking me:  how 
do I get the *results* of a macro call into a variable?

The project I'm working on will involve dates.  I can write a macro in 
Javascript which takes a date in TW's format and adds or subtracts a given 
amount of time.  But how can I have TiddlyWiki call that macro *and* store it 
in a field rather than simply rendering the result on the screen?

-- 
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 http://groups.google.com/group/tiddlywiki.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/tiddlywiki/8782aa2c-69ae-48a0-968d-dee916f2d037%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.