The Now Platform® Washington DC release is live. Watch now!

Help
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
SlightlyLoony
Tera Contributor

Somewhere there may be a programmer who always writes programs that work correctly on the first try. Many non-programmers I know are convinced that every progammer other than me is like that! But I've never met that programmer — and I am certainly not that programmer. Some programming languages increase the probability of writing a correct program; others reduce it. Jelly, in my own experience, is a prime candidate for the programming language most likely to helpdrive a programmer crazy. That's a shorter drive for some (like me!) than it is for others...

So when things do go horribly wrong with your Jelly templates, as they inevitably will, how can you troubleshoot them?

Here's an example we'll use to illustrate the troubleshooting techniques:


<?xml version="1.0" encoding="utf-8"?>
<j:jelly>
      <g:evaluate>
              var fn = gs.getUser().getFirstName();
              var ln = gs.getUser().getLastName();
              var name = fn + ' ' + ln;
              name;
      </g:evaluate>
      <g2:evaluate>
              var picks = ['rocket scientist', 'hero', 'mouse', 'orangatan', 'Jelly-head', 'communist'];
              var index = Math.random();
              var pick = picks[index];
              pick;
      </g2:evaluate>
   
Your name is $[jvar_name] and you are a $[jvar_pick] (and your mother wears Army boots)!
</j:jelly>


If you run this, you'll see that it works very poorly indeed. Here's what I got:


Your name is and you are a *Undefined(var picks = ['rocket scientist', 'hero', 'mouse', 'orangatan', 'Jelly-head', 'communist']; var index = Math.random(); var pick = picks[index]; pick;) (and your mother wears Army boots)!


There are two problems: it didn't print out my name, and I got a bunch of garbage instead of the randomly selected description. Let's take the name problem first. The evaluate tag looks pretty much foolproof, so I'm wondering exactly what is in the jvar_name Jelly variable when that evaluation is finished. Here's how I can find out — by using the breakpoint tag like this:


<?xml version="1.0" encoding="utf-8"?>
<j:jelly>
      <g:evaluate>
              var fn = gs.getUser().getFirstName();
              var ln = gs.getUser().getLastName();
              var name = fn + ' ' + ln;
              name;
      </g:evaluate>
      <g:breakpoint/>
      <g2:evaluate>
              var picks = ['rocket scientist', 'hero', 'mouse', 'orangatan', 'Jelly-head', 'communist'];
              var index = Math.random();
              var pick = picks[index];
              pick;
      </g2:evaluate>
   
Your name is $[jvar_name] and you are a $[jvar_pick] (and your mother wears Army boots)!
</j:jelly>


When I ran this, the following showed up in my log:


<<< BREAKPOINT TAG START <<<
JVAR: AMP=&
JVAR: AND=&&
JVAR: GT=>
JVAR: LT=<
JVAR: RP=FFFFFFFFFFF250350nullnullnullnullnullnullnullFFFnullnullnullF
JVAR: SP=
JVAR: context=com.glide.ui.jelly.GlideJellyContext@5f02640f
JVAR: gc=com.glide.script.GlideController@15f74584
JVAR: jvar_cdata_end=]]>
JVAR: jvar_cdata_start=
7 Comments