Jump to content

drag and drop rule problem


rjhansen

Recommended Posts

I'm new to FusionPro. I'm trying to create a simple rule using Drag and Drop. I have a series of numbers (1-100) printing on cards. I want the single digit numbers to be a larger font size than the double digit numbers. My data file only has one field, "TableNo".

 

I have the following:

 

If "Numeric value of" "TableNo" (my field) is less than "10"

Then Return "FusionProRuleWizard.Action.Change Point Size"

 

I'm specifying 250 pts for the point size change. When I try to insert the rule, the rule itself is printing on the page with the data and is not changing the font size as expected.

 

I've looked at at the documentation and searched the forums but haven't been able to figure out what I'm doing wrong.

Link to comment
Share on other sites

rjhansen,

Drag and drop is probably not the best way to accomplish this. Try an empty rule with the content below.

if (Field("TableNo") < "10")

 

return '<z new size="250">'+Field("TableNo");

 

else

return Field("TableNo");

 

2 important things to remember:

  1. Make sure you check the box at the top of the rule menu for "Treat return strings as tagged text".
  2. When you insert the rule the font size should be the desired size for everything > 10.

Link to comment
Share on other sites

I agree that this would be easier to accomplish through a custom rule, but I think the rule as it stands is comparing a string to a string which seems like it would throw off the comparison between the two numbers. I think you probably want to re-write the if statement condition (first line) to be:

if (StringToNumber(Field("TableNo")) < 10)

Link to comment
Share on other sites

I've never used the drag and drop before, but I whipped up a quick sample and it worked as intended. I'm attaching a jpg screenshot of what my rule looked like in the drag and drop editor window (my field name was "Qty_S" and I used 25pt font, but you get the idea).

 

After I saved the rule I inserted it into a text frame and it worked fine. Incidentally, if you put in the rule that way and then click the button to convert the rule to JavaScript you get essentially the combination of what users FreightTrain and step posted.

2-25-20152-03-04PM.jpg.c45c413f0d946f3c03eccb9702baf563.jpg

Link to comment
Share on other sites

Thanks for all the input! Definitely very helpful, but I'm still having issues getting this to work. Straight off, using FreightTrain's code didn't change the point size. I suspected I needed the StringToNumber function, but I was calling it wrong. Step's suggestion showed the correct usage, but my rule still didn't work correctly.

 

Then I tried recreating tobarstep's Drag And Drop rule. This didn't change my point size either. Then I converted that to JavaScript and made a couple of changes and now I've got something that changes the point size on 1-9 (as expected) but it also prints the same digit at the original point size right beside the larger number. Here's the rule:

 

if (StringToNumber(Field("TableNo")) < StringToNumber("10"))

{

return "<span pointSize=230>" + TaggedDataField("TableNo") + "</span>";

}

 

return "";

 

And a screenshot of the first record as it previews with this rule inserted:

 

http://forums.pti.com/picture.php?albumid=20&pictureid=34

Link to comment
Share on other sites

It sounds like your text frame is returning your rule as well as the variable. You should set the contents of your text frame to only return the contents of the rule and the change your rule to:

if (StringToNumber(Field("TableNo")) < 10){
return "<span pointSize=230>" + TaggedDataField("TableNo") + "</span>";
}
else {
return TaggedDataField("TableNo");
}

Link to comment
Share on other sites

Sorry, I probably should have specified that by "collect" I meant to select "Collect.." from the "FusionPro" menu. Without doing that, your rules didn't come over.

 

Regardless, I've attached an example in which I've got my code working as I would expect it to.

 

Another way to accomplish what I think you're trying to accomplish would be to insert the "TableNo" variable into your text frame and apply Copyfitting to it (click on the text frame and select "Overflow" from the text pallet). From there you'd select "adjust text to fit" and "allow text to expand to fill." Doing this will create an "OnCopyfit" call back rule that would look something like this:

if (!Copyfit(new MagnifyAttributes("text", 25, 400, 6, 72)))
   ReportWarning("Could not copyfit text in flow " + 
                 FusionPro.Composition.CurrentFlow.name);

 

The "25" is the lowest magnification factor it will apply to your text to get it to fit. The "400" is the max. So it will magnify your text a maximum of 400% the original pointsize in order to get the text to fill the frame. The last two numbers are the min and max (respectively) pointsize the function is allowed. So, by default, Copyfit will only increase the size of the text to 72pt. You can change that parameter to "250" and then there's no need for any rule.

122348 Speakers Ball Table Tent Numbers.zip

Link to comment
Share on other sites

Step,

 

Thanks, that does exactly what I want it to do. I will have to look at the rule you made when I get a chance to see what the problem with mine was. And thanks for the info on the copy fitting. I played with that a little bit when my rule wasn't working but was having trouble getting it to do what I wanted. Your explanation should help me figure out how that works.

 

I really appreciate your time and help with this.

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