How to debug TW code

91 views
Skip to first unread message

Bob Jansen

unread,
Sep 16, 2020, 7:28:07 AM9/16/20
to TiddlyWiki
I am trying to debug some TW code that is not working as expected. The code is in a macro. I have tried to display the value of a variable but that does not seem possible from within a macro.

Are there any debugging facilities apart from dumpvariables which gives way too much for me to follow?

bobj

Saq Imtiaz

unread,
Sep 16, 2020, 7:40:18 AM9/16/20
to TiddlyWiki
I wrote a widget that I use for debugging: https://saqimtiaz.github.io/sq-tw/sandbox.html#%24%3A%2Fsq%2Fwidgets%2Faction-log

So within a macro you can do something like

<$log $message="any descriptive text" myvalue=<<myvariable>> />

The output gets logged to the browsers developer console, which you can bring up with ctrl+shift+I and then choose the Console tab.

TW Tones

unread,
Sep 16, 2020, 7:19:38 PM9/16/20
to TiddlyWiki
Bob,

I have a range of methods I use to debug but they are just co-opting other methods I use to write the code in the first place. Eventually I would like to publish a debug bundle 
but for now some pointers;
  • Where possible test the code as you develop it, small ongoing tests, the preview can help with this
  • Buttons can have variables displayed in their tiles (although they look terrible)
  • You could have little buttons whos tooltip shows a value of something
  • I have some macros that test $:/config/debug = yes then display content 
  • Popups and messages, or modals could be used to display "out of stream info"
  • Many values can be global or stored externally, you can monitor this outside you code
  • <$text text=<<variablename>> /> will often show you need to wikify its content before further use by returning not the result but the code.


More advanced ideas
  • Using the browser inspect or debug tools can solve some problems, especially CSS
  • the https://tiddlywiki.com/#transclusion%20Variable can provide information in nested transclusions
    • I have a varied that can identify the tiddler in which the code is defined.
  • The storyTiddler variable can be used when currentTiddler has being used in a list to identify the tiddler displayed in the story list (normally currentTiddler)
  • I think dump-variables in a modal may be helpful
  • Some operators allow you to test variables exist or have values
I expect i will think of more, as may others!

Tones

Bob Jansen

unread,
Sep 16, 2020, 8:15:36 PM9/16/20
to tiddl...@googlegroups.com
Thanks Tones and Imtiaz helpful ideas.

Maybe a manual tiddler should be prepared from these comments as I am sure I am not the only one to face this issue.

As a general question does anyone peruse all the questions and answers to update the manual?

Bobj

Dr. Bob Jansen
122 Cameron St, Rockdale NSW 2216, Australia
Skype: bobjtls

--
You received this message because you are subscribed to a topic in the Google Groups "TiddlyWiki" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/tiddlywiki/VVQeCDn2gjc/unsubscribe.
To unsubscribe from this group and all its topics, send an email to tiddlywiki+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/tiddlywiki/4c2d1851-a35b-49e6-9770-039e071b2f02o%40googlegroups.com.

Atronoush Parsi

unread,
Sep 17, 2020, 4:38:41 AM9/17/20
to tiddl...@googlegroups.com
Bob,
 There is a resource called TW-Scripts which has collected selectively some Q&A but unfortunately the author is absent for a few months.
Atro

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 view this discussion on the web visit https://groups.google.com/d/msgid/tiddlywiki/6C0C8E75-A92D-45D4-BD17-333B5B2DABE0%40gmail.com.
Reply all
Reply to author
Forward
0 new messages