Tinderbox Meetup- Meetup 23OCT22 Working with Action Code, a Step-by-Step Walkthrough
Level | Intermediate |
Published Date | 10/23/22 |
Revision | 1 |
Tags | 5CKMEl, 5Cs of Knowledge Management and Exchange, Action Code, Development, Logging, Parse, Split, Stamp, Text Transformation |
Video Length | 01:31:18 |
Video URL | Tinderbox Meetup 23OCT22 Using Split to Parse Data - YouTube |
Example File | TBX L - Meetup 23OCT22 Using Split to Parse Data.tbx (372.2 KB) |
TBX Version | 9.3 |
Instructor | Michael Becker |
In this meetup, we cover a range of topics: we discuss numbering outlines and do a deep dive into parsing a note name with the split dot operator. We explore the use of attributes, variables, stamps, factions, and logging. We also discuss various edge cases to consider, e.g., how to care for semicolons when working with lists.
The lesson we went through today is in response to a Tinderbox Forum post by @jprint714: How to name $Title and move $Text for notes containing bracketed titles? . This post is the basis for a wonderful tutorial that gets at the root of action code, logging, text transformation, note name path management and more.
Description
Parse the text in an attribute and place the different parts in different attributes.
Learning Outcome
- Know how to use .split operator
- Appreciate the retention of your source data until you’re ready to destroy it
- Missed typed operators can lead to data being inexplicably destroyed (see LO2)
- Logging is your friend, helps you see what’s going on.
- Commenting code is your friends, it helps your future-self
- There is more than one way to do something
- Understand RegEx operational characters and how to escape them
- Tinderbox’s syntax for finding keys in a list or dictionary, e.g. [0], [1].
- User of designators, e.g. a note name, path, to enhance action code.
- The use of variables
- Appreciate the value of cleaning up after yourself
- Bonus: writing in markdown gives a ton of flexibility
- Bonus: some visual affordance really help, e.g., views, separators, and badges
- Bonus: replacing tricky characters, e.g., “;”, in operations with a different delimiter to complete a process and then later refers back to the original.
- Bonus: Triggering functions.
Objective:
Parse this text “{1492: Columbus Sails} Columbus departs from Palos, Spain” that is in the $Name of a note.
- Place the text between the{} in the $Name
- Place the remaining text in $Text
- Do it in a way that leaves no lingering data
The Solution
See the stamps. I’ve produced several for the exercise:
- Reset
- Parse Name Original 0, the stamp that does not work
- Parse Name Original 1, simple stamp
- Parse Name Original 2 Modified, handles “;” in text.
- Parse =Name Refined Eg 1 Use Attribute Placeholder, uses attributes as a placeholder
- Parse Name Refined Eg 2 Use Variable uses variables instead of attributes.
- Tigger Parse Note, triggers a function to parse the note
See the functions, I’ve created two functions.
- fParseNote, parses the note on a boolean trigger
- fReset, resets the note on a boolean trigger
Please support aTbRef and Mark Anderson
Please donate to Market Anderson. Mark has set up a PayPal channel (paypal.com/donate/?hosted_button_id=KEG8GHSSD47BC) to receive donations for his work on aTbRef and the community. I’ve set up a monthly contribution for him. As an aside, I regularly share parts of my Patreon proceeds with him—typically via an Amazon UK gift card—whenever he helps me/us with a big part of what we go over. I thank you for your support of Mark.