Manual Reference Pages  - paragraph (3m_strings)

NAME

paragraph(3f) - [M_strings:TOKENS] break a long line into a paragraph (LICENSE:PD)

CONTENTS

Synopsis
Description
Options
Returns
Examples
Author
License

SYNOPSIS

function paragraph(source_string,length)

   character(len=*),intent(in)       :: source_string
   integer,intent(in)                :: length
   character(allocatable(len=length)    :: paragraph(:)

DESCRIPTION

paragraph(3f) breaks a long line into a simple paragraph of specified line length.

Given a long string break it on spaces into an array such that no variable is longer than the specified length. Individual words longer than LENGTH will be placed in lines by themselves and the paragraph width will be increased to the length of the longest word.

OPTIONS

SOURCE_STRING
  input string to break into an array of shorter strings on blank delimiters
LENGTH length of lines to break the string into.

RETURNS

PARAGRAPH
  character array filled with data from source_string broken at spaces into variables of length LENGTH.

EXAMPLES

sample program

   program demo_paragraph
   use M_strings, only : paragraph
   implicit none
   character(len=:),allocatable :: paragrph(:)
   character(len=*),parameter    :: string= ’&
    &one two three four five &
    &six seven eight &
    &nine ten eleven twelve &
    &thirteen fourteen fifteen sixteen &
    &seventeen’

write(*,*)’LEN=’,len(string) write(*,*)’INPUT:’ write(*,*)string

paragrph=paragraph(string,40) write(*,*)’LEN=’,len(paragrph),’ SIZE=’,size(paragrph) write(*,*)’OUTPUT:’ write(*,’(a)’)paragrph

write(*,’(a)’)paragraph(string,0) write(*,’(3x,a)’)paragraph(string,47)

end program demo_paragraph

Results:

    LEN=         106
    INPUT:
    one two three four five six seven eight nine ten eleven twelve
    thirteen fourteen fifteen sixteen seventeen
    LEN=          40  SIZE=           3
    OUTPUT:
one two three four five six seven eight nine ten eleven twelve thirteen fourteen fifteen sixteen seventeen one two three four five six seven eight nine ten eleven twelve thirteen fourteen fifteen sixteen seventeen one two three four five six seven eight nine ten eleven twelve thirteen fourteen fifteen sixteen seventeen

AUTHOR

John S. Urban

LICENSE

Public Domain


Nemo Release 3.1 paragraph (3m_strings) July 20, 2024
Generated by manServer 1.08 from 32de0a8b-b5bd-48cc-9985-91f3c174b8d3 using man macros.