How do I debug a tiddler?

86 views
Skip to first unread message

Joe Armstrong

unread,
Mar 10, 2018, 1:29:47 PM3/10/18
to TiddlyWiki

I have a pretty good idea how to debug almost any language by writing functions calling the code

and adding  print statements to the code. But I'm unclear as to how I would do this in TW.


I wanted to take a few tiddlers i don't understand and add a few print statement to clarify 

what is happening - is this possible?


If I take a maco I think what happens is that it returns some text which is 

then rescanned - it would be nice to a get a trace of what get called and what the

return values are (same for widgets and JS code)


Cheers


/Joe

Mat

unread,
Mar 10, 2018, 5:00:30 PM3/10/18
to TiddlyWiki
On Saturday, March 10, 2018 at 7:29:47 PM UTC+1, Joe Armstrong wrote:

I have a pretty good idea how to debug almost any language by writing functions calling the code

and adding  print statements to the code. But I'm unclear as to how I would do this in TW.


Well, as far as I understand, TW works on a few layers that can go wrong depending on what you do. There's the backend JS that is supposed to be hidden, there are the widgets as a functional layer with fundamental building blocks, the macros are merely text-substitutions not actual functions. But wikitext also allow for direct use of html-elements and CSS.

The browser inspector is probably the only real *tool* that you can use to investigate things.

I think the RSOE (Red Screen of Embarrassment) exclusively is for JS and it usually gives a clue to what is wrong. There are a few build in error codes that I believe are for wikitext - I'm primarily thinking of when a bracket is missing in filters.

BTW, you may find my SideEditor of use. I use it all the time for testing stuff. It has similarities with the editor preview function.


I wanted to take a few tiddlers i don't understand and add a few print statement to clarify 

what is happening - is this possible?


... it depends ... ;-) 


If I take a maco I think what happens is that it returns some text which is 

then rescanned - it would be nice to a get a trace of what get called and what the

return values are (same for widgets and JS code)


Macros are pure text substitution. I'm not sure what you mean with "rescanned".

You can check global variables with this syntax "$(variable)$".

If you give us your actual wikitext code it would be much easier to help you.

<:-)

Joe Armstrong

unread,
Mar 10, 2018, 5:23:54 PM3/10/18
to TiddlyWiki
Let me explain

if we have some text

    <begin>
        <<a>>
        <<b>>
    </begin>

After <<a>> and <<b>> have been expanded we get

   <begin>
        something ...
        ....
    </begin>

rescanning means we start over and see if we can expand this again - this process stops
when no more changes can be made (ie all macros have been expanded)

This is pretty standard macro expansion behaviour.

 
You can check global variables with this syntax "$(variable)$".
 
If you give us your actual wikitext code it would be much easier to help you.

I will when I get to that point - I'm a slow learner :-)

Thanks

/Joe
 

<:-)

Joe Armstrong

unread,
Mar 10, 2018, 6:50:07 PM3/10/18
to TiddlyWiki


On Saturday, 10 March 2018 14:00:30 UTC-8, Mat wrote:
Ok - I want to make a numbered list of tiddlers with tag post

Version 1)

<$list filter="[tag[post]]">
<<currentTiddler>>
</$list>

This resulted in

Building a story line Changing how we think How this blog was created How to create a new blog entry One idea per tiddlerThe Web Is Broken Uplifting Projects What would you like to hear about?

So far so good

Vsn 2:

<ol>
<$list filter="[tag[post]]">
<li><<currentTiddler>></li>
</$list>
</ol>

Output 
  1. Building a story line
  2. Changing how we think
  3. How this blog was created
  4. How to create a new blog entry
  5. One idea per tiddler
  6. The Web Is Broken
  7. Uplifting Projects
  8. What would you like to hear about?
Almost right at this point I thought this would work:

vsn4 
<ol>
<$list filter="[tag[post]]">
<li>[[<<currentTiddler>>]]</li>
</$list>
</ol>

But this results in
 
Hang on [[Link]] is expanded into a link and <<....>> is expanded
so what are the precedence rules?

Finally 
<ol>
<$list filter="[tag[post]]">
<li>
<$link>
<<currentTiddler>>
</$link>
</li>
</$list>
</ol>

This worked


 

<:-)

Jeremy Ruston

unread,
Mar 11, 2018, 5:45:08 AM3/11/18
to tiddl...@googlegroups.com
Hi Joe

One hint that might help is to understand that the various brackets and quotes we use as attribute values are treated as special types of quotes, and not as operators, as you might expect. That's why you can't nest them.

So, <a href={{mylink}}>Click</a> will use the value of the tiddler "mylink” as the value for the attribute "href".

And <a href=<<myvar>>>Click</a> will use the value of the variable "myvar” as the value for the attribute “href”.

You can also use triple curly braces to evaluate an attribute value as a filter expression, and return the first entry in the result list. For example, to retrieve the value of a variable and add a suffix to it:

<a href={{{ [<myvar>addsuffix[.com]] }}}>Click</a>

Best wishes

Jeremy
--
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 post to this group, send email to tiddl...@googlegroups.com.
Visit this group at https://groups.google.com/group/tiddlywiki.
To view this discussion on the web visit https://groups.google.com/d/msgid/tiddlywiki/0efa1415-d3cb-4507-8f33-d9f940bff0cb%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages