[UP]


Manual Reference Pages  - fmt (3)

NAME

fmt(3f) - [M_strings:TOKENS] Tokenize a string, consuming it one token per call (LICENSE:PD)

CONTENTS

Synopsis
Description
Options
Returns
Example
Author
License

SYNOPSIS

function fmt(source_string,length)

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

DESCRIPTION

fmt(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 variables by themselves.

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

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

EXAMPLE

sample program

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

paragraph=fmt(string,40) write(*,’(a)’)paragraph

write(*,’(a)’)fmt(string,0) write(*,’(3x,a)’)fmt(string,77)

end program demo_fmt

Results:

   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


fmt (3) July 05, 2020
Generated by manServer 1.08 from 25eb0168-9c29-4909-9478-526617386e24 using man macros.