Jump to content

Add variable number of leading characters


Recommended Posts

I am formatting a label for USPS mailing


I need to put in the OEL information with some of our information at the beginning of the line.


123456 M1 FF************************ADC 605

{Memcode}{Memtype}{Magname}variable number of *{endorse}


The Memcode can vary from 3-7 characters and Memytpe can be 0-3, and Magname is always 2 characters


I know that I will need to calculate the length of the string:



and the length of the maximum string (text box is 4.0in wide) = y


y-x=total number of * i need


And then insert that value into the padL function


I have been able to get by with the built-in simple rules until now. But I am stumped.


Thanks in advance for any help or direction


Dennis Matl

Production Manager

American Nuclear Society

Link to comment
Share on other sites

If I'm understanding your question correctly and you want to dynamically add asterisks between the "Magname" and the "Endorse" variables, then you don't need a rule for this at all.


In you text editor, insert your first 3 variables, tab, and insert the "endorse" variable. Then click the "Tabs..." button in the text editor dialog box and add a new tab:

Position: 3.9in (Note: if the line has to be exactly 4 inches long, set the position to 4 and increase the width of the text box so it doesn't wrap.)

Alignment: Right

Leader: *


If you really wanted to do this with JavaScript, you could use TextMeasure to measure the length of your 4 variables and using a while loop add an asterisk to that string until the line was equal to 28800 (4 inches - TextMeasure returns width in 1/100 of a point). But I think that's unnecessary.

Edited by step
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.

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