RickB Posted March 20, 2023 Share Posted March 20, 2023 Looking to write a rule that would turn off text wrap when empty. Your input is appreciated. Quote Link to comment Share on other sites More sharing options...
Dan Korn Posted March 20, 2023 Share Posted March 20, 2023 You can't directly determine when a text frame is empty, but, in OnRecordStart, you can test whether whatever field or rule you're inserting into the frame is empty, and if so, turn off text wrap. Something like: if (!Field("YourFieldName")) FindTextFrame("YourFrameName").textWrap = false; Or, more succinctly: FindTextFrame("YourFrameName").textWrap = !!Field("YourFieldName"); Quote Link to comment Share on other sites More sharing options...
Douglas Cogan Posted March 20, 2023 Share Posted March 20, 2023 Hi Rick, you mean, don't wrap text around a picture if the graphic frame is empty, right? To do this, first give the text frame a name such as "TheTextFrame" in the frame properties dialog box. Then make a new OnRecordStart rule (or add to one if you have one.) if (Len(Field("TheGraphic")) == 0) { TextFrame = FindTextFrame("TheTextFrame"); TextFrame.textWrap.textWrap =false; } Replace "TheGraphic" with the name of the field that if empty triggers the text to not wrap. Let me know if this works. Quote Link to comment Share on other sites More sharing options...
RickB Posted March 20, 2023 Author Share Posted March 20, 2023 3 minutes ago, Dan Korn said: You can't directly determine when a text frame is empty, but, in OnRecordStart, you can test whether whatever field or rule you're inserting into the frame is empty, and if so, turn off text wrap. Something like: if (!Field("YourFieldName")) FindTextFrame("YourFrameName").textWrap = false; Or, more succinctly: FindTextFrame("YourFrameName").textWrap = !!Field("YourFieldName"); Thank you, I'll give it a go. Quote Link to comment Share on other sites More sharing options...
RickB Posted March 20, 2023 Author Share Posted March 20, 2023 4 minutes ago, Douglas Cogan said: Hi Rick, you mean, don't wrap text around a picture if the graphic frame is empty, right? To do this, first give the text frame a name such as "TheTextFrame" in the frame properties dialog box. Then make a new OnRecordStart rule (or add to one if you have one.) if (Len(Field("TheGraphic")) == 0) { TextFrame = FindTextFrame("TheTextFrame"); TextFrame.textWrap.textWrap =false; } Replace "TheGraphic" with the name of the field that if empty triggers the text to not wrap. Let me know if this works. Great! Thank you, I'll give it a shot! Quote Link to comment Share on other sites More sharing options...
RickB Posted March 20, 2023 Author Share Posted March 20, 2023 3 hours ago, Douglas Cogan said: Hi Rick, you mean, don't wrap text around a picture if the graphic frame is empty, right? To do this, first give the text frame a name such as "TheTextFrame" in the frame properties dialog box. Then make a new OnRecordStart rule (or add to one if you have one.) if (Len(Field("TheGraphic")) == 0) { TextFrame = FindTextFrame("TheTextFrame"); TextFrame.textWrap=false; } Replace "TheGraphic" with the name of the field that if empty triggers the text to not wrap. Let me know if this works. So yes, text needs to wrap around a graphic frame which I given it a resource file. This code works perfectly with a text wrap but not a graphic frame wrap. Quote Link to comment Share on other sites More sharing options...
Douglas Cogan Posted March 21, 2023 Share Posted March 21, 2023 Hi Rick, sorry that didn't work. I did see a typo where I put .textWrap twice in my note above. I don't quite know what you mean that it doesn't work with a graphic frame wrap. What can we use to determine if the graphic frame would be empty? That's what I was putting in the "if" statement above. What data values can we test to determine the frame would end up empty? We just need to put that in the if clause of the expression in OnRecordStart and we're set. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.