New and making a lot of mistakes

97 views
Skip to first unread message

Christopher Londrie

unread,
Apr 2, 2016, 5:49:29 PM4/2/16
to TiddlyWiki
I'm able to do this at all thanks to Tobias Beer's really easy to use "Random" plugin. http://tobibeer.github.io/tw5-plugins/#random

 
<!-- Generating a random corp -->

<!-- Generate the First Name from tiddlers starting with GenSource: that also have the tags "Corp" and "FirstName" and use the "corpname" field as the value -->
<$set name="FirstName" filter="[prefix[GenSource:]tag[Corp]tag[FirstName]field[corpname]random[]]">

<!-- Generate the Last Name from tiddlers starting with GenSource: that also have the tags "Corp" and "LastName" and use the "corpname" field as the value -->
<$set name="LastName" filter="[prefix[GenSource:]tag[Corp]tag[LastName]field[corpname]random[]]">

<!-- Preview the Generate Corp -->
<table>
<tr><th>Name </th> <td><<FirstName>></td></tr>
</table>

<!-- Create New Tiddler with the generated information prefilled -->
<$button>Generate Corp
<$action-sendmessage $message="tm-new-tiddler" title="Corp:"<<FirstName>> tags="Corp Corp:<<FirstName>>-<<LastName>>"/>
</$button>
</$set>

This is my current batch of code, I've got it partially working but am stumped on a few things:

1) If I remove the field[corpname] I'm able to successfully pull the titles of the GenSource: tiddler(s), however with it, I get null as a result, I've made absolutely sure that I've made no spelling mistakes and the GenSource tiddler does indeed have that field, am I specifying this wrong?

2) How do I properly insert tags using the variables, they're considered literal inside the quotes, and ignored outside of them.

3) Am I going about this in an absurd manner?

Mark S.

unread,
Apr 2, 2016, 6:14:01 PM4/2/16
to TiddlyWiki
Does it work better if you use "get[corpname]" instead of "field[corpname]" ?

Mark

Hegart Dmishiv

unread,
Apr 2, 2016, 6:28:24 PM4/2/16
to TiddlyWiki, Andrew Myers

Hi Christopher,

Sorry, I don't have any answers for your questions, but I just wanted to say that I was impressed with what you've done here. I've spent the last week or two trying to achieve something similar, except I'm using a Google Sheets spreadsheet as my source data, and creating pseudo-random company tiddlers, with pseudo-random contact details, employees, and just today I've added individual communications with those companies, as per the screenshot example below.


I'm doing this for my {{DesignWrite}} semester project, TiddlyCRM. I hadn't considered using TobiBeer's random[ ] filter plugin for this before. I guess the main difference between your solution and mine is that you have to have the tiddlers in your wiki first to create new random ones from them. Mine starts with a completely blank TiddlyWiki, and I just import the tiddlers from JSON files, via the CSV to JSON converter, from the spreadsheet. Interesting to see a different approach to this. Thanks for sharing.

Hegart.

Knut Franke

unread,
Apr 3, 2016, 9:06:12 AM4/3/16
to TiddlyWiki
On Saturday, April 2, 2016 at 11:49:29 PM UTC+2, Christopher Londrie wrote:
1) If I remove the field[corpname] I'm able to successfully pull the titles of the GenSource: tiddler(s), however with it, I get null as a result, I've made absolutely sure that I've made no spelling mistakes and the GenSource tiddler does indeed have that field, am I specifying this wrong?

As Mark said, you probably want `get[corpname]`.

2) How do I properly insert tags using the variables, they're considered literal inside the quotes, and ignored outside of them.
 
Common pitfall. At the top of your tiddler, define a macro, like so:

\define createCorpTiddler()
<$action-sendmessage $message="tm-new-tiddler" title="Corp:$(FirstName)$" tags="Corp Corp:$(FirstName$)-$(LastName$)"/>
\end

Then, inside your button, insert this macro:

<$button>Generate Corp
<
<createCorpTiddler>>
</$button>

Basically, you need the `$(variable)$` syntax for this kind of interpolation, but that is only available in macro bodies.

3) Am I going about this in an absurd manner?

Dunno. Life is absurd. This bit doesn't strike me as particularly more so than the rest.


Cheers,
Knut

Christopher Londrie

unread,
Apr 3, 2016, 11:52:15 AM4/3/16
to TiddlyWiki
Most excellent and many thanks!  With those new knowledge bits I can move on to construct the entire thing.

Christopher Londrie

unread,
Apr 3, 2016, 12:01:28 PM4/3/16
to TiddlyWiki, mye...@sunyit.edu
I think that's partly because my end goals are slightly different. I need the ability to generate these while half-distracted and from specific and custom lists, and then have them instantly available.  Most time I won't need to generate in bulk.  This means a button I can press and dump out a quick answer is perfect for running a tabletop game and needing to generate a new patron for my players.  Yours feels far more heavy duty!

Hegart Dmishiv

unread,
Apr 3, 2016, 2:14:39 PM4/3/16
to TiddlyWiki, mye...@sunyit.edu
Hi Christopher,

Thanks for sharing a little more about your project. I see the distinction now: fantasy vs reality. Even so, your solution does give me pause for thought, and the answers you've been getting to your questions may well have application for what I'm doing as well. Also, your comment about being "half-distracted" is something I should take onboard as well, as I fully expect the end users of my system will be on the phone or deeply in some other communication with their Contact at the time they are capturing data into the system. So thanks again, your fantasy project may well have bearing on a real-world system!

Hegart.
Reply all
Reply to author
Forward
0 new messages