Thanks for your help! I see that nested lists are very useful. And I didn't know about transcluding in filter notation like that. I see what you're saying about the second part being sensitive to typos. I realized that in making these tiddlers that I am trying to change, I have used many short-hands for referring to 'passive Perception'. I have used 'passive perception', 'passive Perception', 'PP', and 'pp'. Very sloppy of me, I will admit, though i have never been formally trained in coding so I am learning the housekeeping as I go. Because of this, I decided to try your assigned exercise! I don't think I was able to include a fail-safe, but rather made it more fool proof. Check out what I have:
__''Step 1'': Select precise language used in "senses" field:__ <$select tiddler = "$:/TempPassivePerceptionTest" > <option>---</option> <option>passive perception</option> <option>passive Perception</option> <option>PP</option> <option>pp</option> </$select> <hr> __''Step 2'': Grab passive Perception from "senses" field and put it in its own field:__ <$set name = 'y' value = {{$:/TempPassivePerceptionTest}}> <$button>Create Passive Perception Fields <$list filter="[regexp:senses<y>]"> <$list filter = "[<currentTiddler>get[senses]split[ ]last[1]]" variable = 'x'> <$action-setfield pp=<<x>>/> </$list> </$list> </$button> <$set> <hr> __''Step 3'': Get rid of the 'passive Perception' and score from the "senses" field:__ <$set name = 'y' value = {{$:/TempPassivePerceptionTest}}> <$button>Change Senses <$list filter = "[regexp:senses<y>]"> <$list filter = "[<currentTiddler>get[senses]split[ ]last[1]]" variable = 'x'> <$action-setfield senses={{{[<currentTiddler>get[senses]removesuffix<suffix>] }}}/> </$list> </$list> </$button> </$set> <hr> <!-- List of tiddlers and relevant values --> <span style = "color:darkred;"> ''List of affected tiddlers | Last Item in the "senses" field | Contents of "pp" field'' </span> <$set name = 'y' value = {{$:/TempPassivePerceptionTest}}> <$list filter = "[regexp:senses<y>]"> <$list filter = "[<currentTiddler>get[senses]split[ ]last[1]]" variable = 'x'> <br><$link to = {{!!title}}> {{!!title}} </$link> | <<x>> | {{!!pp}} </$list> </$list> </$set> On Sunday, April 12, 2020 at 9:41:44 PM UTC-4, Mark S. wrote: > > Be sure to have a backup file before trying this! > > This method requires you to hit a button twice. First to populate > "passiveperception", and then again to trim the end of senses. > This is because you might not want to push the second button. > > Note that the second part in particular will be very sensitive to typos. > If it's wrong even by case or extra white space, it will change "sense" to > nothing! > Sorry, there should be a fail safe mechanism, but it would take too long. > Putting in a fail safe is left to the > student as an exercise. ;-) > > Good luck! > > \define passiveperception() passive Perception $(x)$ > <$button>Change All Passive Perception > > <$list filter="[has[senses]]"> > <$list filter = "[<currentTiddler>get[senses]split[ ]last[1]]" variable = > 'x'> > <$action-setfield passiveperception=<<x>>/> > > <!-- <<x>> <br/>this is so I could verify that the variable 'x' held the > correct value --> > </$list> > </$list> > > </$button> > > <$button>Change Senses > > <$list filter="[has[senses]]"> > <$list filter = "[<currentTiddler>get[senses]split[ ]last[1]]" variable = > 'x'> > <$action-setfield > senses={{{[<currentTiddler>get[senses]removesuffix<passiveperception>] }}}/ > > > > <!-- <<x>> <br/>this is so I could verify that the variable 'x' held the > correct value --> > </$list> > </$list> > > </$button> > > > > On Sunday, April 12, 2020 at 3:11:45 PM UTC-7, Jalen MichalsLevy wrote: >> >> Hi there, >> >> I have many tiddlers (of the same unique type), which contain the field >> "senses". The 'senses' field contains values that look something like this: >> "Darkvision 60ft., passive Perception 12". Now, it has come to my attention >> that it would be far more useful for Passive Perception to be its own field >> with its own numeric value. Instead of doing this manually, as there are >> hundreds of tiddlers like this, I want to make a button that will do this >> by batch. Basically, I want to take the last word (which is actually a >> number in all cases) from the 'senses' field and put it into a new >> "passive-perception field". I have played around with the list widget and >> filter notation, trying to use the 'enlist' operator and the 'last' >> operator, and was able to make it work for a single tiddler (see below). >> But I think I am definitely missing something that ties it all together and >> makes it work for a batch. Any help would be appreciated. Bonus points if >> you can also tell me how to delete the words 'passive Perception ##' from >> the end of the 'senses' field. Thank you! >> >> Code for a single tiddler: >> <$list filter = "[{Boar!!senses}split[ ]last[1]]" variable = 'x'> >> >> <<x>> <!-- this is so I could verify that the variable 'x' held the >> correct value --> >> >> <$button set = "Boar!!passiveperception" setTo = <<x>> > >> Change Boar's Passive Perception >> </$button> >> >> </$list> >> >> Thank you! >> >> -Jalen >> > -- 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 view this discussion on the web visit https://groups.google.com/d/msgid/tiddlywiki/559e2b49-227f-41b8-be5b-ffa8d17a9e91%40googlegroups.com.