Jump to content
Claris Engage 2025 - March 25-26 Austin Texas ×
The Claris Museum: The Vault of FileMaker Antiquities at Claris Engage 2025! ×

This topic is 6423 days old. Please don't post here. Open a new topic instead.

Recommended Posts

Posted

How can I do add hard returns before each of numbers in these sentances? Sometimes they are letters. Assume that the text has been placed in a temptext field.

1. sample text

2. sample text

3. sample text

or

a. sample text

b. sample text

c. sample text

Posted

Probably easiest to use a long substitute statement (or you could write a Custom function);)

Substitute( yourtextfieldhere ; ["A. " ; ¶ ] ; ["B. " ; ¶ ] ; ["C. " ; ¶ ] ; ["D. " ; ¶ ] ; ... ; [ "a. " ; ¶ ] ; ["b. " ; ¶ ] ; ... ; [ "1. " ; ¶ ] ; ... ; [ "0. " ; ¶ ] )

... but that's like 62 combinations or something so may be easier to write a custom function..

Posted (edited)

Make those sentences records instead?

UPDATE: Usually, when you hit something which needs to be twisted into nightmare designs just to get the job done, it indicates that the process should be reconsidered. I would bet there are easier, more elegant ways of handling this. If you would explain more about what you are doing and why, we might be able to help you come up with easier approaches. ;)

Edited by Guest
Added Update
Posted

If you would explain more about what you are doing and why

Yeh, I don't think people trust us for some reason, that must be why they hold back lol. Then again, it's just as bad where people tell us their whole setup and forget to mention the problem ;)

Posted

hmmmm... Well, just in case we don't get more info, I think i may have interpreted the question incorrectly...

¶ & Substitute( tempText ; "¶" ; "¶¶" )

Posted

I am importing raw text from various sources, like PDF's and Doc files etc. In order to process the information I need the text to breath more so I want to insert space between lines, bullets, paragraphs etc. Sometimes the text doesn't reflow and hard returns have to be removed where the sentance wraps. (substitute works well for this)

I have been successfully creating other substitutions formulas but they only work with fixed characters. For example, with bulleted text that I want to space out I use:

Substitute ( WITH 1::temp_content; "•" ; "¶•" )and this works fine.

Now I need to figure out how to do this when there is a variable. The following forumula works fine for "1." but I need something that allows for "1" to be any number or any letter:

Substitute ( WITH 1::temp_content; "1." ; "¶1.")

Posted

Yes, that does give me some control but what it doesn't do is differentiate between paragraphs. It only controls line spacing. (unless I'm missing something here)

Even if it did the problem is that I am importing hundreds of pages and it would take too long. I need some of that functionality built into various scripts.

Posted

Genx,

You would be right on if the original text didn't have unnecessary hard returns inserted where the text wraps. Because of this I have to remove all the returns and end up with a block of text like this example:

1. The Roundtable believes that people in Halton have a right to access quality programmes and services in Halton and that the non-profit and voluntary sector has played and continues to play – along with other sectors - a critical role in ensuring this occurs. 2. Participation of those affected by change is essential to the development of effective strategies to create that change. From the broad involvement of people and organizations in sharing information and insight to the Roundtable’s invitation to the community to adopt and put form to its recommendations, its process has been shaped by a commitment to community participation. 3. The Roundtable believes that the opportunity to maximize creativity and innovation in responding to any set of challenges is made more likely when people and organizations come together rather than work in isolation. Partnership and collaboration are strategies which nurture creativity and innovation. We are fortunate in Halton because it is possible to build on a strong history of partnership and collaboration. 4. The non-profit and voluntary sector is multi-faceted. We need to acknowledge this dynamic mix and the equally dynamic tension between the need for change and the need to honour difference. Finding an effective balance between change and the need to preserve difference will be a hallmark of effective problem-solving in our community. 5. Although we all have a unique role to play, we are all stakeholders in our community. Everyone and every sector – public, corporate, non-profit and voluntary - has a role to play in maintaining the quality of life in Halton. Our best results will emerge only if everyone and every sector engages. 6. Healthy communities require investment of resources (including human resources, financial resources and information and technological resources) and ongoing investment fosters sustainability.

This is where I need to insert hard returns before the numbers and then I can do as you suggested to increase space between paragraphs.

Posted (edited)

No, it increases paragraph spacing (if you increase the Above/Below parameters), not line spacing. Of course, if your lines are wrapped by hard returns, it won't help you much.

Even if it did the problem is that I am importing hundreds of pages and it would take too long.

You only need to do this once, in Layout mode. After that, anything you put in the field will conform to the settings (unless you have chosen to override them by applying different settings in Browse mode.

In any case, to do this by calculation, without a custom function, you would need to use nested Substitute() along the lines suggested by Genx.

Edited by Guest
Posted

I posted the above before I saw your last example. From my experience, texts with hard-wrapped lines will have TWO carriage returns to indicate a new paragraph. This type is easily fixed by:

Substitute ( text ; [ "¶¶" ; "§" ] ; [ ¶ ; " " ] ; [ "§" ; ¶ ] )

The advantage over your suggested method is that it preserves all paragraphs, not just numbered ones.

Posted

I always do this kind of cleanup using a text editor, with "grep" or "regex" ability, which makes it heck of lot easier. But that's only good for one-shot jobs; or I can write (or record) an AppleScript to do it. That won't help you however.

There is a set of Custom Functions, written by The Shadow (here at FMforums). It lets you use a wildcard for a number or letter, so you don't have to type: "A. "; "B. ", ... and "1. "; "2. ", ...

It may execute faster however if you use the above hard-coded values, and there's not really that many.

But that's not my main point ;)-] I think there's a step missing. The usual routine is to "protect" your existing values BEFORE you wipe out all the hard returns. I'm assuming that the original text has line returns before the A., B., 1., 2., etc.. At least that's what I usually see (in PC emails especially). So you can identify and protect them; as well as any double returns, which signify real line returns in the text.

The Substitute list would look more like (partial, very):

Substitute ( Text_Temp;

["¶¶"; "zzzzzz"]; // preserve double returns

["¶A. " ; "zzzA. "]; ["¶B. " ; "zzzB. "]; [ "¶1. " ; "zzz1. "]; [ "¶2. " ; "zzz2. "]; [ "¶3. " ; "zzz3. "]; [ "¶4. " ; "zzz4. "];

[ ¶; ""]; // remove returns

["zzzzzz"; "¶¶"]; // restore double returns

["zzzA. "; "¶A. "]; ["zzzB. "; "¶B. "]; ["zzz1. "; "¶1. "]; ["zzz2. "; "¶2. "]; ["zzz3. "; "¶3. "]; ["zzz4. "; "¶4. "]

)

Posted (edited)

My method above does not "force" returns for: A., B., a., b., 1., 2., .... It assumes they're already there. And would leave it alone if one was in the middle of a block of text. If you want to force line returns before them, anywhere, then you don't need to protect them (saves a lot of typing).

But then you have a different problem. Many sentences end with an uncapitalized letter (duh). You need to identify only those that are one of these special ones. It seems that they are always letters on their own, after a space (or return).

some sentence. a. List item one. b. list item two.

But we'd wiped out the returns already. So I put a space for the return. Then at the end I removed any double spaces (don't like 'em anyway ;)-)

Substitute ( Text_Temp;

["¶¶"; "zzzzzz"]; // preserve double returns

[ ¶; " "]; // remove returns, but add space

["zzzzzz"; "¶¶"]; // restore double returns

[" A. "; "¶A. "]; [" B. "; "¶B. "]; [" a. "; "¶a. "]; [" b. "; "¶b. "];

[" 1. "; "1. "]; [" 2. "; "¶2. "]; [" 3. "; "¶3. "]; [" 4. "; "¶4. "];

[" "; " "] // remove extra spaces

)

(P.S. Above is single returns for the lists; add another return if desired.)

Edited by Guest

This topic is 6423 days old. Please don't post here. Open a new topic instead.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.