Jump to content

Recommended Posts

Posted

I have a 2 sided flyer with multiple text boxes with multiple text fields using different size of fonts and different number of fields. The customer that doesn't want to copyfit any text but wants to return red text saying "You have entered too much text" in that specific text box. Since there are several text fields with different fonts and sizes in each text box, I can’t really use the calculate text width because of all the different fields, fonts, and sizes. I have named all the text boxes and text1, text2, text3, etc.

My logic would be if textbox “text1” has to copyfit return, in red, "You have entered too much text"

else return whatever they entered. I just can’t figure out the syntax

 

I was thinking of changing the 25 and 400 to 100 in the copyfit rule but I don’t know how to select the textbox that has too much text and change the text to something else.

 

if (!Copyfit(new MagnifyAttributes("text", 100, 100, 6, 72)))

ReportWarning("Could not copyfit text in flow " +

FusionPro.Composition.CurrentFlow.name);

Posted

Probably the easiest thing you could do (since they don't want to copy fit at all) would be to replace the contents of your "OnCopyfit" rule with this:

with (FusionPro.Composition.CurrentFlow) 
   if (!fits) content = '<para><span color="Red">' + 
           'You entered too much text.</span></para>';

Posted

Try searching this forum for "copyfit error message". Two of the threads it returns are:

http://forums.pti.com/showthread.php?t=3165

http://forums.pti.com/showthread.php?t=2276

 

Both of those other threads basically have this answer to your question:

if (!Copyfit(new MagnifyAttributes("text", 100, 100, 6, 72)))
{
   ReportWarning("Text does not fit in flow " + 
                 FusionPro.Composition.CurrentFlow.name);
   FusionPro.Composition.CurrentFlow.content = '<para><color name="Red">TEXT DOES NOT FIT IN THIS FRAME!</para>';
}

Posted
Probably the easiest thing you could do (since they don't want to copy fit at all) would be to replace the contents of your "OnCopyfit" rule with this:

with (FusionPro.Composition.CurrentFlow) 
   if (!fits) content = '<para><span color="Red">' + 
           'You entered too much text.</span></para>';

Ooh, that's a nice concise answer, and very clever! It's true that you don't actually need to call the Copyfit function.

 

I like the use of "with" there, although I try not to use it as Mozilla recommends against it, and it won't work in ECMAScript "strict mode". This is slightly less concise but more conformant:

var cf = FusionPro.Composition.CurrentFlow;
if (!cf.fits)
   cf.content = '<para><span color="Red">' + 
           'You entered too much text.</span></para>';

Posted
I like the use of "with" there, although I try not to use it as Mozilla recommends against it, and it won't work in ECMAScript "strict mode". This is slightly less concise but more conformant:

var cf = FusionPro.Composition.CurrentFlow;
if (!cf.fits)
   cf.content = '<para><span color="Red">' + 
           'You entered too much text.</span></para>';

Haha! Dan, originally the code I wrote for jwhittaker was exactly what you've posted above – down to the variable name. But, I'd previously read that page about "with" and revised my solution to get your opinion on it/how it would work within FusionPro. It just seems like it would be such a handy shorthand for all of the properties of the FusionPro object that I find myself typing so frequently. I had not, however, come across "strict mode" so I'll have to read into that page you posted here. Thank you for that.

Posted
Haha! Dan, originally the code I wrote for jwhittaker was exactly what you've posted above – down to the variable name. But, I'd previously read that page about "with" and revised my solution to get your opinion on it/how it would work within FusionPro.

I guess I took the bait. ;) Although I do like talking about JavaScript, so you have me pegged!

It just seems like it would be such a handy shorthand for all of the properties of the FusionPro object that I find myself typing so frequently.

Well, this is getting off the original topic, but yes, the "with" statement can indeed be a handy shorthand. But there are some potential downsides in terms of possible ambiguities, as that MDN page notes in the Ambiguity contra section. It's also deprecated, which means that it may not work at all in a future version of JavaScript, or it may be disallowed under certain conditions such as "strict mode." Speaking of which...

I had not, however, come across "strict mode" so I'll have to read into that page you posted here. Thank you for that.

Okay, but keep in mind that "strict mode" is a feature specific to ECMAScript 5, which is a later version than the JavaScript 1.7 which is currently embedded into FusionPro.

 

Further into the future, ECMAScript 6 introduces some other cool things like "let", which can help to better define the scope of variables and reduce ambiguity. There are neat features in other versions of JavaScript/ECMAScript as well, including JavaScript 1.8. Someday I hope to be able to bring in one of these newer versions to FusionPro, to be able to take advantage of some of the newer language features, but for now, it's JavaScript 1.7. So while I encourage you to look at newer versions of JavaScript/ECMAScript and even try them out in web pages and online tutorials and other such contexts, please be aware that the newer language features won't all work in FusionPro (though some new methods have polyfill you can add to use them in older versions).

Posted

Step and Dan

Thank you so much for your help I really appreciate it. I love how there is always different ways of doing things.

 

Dan

I was close but I had everything in this except the <para> part of the last line.

 

if (!Copyfit(new MagnifyAttributes("text", 100, 100, 6, 72))) { ReportWarning("Text does not fit in flow " + FusionPro.Composition.CurrentFlow.name); FusionPro.Composition.CurrentFlow.content = '<para><color name="Red">TEXT DOES NOT FIT IN THIS FRAME!</para>'; }

Thanks again!!!

Posted
I guess I took the bait. ;) Although I do like talking about JavaScript, so you have me pegged!

Don't worry, when I devise a way to work a mention of (what looks to be) a very tall bicycle into one of my posts I will because I'm sure there's a conversation there.

 

Anyway, I won't derail the topic any further, just wanted to thank you for sharing this information with me and the rest of the community.

 

I was close but I had everything in this except the <para> part of the last line.

You were! All FusionPro text flows are wrapped with "para" tags so if you're replacing the content of one, you have to make sure you add those tags back in order for the text to display.

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