Coding efficiency

Post Reply
MiniMe
Posts: 210
Joined: Thu Mar 15, 2001 4:30 pm

Coding efficiency

Post by MiniMe »

is there a way to combine these statements to be more efficient??
<strlen $TITLE>
< if $ret gt 50>
<substr $TITLE 0 50>
<sum "%s" $ret "...">
$ret
</if>

to something like
<sum "%s" <substr $TITLE 0 50> "...">
$ret


Don't ask me why.. one of our perl developers asked..

M.
User avatar
mark
Site Admin
Posts: 5519
Joined: Tue Apr 25, 2000 6:56 pm

Coding efficiency

Post by mark »

No need to check first. The following is that same as what you propose:
<substr $TITLE 0 50>
<sum "%s" $ret "...">
User avatar
John
Site Admin
Posts: 2622
Joined: Mon Apr 24, 2000 3:18 pm
Location: Cleveland, OH
Contact:

Coding efficiency

Post by John »

If you only wanted to put the ... after titles longer than 50 you could also do something like:

<sandr ".{50}.+" "\1..." $TITLE>
$ret
John Turnbull
Thunderstone Software
Post Reply