Jump to content

Returning Text based on Length


James

Recommended Posts

I am having an issue with getting longer names to fill space properly. On the attachment, the left image is exactly what I want and works great for smaller names, but if I have a name that is longer (seems like 8 characters is the number) it makes it tiny (image on right).

 

I looked for someone else who had my problem and found this, it's close, but not exactly what I need. http://forums.pti.com/showthread.php?t=1093

 

Based on the above post I came up with the following to fit my needs.

 

var len = Field("First Name").length;
if (len >= 8)
 return Resource("Name Length");
//else
return "";

 

It does make the longer names fit, however it removes the shorter names instead of keeping them how they were (which is perfect).

 

What am I doing wrong?

 

THANKS!

 

James

Screen-shot-2013-01-10-at-9_05.46-AM.jpg.bcb17f6f6b806ae7e2f706de123db953.jpg

Link to comment
Share on other sites

It does make the longer names fit, however it removes the shorter names instead of keeping them how they were (which is perfect).

 

What am I doing wrong?

The code you included is returning a resource when length of first name is 8 or more characters otherwise returning nothing. The last line should read:

else return Field("First Name");

 

This scenario looks like it would benefit from the TextMeasure function, but I'm not sure what you are trying to accomplish for names with 8 or more characters.

Link to comment
Share on other sites

Hmmm. That helped with the longer name, but replaced the shorter names with the name of the rule.

 

I've attached what I'm trying to accomplish with the longer names. I know once I figure it out for the first names I will be able to apply that to the longer middle names.

 

Thanks for the help!

Screen-shot-2013-01-10-at-9_51.39-AM.jpg.3cc830c3994d4c044ebda70f091246e3.jpg

Link to comment
Share on other sites

Hmmm. That helped with the longer name, but replaced the shorter names with the name of the rule.

That doesn't make much sense. You were already returning

return Resource("Name Length");

for names that were greater than 7 characters. My code addition should return First Name value for records with a first name of 7 or less characters..

 

What does the resource contain (i.e. what is returned for longer first names)?

Link to comment
Share on other sites

Here is the source code, is that what you are asking for?

 

<p style="(no style)" br="false" override="true" quad="C" findent="0" lindent="0" rindent="0" leadbefore="0" leadafter="0" widows="2" kerning="true" hyphenate="true" skipifempty="false" skipifemptyvar="false" noparabreakoncopyfit="true"><tracking newsize="0"><f Name="Jellyka Delicious Cake"><z newsize="200.0"><color Name="C=2 M=2 Y=2 K=0"><variable Name="First Name">

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...