cancel
Showing results for 
Search instead for 
Did you mean: 

Word wrapping and line count in output

0 Kudos

Team,


I want to apply word wrapping logic where expected Input data and Expected output data is as below.

My source data can or can't have more than 60 characters, carriage return. I want my output without carriage return

and in 60 charactre fixed width multiple line format.  



Input

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.<CR>

Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.<CR>

Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.<CR>

Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.


Output

1 Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed

2 do eiusmod tempor incididunt ut labore et dolore magna

3 aliqua.

4 Ut enim ad minim veniam, quis nostrud exercitation ullamco

5 laboris nisi ut aliquip ex ea commodo consequat.

6 Duis aute irure dolor in reprehenderit in voluptate velit

7 esse cillum dolore eu fugiat nulla pariatur.

8 Excepteur sint occaecat cupidatat non proident, sunt in

9 culpa qui officia deserunt mollit anim id est laborum.

Accepted Solutions (0)

Answers (3)

Answers (3)

0 Kudos

Can someone send me custom function code ?

I want to use it for different lengths, like in above case its 60.

And I need to avoid word braking also while moving to next line..

former_member223526
Participant
0 Kudos

You can send the input for the above code every time as the left over string i.e

use input as substr(input,1,60) for first column

substr(input,60,60) for second  column so on

if the answer is helpful mark it as helpful

0 Kudos

Hi Madhusudhan,

Can you send me custom function code which created desired output from above input.

I need line number information as well as a part of output

former_member187605
Active Contributor
0 Kudos

How much do you pay? Do you really expect anybody to write your code for free?

No, seriously, have a look at (you could have found it yourself by just searching for the word split in this forum).

0 Kudos

Thanks for inspiring comment..!

I written my own code and tested successfully.

If you look carefully my requirements are fferent.

Anyway,

Now just one issue in my function,

My script has one line where I am using an input parameter(integer) as second parameter to RPAD function. But I get some error like "Second parameter of RPAD must be an integer"

I need to use my function for different length in different jobs so I must keep it parameter..

Any guess ?

former_member223526
Participant
0 Kudos

Hi Roshan,

Try some customfunction like this:

Initial : $Counter = 1;

CustomFun('Input')

While($Counter = 60 or $line = '<CR>')

{

$String = $String||Substr('Input',$Counter,1);

$line = Substr('Input',[$Counter]+1,4);

$Counter = $Counter + 1;

}

Return($String)

Thanks,

Madhu.

former_member106536
Active Participant
0 Kudos

If you use word_ext() using your <CR> as the delimiter...  You can loop through your input lines, then loop through the words within each input line, and conditionally concatenate each word to a single output line, separated by a unique delimiter (on break).

fun stuff.