[antlr-interest] String Template - doing a substring?

Barnes, Jeff JB0284 at att.com
Thu Aug 23 06:02:27 PDT 2007


Stringtemplate does not have comparison capability like what you
describe. You have to do your business logic in code. 

 

Best regards,

Jeff

 

________________________________

From: antlr-interest-bounces at antlr.org
[mailto:antlr-interest-bounces at antlr.org] On Behalf Of Nick Lee (NWL
Solutions Limited)
Sent: Thursday, August 23, 2007 5:10 AM
To: antlr-interest at antlr.org
Subject: [antlr-interest] String Template - doing a substring?

 

Hi all,

I'm using the c# String Template and it seems a fantastic powerful piece
of software, which I'm sure I have only scratched the surface on.

 

I've got a very simple template where I would like to check the length
of an attribute passed (easily done using the c# strings length
property). However if this length is over a specified amount I would
like to substring the value.

 

I've looked at the docs and examples but cannot find how to call the sc#
string substring method etc, does anybody have any examples of comparing
the length of a string and then doing a substring?

 

For example ...

$if(obj.description.Length()>20)$

obj.description.substring(0,20)

$else$

obj.description

$endif$

 

Any guidance is much appreciated.

 

Kind regards,

Nick

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20070823/767af59c/attachment.html 


More information about the antlr-interest mailing list