[TW5] Need help writing better macro

117 views
Skip to first unread message

infurnoape

unread,
Apr 20, 2016, 12:19:57 AM4/20/16
to tiddl...@googlegroups.com
I've got the following but it is getting long. Any suggestions to condense this?
define reveal-tagpill1a() $:/temp/$(currentTiddler)$!!TagPill1a
define reveal-tagpill2a() $:/temp/$(currentTiddler)$!!TagPill1a
define reveal-tagpill3a() $:/temp/$(currentTiddler)$!!TagPill1a
define reveal-tagpill4a() $:/temp/$(currentTiddler)$!!TagPill1a
define reveal-tagpill5a() $:/temp/$(currentTiddler)$!!TagPill1a
define reveal-tagpill6a() $:/temp/$(currentTiddler)$!!TagPill1a
define reveal-tagpill7a() $:/temp/$(currentTiddler)$!!TagPill1a
define reveal-tagpill8a() $:/temp/$(currentTiddler)$!!TagPill1a
define reveal-tagpill9a() $:/temp/$(currentTiddler)$!!TagPill1a

<<toggle TagPill1a>><br>
<$reveal <$reveal type="match" state=<<reveal-tagpill1a>> text="$:/TagPill1b">
Some content<br>
</$reveal>
<<toggle TagPill2a>><br>
<$reveal <$reveal type="match" state=<<reveal-tagpill2a>> text="$:/TagPill2b">
Some content<br>
</$reveal>
<<toggle TagPill3a>><br>
<$reveal <$reveal type="match" state=<<reveal-tagpill3a>> text="$:/TagPill3b">
Some content<br>
</$reveal>
<<toggle TagPill4a>><br>
<$reveal <$reveal type="match" state=<<reveal-tagpill4a>> text="$:/TagPill4b">
Some content<br>
</$reveal>
<<toggle TagPill5a>><br>
<$reveal <$reveal type="match" state=<<reveal-tagpill5a>> text="$:/TagPill5b">
Some content<br>
</$reveal>
<<toggle TagPill6a>><br>
<$reveal <$reveal type="match" state=<<reveal-tagpill6a>> text="$:/TagPill6b">
Some content<br>
</$reveal>
<<toggle TagPill7a>><br>
<$reveal <$reveal type="match" state=<<reveal-tagpill7a>> text="$:/TagPill7b">
Some content<br>
</$reveal>
<<toggle TagPill8a>><br>
<$reveal <$reveal type="match" state=<<reveal-tagpill8a>> text="$:/TagPill8b">
Some content<br>
</$reveal>
<<toggle TagPill9a>><br>
<$reveal <$reveal type="match" state=<<reveal-tagpill9a>> text="$:/TagPill9b">
Some content<br>
</$reveal>

Happy Connecting. Sent from my Sprint Samsung Galaxy S® 5

PMario

unread,
Apr 20, 2016, 2:41:38 AM4/20/16
to TiddlyWiki
Hi Andrew,

It would be easier, if you describe, what you want to achieve, instead of posting some code and let us reverse engineer it, to find out (guess) what you want.
Also if I copy paste the code to tiddlywiki.com it doesn't do anything.

-mario


infurnoape

unread,
Apr 20, 2016, 8:31:39 AM4/20/16
to tiddl...@googlegroups.com
You are right, I really went at this from the wrong angle. Ok, so I would like to have slider or toggle buttons that when clicked, they reveal some text. The problem is that in order to be able to reset all of them with a reset button, I had to store the targets of buttons in fields of a temp tiddler using a global macro. Reset, basically deletes the temp tiddler. I would like to figure out a macro that uses the button name so I can define one button and reveal and then transclude several times and each with the names of the toggle buttons. I'm probably trying to get macro results from within another macro. Not possible right?



Happy Connecting. Sent from my Sprint Samsung Galaxy S® 5


--
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/db91eb48-5e7c-49fd-93d0-241ceca40369%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

PMario

unread,
Apr 20, 2016, 11:30:18 AM4/20/16
to TiddlyWiki
On Wednesday, April 20, 2016 at 2:31:39 PM UTC+2, Andrew wrote:
You are right, I really went at this from the wrong angle. Ok, so I would like to have slider or toggle buttons that when clicked, they reveal some text. The problem is that in order to be able to reset all of them with a reset button, I had to store the targets of buttons in fields of a temp tiddler using a global macro. Reset, basically deletes the temp tiddler. I would like to figure out a macro that uses the button name so I can define one button and reveal and then transclude several times and each with the names of the toggle buttons. I'm probably trying to get macro results from within another macro. Not possible right?

Let me recap, so I can see if I did understand it.

- "Some content" should be shown/hidden with the help of a toggle button
- There should be a "reset button" that deletes all state tiddlers
- The tiddler content, to modify the states should be relatively easy to read.

some questions

1) What do you mean with "some content"?

Since TW is highly optimized for tiddlers. As in "the tiddler is the thing" for me "some content" means tiddler content. So it will be easy to transclude. eg: with a macro like this: <<toggleMe tiddlerName>>

2) should the state "show/hide" tiddlers be persistent between sessions

This is important, since we need to know if we use "state" or "temp" variables

3) Are there any sliders, that need to be open by default

This makes a difference for the macro code

---------------

I'm thinking about a maro like this

<<toggleMe tiddlerName>> produces 2 buttons [show] / [hide]
[show] / [hide]  replace each other when active


possible state tiddler names are: 
 - $:/state/toggleMe/tiddlerName  for session persistent tiddlers
 - $:/temp/toggleMe/tiddlerName  for temporary state tiddlers

<<resetMe>> will delete all state or temp tiddlers with one click, so all "sliders" are closed

There may be "groups of sliders" eg: <<toggleMe tiddlerName groupName>>

so <<resetMe groupName>> just deletes all states that belong to one group
eg:

<<toggleMe asdf>>  uses a state tiddler  $:/state/toggleMe/-asdf

<<toggleMe aaaa group:mario>> uses a state tiddler $:/state/toggleMe/mario-aaaa
<<toggleMe bbbb group:mario>> uses a state tiddler $:/state/toggleMe/mario-bbbb

so

<<resetMe group:mario>> deletes all states that start with tiddler $:/state/toggleMe/mario

I'm testing this idea at the moment. ... The funny thing is, that the code is actually simpler than this description :)

feedback needed
have fun!
mario




infurnoape

unread,
Apr 21, 2016, 2:40:23 AM4/21/16
to tiddl...@googlegroups.com
Thank you so much for all your help. Here is sort of what I ended up with:

\define reveal1(button)
<<toggle $button$>><br>
<$reveal type="match" state="$:/temp/$(currentTiddler)$!!$button$" text="$:/$button$_b">
<object type='text/html' data='http://www.tiddlywiki.com/#$button$' style='width: 100%;'/><br>
</$reveal>
\end

<<reveal1 TagPill1>>


Happy Connecting. Sent from my Sprint Samsung Galaxy S® 5


-------- Original message --------
From: PMario <pmar...@gmail.com>
Date: 4/20/16 8:30 AM (GMT-07:00)
To: TiddlyWiki <tiddl...@googlegroups.com>
--
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.
Reply all
Reply to author
Forward
0 new messages