Jump to content

space between variable and period


billn

Recommended Posts

I haven't seen your template or a sample of the data you're trying to add tracking to, but it sounds like you basically want to add tracking tags around the last letter of a variable when it's followed by a period so that only the period will move closer to the last letter of the variable and leave the rest of the letters alone.

 

I also made the assumption that you have a text frame that you are doing all of your text editing in and you're pulling your variables in by adding them from the drop down menu.

 

If both of those assumptions are true, this solution may work for you:

1. Name the text frame that you want to adjust the tracking on. In my code I named it "content" but you can be as descriptive as you'd like. Just make sure the code matches what you named the frame.

 

2. Paste this code into an OnRecordStart Callback rule:

var trackingSize = "-10"; // Tracking from -100% to 500%
var fieldName = "NAME"; // Name of the field
var frameName = "content"; //Name of the text frame

var find = new RegExp('<variable name="'+ fieldName +'">' + "\\.","g");
var replace = Field(fieldName).replace(/(.)$/,'<tracking newsize="'+ trackingSize +'">$1</tracking>.');
FindTextFrame(frameName).content = FindTextFrame(frameName).content.replace(find,replace);

 

Type the name of the variable that you are trying to add tracking to between the quotes. The code essentially scans the content of the text frame for the variable defined followed by a period. If it finds it, it adds tracking tags around the last letter of the variable. You can adjust the tracking amount, "-10" was just a guess. Hope that helps!

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...