[tw] Re: Using Macro Substitution as a filter parameter

2015-02-25 Thread Alan Finger
Got it. How can I pass variable data to a Javascript macro, then?

Alan

On Wednesday, February 25, 2015 at 3:53:02 AM UTC-5, Astrid Elocson wrote:

 Hi Alan,

 Macro parameters are *not* parsed as WikiText until they are returned to 
 a WikiText context. They're just inert strings of characters. This means 
 your JavaScript is receiving strings that start with *{{* and end with 
 *}}*. Only once the macro call has returned will its result be parsed as 
 WikiText and the transclusions detected and acted upon.

 – æ


-- 
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.
For more options, visit https://groups.google.com/d/optout.


[tw] Re: Using Macro Substitution as a filter parameter

2015-02-25 Thread Jed Carty
The $macrocall widget should do what you want. It is supposed to evaluate 
inputs before passing them to a macro.

Alternately you can use set widgets and macros:

\define thisMacro()
 javascriptmacro $(macroinput)$
 \end

 $set name=macroinput value=somevalue
 thisMacro
 /$set


This should evaluate pass the variable correctly.

I have a brief and probably not very clear explanation on my site 
http://inmysocks.tiddlyspot.com/#Concatenating%20Strings%20-%20What%20Breaks 
about concatenating strings, but the problem happen for the same reason and 
are fixed in the same way.

-- 
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.
For more options, visit https://groups.google.com/d/optout.


[tw] Re: Using Macro Substitution as a filter parameter

2015-02-25 Thread Astrid Elocson
Hi Alan,

Macro parameters are *not* parsed as WikiText until they are returned to a 
WikiText context. They're just inert strings of characters. This means your 
JavaScript is receiving strings that start with *{{* and end with *}}*. 
Only once the macro call has returned will its result be parsed as WikiText 
and the transclusions detected and acted upon.

– æ

-- 
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.
For more options, visit https://groups.google.com/d/optout.


[tw] Re: Using Macro Substitution as a filter parameter

2015-02-24 Thread Alan Finger
Hi Tobias,

I'm finally getting back to this.

Here's a simple Javascript macro that displays the value of three 
parameters and the results of a comparison to a constant:


/**
 * Created by afinger on 2/24/2015.
 */
/*
Macro to build search string from section and company parameters
*/

(function(){
/*jslint node: true, browser: true */
/*global $tw: false */
use strict;
/*
Information about this macro
*/
exports.name = build_search_string;
exports.params = [
{name: section, default: Any},
{name: source, default: Any},
{name: text, default: }
];
/*
Run the macro
*/
exports.run = function(section, source, text) {

var foo= | + section +  |  + source +  |  + text +  |\n + | + 
(section == Any ) +   |  + (source == Any) +  |  + (text == ) +  
|\n
return foo
};
})();

Invoking it from a WikiText macro:

\define ShowResult()

build_search_string  {{$:/.af/SearchBy/params!!section_sel}}  
{{$:/.af/SearchBy/params!!source_sel}} 
{{$:/.af/SearchBy/params!!searchtext}} 


\end
{{$:/.af/SearchBy/form}}
ShowResult

It always shows the correct value but the comparison is always false.


If I replace the transclusions with constants, it works correctly. What's 
going on?

Alan




On Wednesday, January 28, 2015 at 7:02:16 PM UTC-5, Tobias Beer wrote:

 Looks like a good place to use a javascript macro...


 That may indeed be a viable way to achieve this...

 *#1427 allow text-references and variables anywhere in a filter expression*
 https://github.com/Jermolene/TiddlyWiki5/issues/1427

 @Jeremy, (how) can a js macro acces a variable number of parameters?

 Best wishes, Tobias.


-- 
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.
For more options, visit https://groups.google.com/d/optout.


[tw] Re: Using Macro Substitution as a filter parameter

2015-01-28 Thread Alan Finger

I mean that the operator  section{$:/temp/findby!!section} should only be 
applied to the filter if the field value is not Any

I'll try to post an example in the next day or so. 

Alan

On Wednesday, January 28, 2015 at 2:43:44 AM UTC-5, Stephan Hradek wrote:



 Am Mittwoch, 28. Januar 2015 08:42:13 UTC+1 schrieb Stephan Hradek:

 Could you please post a fully (non-)working example? I have difficulties 
 in understanding what you're trying to do by just looking at an image. I'd 
 prefer to be able to play around a bit with real data and not try to make 
 up test data which I made up on my own and which need not match what you 
 had in mind.

 I'm especially extremely astonished about this part: 
 [title[$:/tmp/findby]!section[Any]] What do you think should this do? I 
 have no clue what the meaning should be. Especially because there is no 
 such filter like section.


 P.S. Maybe I know! that part means: Get the tiddler  titled 
 $:/tmp/findby but only if it's field section does not contain Any!?


-- 
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.
For more options, visit https://groups.google.com/d/optout.


[tw] Re: Using Macro Substitution as a filter parameter

2015-01-28 Thread Tobias Beer
Thanks, Jed,

That's a cool example

If you know what the filters will be you can use the select widget to set a 
 field to the entire filter string and use a text reference for the filters.


Added here: filter from field @ filters 
http://filters.tiddlyspot.com/#filter%20from%20field.

Best wishes, Tobias.

-- 
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.
For more options, visit https://groups.google.com/d/optout.


[tw] Re: Using Macro Substitution as a filter parameter

2015-01-28 Thread Alan Finger
That works well for one variable. The problem is that I have two: section 
and sourcedoc so I need to try to get concatenation working.

Alan

On Wednesday, January 28, 2015 at 9:02:17 AM UTC-5, Tobias Beer wrote:

 Thanks, Jed,

 That's a cool example

 If you know what the filters will be you can use the select widget to set 
 a field to the entire filter string and use a text reference for the 
 filters.


 Added here: filter from field @ filters 
 http://filters.tiddlyspot.com/#filter%20from%20field.

 Best wishes, Tobias.


-- 
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.
For more options, visit https://groups.google.com/d/optout.


[tw] Re: Using Macro Substitution as a filter parameter

2015-01-28 Thread Tobias Beer


 Looks like a good place to use a javascript macro...


That may indeed be a viable way to achieve this...

*#1427 allow text-references and variables anywhere in a filter expression*
https://github.com/Jermolene/TiddlyWiki5/issues/1427

@Jeremy, (how) can a js macro acces a variable number of parameters?

Best wishes, Tobias.

-- 
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.
For more options, visit https://groups.google.com/d/optout.


[tw] Re: Using Macro Substitution as a filter parameter

2015-01-27 Thread Stephan Hradek
Could you please post a fully (non-)working example? I have difficulties in 
understanding what you're trying to do by just looking at an image. I'd 
prefer to be able to play around a bit with real data and not try to make 
up test data which I made up on my own and which need not match what you 
had in mind.

I'm especially extremely astonished about this part: 
[title[$:/tmp/findby]!section[Any]] What do you think should this do? I 
have no clue what the meaning should be. Especially because there is no 
such filter like section.

-- 
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.
For more options, visit https://groups.google.com/d/optout.


[tw] Re: Using Macro Substitution as a filter parameter

2015-01-27 Thread Stephan Hradek


Am Mittwoch, 28. Januar 2015 08:42:13 UTC+1 schrieb Stephan Hradek:

 Could you please post a fully (non-)working example? I have difficulties 
 in understanding what you're trying to do by just looking at an image. I'd 
 prefer to be able to play around a bit with real data and not try to make 
 up test data which I made up on my own and which need not match what you 
 had in mind.

 I'm especially extremely astonished about this part: 
 [title[$:/tmp/findby]!section[Any]] What do you think should this do? I 
 have no clue what the meaning should be. Especially because there is no 
 such filter like section.


P.S. Maybe I know! that part means: Get the tiddler  titled $:/tmp/findby 
but only if it's field section does not contain Any!?

-- 
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.
For more options, visit https://groups.google.com/d/optout.


[tw] Re: Using Macro Substitution as a filter parameter

2015-01-27 Thread Alan Finger
Thanks for some good ideas! I may be missing it but is there a way to set 
the value of a field programmatically? The action-setfield widget only 
works inside a button.

On Tuesday, January 27, 2015 at 11:26:43 PM UTC-5, Jed Carty wrote:

 If you know what the filters will be you can use the select widget to set 
 a field to the entire filter string and use a text reference for the 
 filters.

 $select field='filter_field'
 option value='[!is[tag]!is[system]]'Some name/option
 option value='[!is[tag]!is[system]]'Another name/option
 /$select

 /$select

 $list filter={{!!filter_field}}

 /$list

 Where you add an option to the select widget for each filter string.

 If you need more flexibility you could have a sequence of selections that 
 build a string for the filter operators. Like the examples here, but each 
 selection would set a filter operator instead of part of a url 
 http://inmysocks.tiddlyspot.com/#Concatenating%20text%20to%20make%20dynamic%20URLs

 Does that help?


-- 
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.
For more options, visit https://groups.google.com/d/optout.


[tw] Re: Using Macro Substitution as a filter parameter

2015-01-27 Thread Jed Carty
If you know what the filters will be you can use the select widget to set a 
field to the entire filter string and use a text reference for the filters.

$select field='filter_field'
option value='[!is[tag]!is[system]]'Some name/option
option value='[!is[tag]!is[system]]'Another name/option
/$select

/$select

$list filter={{!!filter_field}}

/$list

Where you add an option to the select widget for each filter string.

If you need more flexibility you could have a sequence of selections that 
build a string for the filter operators. Like the examples here, but each 
selection would set a filter operator instead of part of a url 
http://inmysocks.tiddlyspot.com/#Concatenating%20text%20to%20make%20dynamic%20URLs

Does that help?

-- 
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.
For more options, visit https://groups.google.com/d/optout.


[tw] Re: Using Macro Substitution as a filter parameter

2015-01-27 Thread Tobias Beer
You (currently) need to use variables in filters like so...

[field-foovariable-bar]

not...

[field-foo[variable-bar]]

or...

[field-foovariable-bar]

For more on parameters and variables, see...

http://pv5.tiddlyspot.com

Best wishes, Tobias.

-- 
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.
For more options, visit https://groups.google.com/d/optout.


[tw] Re: Using Macro Substitution as a filter parameter

2015-01-27 Thread Alan Finger
Hi Tobias,

I don't think that's going to work for me as I want to conditionally 
include entire filter operators in the filter. Depending the content of 
some fields (Any means no filter), i want to get

[!is[tag]!is[system]]
[!is[tag]!is[system][field1[value1]]
[!is[tag]!is[system]field1[value1]field2[value2]]
[!is[tag]!is[system][field2[value2]]

etc.

There will be at 4 combinations now but I may want to expand that later. 

Is there a more elegant way to approach this?

Alan






On Tuesday, January 27, 2015 at 9:17:49 PM UTC-5, Tobias Beer wrote:

 You (currently) need to use variables in filters like so...

 [field-foovariable-bar]

 not...

 [field-foo[variable-bar]]

 or...

 [field-foovariable-bar]

 For more on parameters and variables, see...

 http://pv5.tiddlyspot.com

 Best wishes, Tobias.


-- 
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.
For more options, visit https://groups.google.com/d/optout.