How do I do printf debugging?

78 views
Skip to first unread message

joearms

unread,
Jan 8, 2019, 11:47:29 AM1/8/19
to TiddlyWikiDev
How do I do printf debugging?

In all programming langauages I know I stick print statements all over the
place to see what's going on - then I remove them when the program works.

What's the equivalent in developing TW plugins?

Specifically I've made a button like this:

<$button actions={{CommentButtonActions}}> Press Me To add a comment </$button>

Which I hope will do something when I click it

I now need to define CommentButtonActions

If this was regular Javascript I'd just write console.log(...) in my
JS and stare at the output.

What's the equivalent in TW code? What would I print out inside CommentButtonActions?

Cheers

/Joe

Eric Shulman

unread,
Jan 8, 2019, 12:07:22 PM1/8/19
to TiddlyWikiDev
On Tuesday, January 8, 2019 at 8:47:29 AM UTC-8, joearms wrote:
How do I do printf debugging?
Specifically I've made a button like this:
<$button actions={{CommentButtonActions}}> Press Me To add a comment </$button>
Which I hope will do something when I click it
I now need to define CommentButtonActions

Try using <$action-setfield> to write your printf output to a tiddler.

-e

PMario

unread,
Jan 9, 2019, 5:53:08 AM1/9/19
to TiddlyWikiDev
hi,
the dumpvariables macro may be an option


-m

joearms

unread,
Jan 10, 2019, 4:46:14 AM1/10/19
to TiddlyWikiDev

In general, what do you do when something goes wrong.

On several occasions, I've written some code (an action to be performed when something happens)
but I see nothing - I expect some output but there is none.

A typical case is an incorrect filter which returns nothing but I'd expected it to
return something  - the trouble is that I don't know it's the filter that has failed
it might be something else.

I don't know where or how to start debugging.

If it were C or JS I'd just start adding print statements at appropriate places printing out
variables

I guess I'd like a <$log ....> widget that did something like console.log(...) in Javascript
or printf in C -- just to know my code has been run.

I don't know how the code that evaluates a widget works - if a widget "fails" (meaning that it
breaks some rules of well-formed or something) I seem to get a silent error (meaning that there is no output)

It would be nice to have some kind of error tiddler - that logged silent errors - so I could read it
when debugging.

Do any of these things (logs, error tracing, etc.) exist?

Is there a tutorial on "How to debug a faulty TW program?"

Cheers

/Joe

TonyM

unread,
Jan 10, 2019, 5:40:54 AM1/10/19
to TiddlyWikiDev
Joe,

The I think two most common debug methods, 
  1. ask smaller questions. Put a filter in a list-links and check the results (use advanced Search Filter tab as well)
  2. Use the browser inspect to see what was generated
You can also provide a single tiddler name or title rather than a more complex filter to test the result if that tiddler name was generated by the filter.

Regards
Tony

TonyM

unread,
Jan 10, 2019, 5:41:29 AM1/10/19
to TiddlyWikiDev
Sorry, 

I cant advise for in Java script :(
tony

alain.bo...@gmail.com

unread,
Jan 12, 2019, 3:25:56 PM1/12/19
to TiddlyWikiDev
For my plugin development (syncadaptor for node-solid-server) I use alert() to replace console.log()
It is a .js plugin
Reply all
Reply to author
Forward
0 new messages