Formatting text in maths

Solved a problem in an elegant manner and want to show off your code? Know a hard-to-find feature? Post it here for the benefit of others. Questions don't belong here.
Post Reply
Jacqueline
Posts: 74
Joined: Fri May 25, 2012 2:40 pm
Has thanked: 14 times

Formatting text in maths

Post by Jacqueline » Tue Dec 01, 2015 8:42 am

Am I able to embolden text included within a maths field which will be brought into a WFM doc?

I didn't want the whole text field to be in bold.

I'm imagining the answer is no and that I have to wait for the new paragraphs feature in the next Proclaim update.

revellbikes
Posts: 422
Joined: Fri Jun 15, 2012 12:44 pm
Has thanked: 11 times
Been thanked: 43 times

Re: Formatting text in maths

Post by revellbikes » Tue Dec 01, 2015 9:03 am

I think it's a no unfortunately :roll:

Jacqueline
Posts: 74
Joined: Fri May 25, 2012 2:40 pm
Has thanked: 14 times

Re: Formatting text in maths

Post by Jacqueline » Tue Dec 01, 2015 9:05 am

thanks for that speedy response.

steve
Posts: 375
Joined: Wed Nov 30, 2011 10:20 pm
Been thanked: 75 times

Re: Formatting text in maths

Post by steve » Tue Dec 01, 2015 9:35 am

without splitting your maths field output up into separate fields, I would think this would be tricky.
Am I right in thinking you want for example:
maths field {M some text output.Text}

Code: Select all

result = "This is my text, and I want the word "bold" to appear in bold in my Word Document"
then in your word document, you want literally that:
This is my text, and I want the word "bold" to appear in bold in my Word Document
?
At present, I can only think of a very messy way:
Three alpha fields and one maths field:
{text Pre-bold}
{text BOLD}
{text post-bold}
{M convert to bold}:

Code: Select all

#surround the text that you want to be bold with ~ characters
#example text field below contains 
# "This is my text, and I want the word "~bold~" to appear in bold in my Word Document"
#copy the text into a variable
v-input = {my text field that I want to embolden one word.Text}
#============
#PRE-BOLD:
#============
#loop through the string to find the first occurrance of the ~
v-length = LENGTH(v-input)
v-count = 1 
v-output = ""
v-found = 0
WHILE v-count <= v-length and v-found = 0 DO 
    v-chr = SPLIT( v-input , v-count , 1 ) 
    v-asc = ASC( v-chr ) 
    IF v-asc <> 126 THEN 
        v-output = v-output + TEXT( v-chr ) 
    ELSE 
    	#found it - end
    	v-found =1
    
    END 
	#next character in input
	v-count  = v-count + 1
END
#our output contains all text up to the first tilde
put(v-output,{text pre-bold.Text}

#============
#BOLD:
#============
v-count = 1 
v-output = ""
v-found = 0
#loop through input again, ignore chars up to first tilde, stop at 2nd tilde
WHILE v-count <= v-length and v-found < 2 DO 
    v-chr = SPLIT( v-input , v-count , 1 ) 
    v-asc = ASC( v-chr ) 
	#only output the text once we have found one tilde
    IF v-asc <> 126 and v-found = 1  THEN 
        v-output = v-output + TEXT( v-chr ) 
    ELSE 
    	#found it - add one to the counter
    	v-found = v-found +1
    
    END 
	#next character in input
	v-count  = v-count + 1
END
#our output contains all between tildes (CHECK)
put(v-output,{text bold.Text}
#============
#post-BOLD:
#============
v-count = 1 
v-output = ""
v-found = 0
#loop through input again, ignore chars up to  2nd tilde, output until end of string
WHILE v-count <= v-length  DO 
    v-chr = SPLIT( v-input , v-count , 1 ) 
    v-asc = ASC( v-chr ) 
	#only output the text once we have TWO tilde
    IF v-asc <> 126 and v-found > 1  THEN 
        v-output = v-output + TEXT( v-chr ) 
    ELSE 
    	#found it - add one to the counter
    	v-found =v-found + 1
    
    END 
	#next character in input
	v-count  = v-count + 1
END
put(v-output, {text post bold.Text})

Then in your Word Document, add the three Text fields, formatting the BOLD one as Bold
(please check the code syntax - pseudocode not written within Proclaim)

You could generalise this code as an 'emboldeining' function, by creating a temporary holding field e.g. {embolden input text.Text} and use that for the v-input instead, then in your letter BEFORE maths you do code such as

Code: Select all

#copy your desired paragraph text - with tilde for bold - into the input maths field
put ({M any field with text output.Text}, {embolden input text.Text})
#split into emboldened text
v-run={M convert to bold.Text}
your three output fields are then ready to use in your WORD document
Not very elegant but should work in limited circumstances and be quite flexible.

revellbikes
Posts: 422
Joined: Fri Jun 15, 2012 12:44 pm
Has thanked: 11 times
Been thanked: 43 times

Re: Formatting text in maths

Post by revellbikes » Tue Dec 01, 2015 10:15 am

Like most things Proclaim, where there's a will there's a way!

Correct me if I'm wrong, wouldn't you need multiple maths items and alpha fields if you had multiple paragraphs within the same document?

We looked at all sorts of ways round this, but it was just going to be impractical to use maths items on a multipage document.

steve
Posts: 375
Joined: Wed Nov 30, 2011 10:20 pm
Been thanked: 75 times

Re: Formatting text in maths

Post by steve » Tue Dec 01, 2015 10:35 am

true - you'd need multiple sets of fields for each bit you wanted bold. I didn't say it was elegant!

Jacqueline
Posts: 74
Joined: Fri May 25, 2012 2:40 pm
Has thanked: 14 times

Re: Formatting text in maths

Post by Jacqueline » Wed Dec 02, 2015 12:10 am

Thank you very much for those great answers

I need to insert into a Word doc which already contains maths text fields:
~ bold headings
~ one whole paragraph in bold for emphasis so the reader can't miss/forget it.

I will have a go but might end up changing the several WFM documents and inserting the headings inbetween separate maths text fields.

The bold paragraph doesn't need to be bold but it needs to stand out big time and I would imagine any form of emphasis would be dealt with in the same way within the fields.

revellbikes
Posts: 422
Joined: Fri Jun 15, 2012 12:44 pm
Has thanked: 11 times
Been thanked: 43 times

Re: Formatting text in maths

Post by revellbikes » Wed Dec 02, 2015 9:05 am

Hi Jacqueline,

I take it there's a specific reason you're using maths items rather than tests within your document?

Jacqueline
Posts: 74
Joined: Fri May 25, 2012 2:40 pm
Has thanked: 14 times

Re: Formatting text in maths

Post by Jacqueline » Wed Dec 02, 2015 12:37 pm

I inherited a whole lot of letters which are very similar - but possibly not similar enough to use tests.

I am working my way through them trying to minimise repetition and have brought together repeated paragraphs into a maths field which now only need to be amended the once. It's a bigger job going through the content of 10 letters and turning those into one with tests. But perhaps I should have started that way.

Post Reply