Hi Mark,

I am not sure I understand what you are saying (I am not a real 
programmer!) so until I understand it, I will try Eric solution.

Philippe

On Monday, 31 October 2016 23:39:53 UTC, Mark S. wrote:
>
> Macros will drive you nuts, because they look for all the world like 
> regular programming functions that you may encounter in any programming 
> language. But they're not.
>
> Since you're willing to make changes to the actual macro code, I can pass 
> on my "trick" I've used in javascript macros. If memory serves, what I've 
> done in similar situations is to make input and output variables in the 
> calling environment. E.g. 
>
> <$set indate={{!!bestbefore}}.> ...
> <$set outval="unused"> ...
>
> Then inside the javascript macro, fetch the value like:
>
> var indate = this.getVariable("indate") ;
>
> and after passing this to the program, return the value like:
>
> this.setVariable("outval",whatever_the_return_variable_is) ;
>
>
> Then (still inside the <$set>...</$set> tags) use the "outval" result in 
> your reveal widget.
>
> I don't know for sure if this will work for you, but it's the kind of 
> thing that I've used in the past.
>
> Remember to back up your TW before messing with javascript macros (since a 
> crash can lock you out) and that you have refresh your TW before javascript 
> macros will take effect. 
>
> Good luck!
> Mark
> On Monday, October 31, 2016 at 3:45:29 PM UTC-7, Philippe Le Toquin wrote:
>>
>> Hello,
>>
>> I have looking all over the place and experimented a lot but I can't find 
>> how to do what I want to achieve.
>>
>> I have a list of item (they are ingredients) that contains some fields 
>> .One of them is a best before date.
>>
>> I then list the ingredient using that code to display them as well as the 
>> number of days until they expire.
>>
>> <$list filter="[!has[draft.of]tag[Stocks]]">
>>
>> * <$link to={{!!title}}><$view field="title"/> </$link>@@color:red;( to 
>> be discarded : <$macrocall $name="day-left" bestbefore={{!!bestbefore}} 
>> />)@@ 
>>
>> </$list>
>>
>> The macro is based on day-diff.js that I modified to only take one day 
>> and return YES or NO. 
>>
>> What I would ideally like to do is that the text in red (to be discarded) 
>> only appears if the return of the macro is YES.
>>
>> I would like to use the RevealWidget but can't make it works. Here is 
>> what I tried
>>
>>
>> * <$link to={{!!title}}><$view field="title"/> </$link> <$reveal 
>> type="match" state="<$macrocall $name="day-left" 
>> bestbefore={{!!bestbefore}} />" text="YES">@@color:red;( to be discarded 
>> )@@ </$reveal>
>>
>> but the result of that is not working. Instead it displays:
>>
>>
>>
>>    - Item1
>>
>> <$reveal type="match" state="YES" text="YES">( to be discarded ) 
>> </$reveal>
>>
>>    - Item2
>>
>> <$reveal type="match" state="NO" text="YES">( to be discarded ) 
>> </$reveal>
>>
>>
>>
>>
>>
>> So my question is : Is it possible to achieve what I want?
>>
>

-- 
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 [email protected].
To post to this group, send email to [email protected].
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/94c1edd2-8c93-4784-b8d1-b35199719508%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to