Focal Point Banner
Community Center Education Summit Technical Support User Groups
Let's Get Social!

Facebook Twitter LinkedIn YouTube
Focal Point    Focal Point Forums  Hop To Forum Categories  WebFOCUS/FOCUS Forum on Focal Point     [CLOSED] Text Formatting
Go
New
Search
Notify
Tools
Reply
  
[CLOSED] Text Formatting
 Login/Join
 
Member
posted
Hello, I have a field in a database that has a lot of text and I need to place sentences on a new line within a single compute virtual field when prefixed with a >>

I also need to look for words that have a double equals sign before and after the word and place them on their own line. So within one compute virtual field, I need to have this format:

==Prepare Muffins==
>>Get the flour
>>Get the sugar
>>Find some berries
==Bake The Muffins==
>>set oven to 350
>>grease a pan
>>place muffins in oven
>>set timer for 40 min

Right now, the data in the field looks like:

==Prepare Muffins==>>Get the flour>>Get the sugar>>Find some berries==Bake The Muffins==..and so on.

Is this possible with some text functions?

Using App Studio 8204
Thanks

This message has been edited. Last edited by: FP Mod Chuck,
 
Posts: 16 | Registered: April 18, 2019Reply With QuoteReport This Post
Virtuoso
posted Hide Post
You'll have to use some of these functions in a DEFINE to accomplish this.
https://webfocusinfocenter.inf...cterSimplified70.htm


WebFOCUS 8206, Unix, Windows
 
Posts: 1660 | Location: New York City | Registered: December 30, 2015Reply With QuoteReport This Post
Expert
posted Hide Post
Whats the output format ?


Waz...

Prod:WebFOCUS 7.6.10/8.1.04Upgrade:WebFOCUS 8.2.05OS:LinuxOutputs:HTML, PDF, Excel, PPT
In Focus since 1984
Know The Code

 
Posts: 6104 | Location: Land of the Darug people, Terra Australis Incognita | Registered: October 31, 2006Reply With QuoteReport This Post
Guru
posted Hide Post
quote:
Originally posted by Waz:
Whats the output format ?


Agreed. In order to answer this, we need to know what the output will be, since outputs have different answers.

There is probably a better way to do this, but this COMPUTE with nested functions works for HTML
  
-SET &TEXT = '==Prepare Muffins==>>Get the flour>>Get the sugar>>Find some berries==Bake The Muffins==>>set oven to 350>>grease a pan>>place muffins in oven>>set timer for 40 min';

TABLE FILE CAR
PRINT COMPUTE NEWFIELD/A200V = SUBSTRING(REPLACE(REPLACE(REPLACE(&TEXT.QUOTEDSTRING,'>>','<br>>>'),'==','<br>=='),'<br>==<br>>>','==<br>>>'),5,200);
BY COUNTRY NOPRINT
WHERE COUNTRY EQ 'ENGLAND'
ON TABLE SET PAGE-NUM NOPAGE
END



Hallway
WF(Prod):8202M
WF(Test):8202M
OS/Platform:Win 10
Outputs:All
 
Posts: 431 | Location: Salt Lake City, UT, USA | Registered: November 18, 2015Reply With QuoteReport This Post
Guru
posted Hide Post
In JavaScript you can use the replace function using a regular expression. Copy/paste this code into the console of any modern browser (And no, IE is not a modern browser)
 
var oldText = '==Prepare Muffins==>>Get the flour>>Get the sugar>>Find some berries==Bake The Muffins==>>set oven to 350>>grease a pan>>place muffins in oven>>set timer for 40 min'
var newText = oldText.replace(/(?<=[a-z])={2}(?!>)|>{2}/g, '\n$&')
console.log(newText);
 

That will return the following to the console:
 
==Prepare Muffins==
>>Get the flour
>>Get the sugar
>>Find some berries
==Bake The Muffins==
>>set oven to 350
>>grease a pan
>>place muffins in oven
>>set timer for 40 min
 


Hallway
WF(Prod):8202M
WF(Test):8202M
OS/Platform:Win 10
Outputs:All
 
Posts: 431 | Location: Salt Lake City, UT, USA | Registered: November 18, 2015Reply With QuoteReport This Post
Member
posted Hide Post
Thanks for the replies. PDF is my output. What is my bet option then?

Thank you!
 
Posts: 16 | Registered: April 18, 2019Reply With QuoteReport This Post
Expert
posted Hide Post
Welcome DataMuncher,

Use Hallways first method but use HEXBYT(10,'A1') to insert a linefeed character instead of the the HTML breaks ( <br> ) then use LINEFEED='LF' within the styling.

Linefeed can be found in the help files here

T



In FOCUS
since 1986
WebFOCUS Server 8.2.01M, thru 8.2.06 on Windows Svr 2008 R2  
WebFOCUS App Studio 8.2.06 standalone on Windows 10 
 
Posts: 5601 | Location: United Kingdom | Registered: April 08, 2004Reply With QuoteReport This Post
Member
posted Hide Post
Sorry, just made a discovery. The carriage returns and line feeds are coming across fine in the SQL field I'm using. For example, when I copy that text from Oracle SQL Developer to Notepad, I can see the format as intended. Is there a way I can tell the field in App Studio to just observe the CRs and LFs that are stored in the text field?
 
Posts: 16 | Registered: April 18, 2019Reply With QuoteReport This Post
Expert
posted Hide Post
Yes, use the LINEFEED syntax within your styling. You need to have consistant characters in your data or just take a punt and specify just LINEFEED=CR or LINEFEED=LF.

This should be found in the documentation link that I gave.

T



In FOCUS
since 1986
WebFOCUS Server 8.2.01M, thru 8.2.06 on Windows Svr 2008 R2  
WebFOCUS App Studio 8.2.06 standalone on Windows 10 
 
Posts: 5601 | Location: United Kingdom | Registered: April 08, 2004Reply With QuoteReport This Post
Guru
posted Hide Post
quote:
Originally posted by DataCarniv0r:
Thanks for the replies. PDF is my output. What is my bet option then?

Thank you!


This works:
 
-SET &TEXT = '==Prepare Muffins==>>Get the flour>>Get the sugar>>Find some berries==Bake The Muffins==>>set oven to 350>>grease a pan>>place muffins in oven>>set timer for 40 min';

DEFINE FILE CAR 
NEWFIELD/A200V WITH COUNTRY = SUBSTRING(REPLACE(REPLACE(REPLACE(&TEXT.QUOTEDSTRING,'>>', CTRLCHAR(CR) | CTRLCHAR(LF) | '>>' ),'==', CTRLCHAR(CR) | CTRLCHAR(LF) | '=='),CTRLCHAR(CR) | CTRLCHAR(LF) |'=='|CTRLCHAR(CR) | CTRLCHAR(LF) |'>>','=='| CTRLCHAR(CR) | CTRLCHAR(LF) |'>>'),3,200);
END
TABLE FILE CAR
SUM NEWFIELD
ON TABLE PCHOLD FORMAT PDF
-* ON TABLE NOTOTAL
-* ON TABLE SET DROPBLNKLINE ALL
-* ON TABLE SET PAGE-NUM NOPAGE
-* ON TABLE SET CACHELINES 100
-* ON TABLE SET GRWIDTH 1
-* ON TABLE SET AUTOFIT OFF
ON TABLE SET STYLE *
TYPE=REPORT,LINEBREAK='CRLF',$
ENDSTYLE
END 


More here: CTRLCHAR: Returning a Non-Printable Control Character


Hallway
WF(Prod):8202M
WF(Test):8202M
OS/Platform:Win 10
Outputs:All
 
Posts: 431 | Location: Salt Lake City, UT, USA | Registered: November 18, 2015Reply With QuoteReport This Post
Guru
posted Hide Post
quote:
Originally posted by Tony A:
Yes, use the LINEFEED syntax within your styling. You need to have consistant characters in your data or just take a punt and specify just LINEFEED=CR or LINEFEED=LF.

This should be found in the documentation link that I gave.

T


or if there is a CR and a LF, try:
 
TYPE=REPORT,LINEBREAK='CRLF',$



Syntax: How to Display An and AnV Fields Containing Line Breaks on Multiple Lines


TYPE=REPORT,LINEBREAK='type',$


where:



REPORT

Is the type of report component. TYPE must be REPORT. Otherwise an error will result.

'type'

Specifies that line breaks will be inserted in a report based on the following:

LF inserts a line break after each line-feed character found in all An and AnV fields.

CR inserts a line break after each carriage-return character found in all An and AnV fields.

LFCR inserts a line break after each combination of a line-feed character followed by a carriage-return character found in all An and AnV fields.

CRLF inserts a line break after each combination of a carriage-return character followed by a line-feed character found in all An and AnV fields.







More Here: Displaying Multi-Line An and AnV Fields

This message has been edited. Last edited by: Hallway,


Hallway
WF(Prod):8202M
WF(Test):8202M
OS/Platform:Win 10
Outputs:All
 
Posts: 431 | Location: Salt Lake City, UT, USA | Registered: November 18, 2015Reply With QuoteReport This Post
Member
posted Hide Post
Thank you both very much. It works like a champ, but now I have a new problem.

This works: I created a computed column using:
CTRAN(1000, MY_SQL_FIELD, 094, 013, Funding)

Then I added this to my source within the style section as per the docs:
TYPE=REPORT,LINEBREAK='CR',$

When I run it, it looks exactly as expected. I saved it. But when I switch to the Design tab, and then back to the Source tab, the TYPE=REPORT,LINEBREAK='CR',$ line I put in there is gone!

Is this a known issue or is there any workaround I can do?

Thanks
 
Posts: 16 | Registered: April 18, 2019Reply With QuoteReport This Post
Member
posted Hide Post
I guess I could just add that line back in the source when I'm done with the entire report, and then save it. Not a big deal. Thanks again.
 
Posts: 16 | Registered: April 18, 2019Reply With QuoteReport This Post
Guru
posted Hide Post
quote:
Originally posted by DataCarniv0r:

When I run it, it looks exactly as expected. I saved it. But when I switch to the Design tab, and then back to the Source tab, the TYPE=REPORT,LINEBREAK='CR',$ line I put in there is gone!

Is this a known issue or is there any workaround I can do?

Thanks


There are a lot if issues with AppStudio reformatting/replacing code in the GUI. It get frustrating at times when the GUI doesn't even recognize valid FOCUS code like you are experiencing. If I ever use the GUI it is just to get the basic report laid out. I then open the report in VSCode (or any other text editor you may prefer) and edit the code in that if I need to do any tweaks.

Good luck.

This message has been edited. Last edited by: Hallway,


Hallway
WF(Prod):8202M
WF(Test):8202M
OS/Platform:Win 10
Outputs:All
 
Posts: 431 | Location: Salt Lake City, UT, USA | Registered: November 18, 2015Reply With QuoteReport This Post
  Powered by Social Strata  
 

Focal Point    Focal Point Forums  Hop To Forum Categories  WebFOCUS/FOCUS Forum on Focal Point     [CLOSED] Text Formatting

Copyright © 1996-2018 Information Builders, leaders in enterprise business intelligence.