[UP]


Manual Reference Pages  - atleast (3)

NAME

atleast(3f) - [M_strings:LENGTH] return string padded to at least specified length (LICENSE:PD)

CONTENTS

Synopsis
Description
Options
Returns
Example
Author
License

SYNOPSIS

function atleast(str,length,pattern) result(strout)

character(len=*) :: str integer,intent(in) :: length character(len=max(length,len(trim(line)))) :: strout character(len=*),optional :: pattern

DESCRIPTION

atleast(3f) pads a string with spaces to at least the specified length. If the trimmed input string is longer than the requested length the trimmed string is returned.

OPTIONS

str the input string to return trimmed, but then padded to the specified length if shorter than length
length The minimum string length to return
pattern
  optional string to use as padding. Defaults to a space.

RETURNS

strout The input string padded to the requested length or the trimmed input string if the input string is longer than the requested length.

EXAMPLE

Sample Program:

   program demo_atleast
    use M_strings, only : atleast
    implicit none
    character(len=10)            :: string=’abcdefghij’
    character(len=:),allocatable :: answer
    integer                      :: i
       answer=atleast(string,5)
       write(*,’("[",a,"]")’) answer
       answer=atleast(string,20)
       write(*,’("[",a,"]")’) answer
       i=30
       write(*,*)
       write(*,’(1x,a,i0)’) atleast(’CHAPTER 1 : The beginning ’,i,’.’), 1
       write(*,’(1x,a,i0)’) atleast(’CHAPTER 2 : The end ’,i,’.’),       1234
       write(*,’(1x,a,i0)’) atleast(’APPENDIX ’,i,’.’),                  1235
       write(*,*)
       write(*,’(1x,a,i7)’) atleast(’CHAPTER 1 : The beginning ’,i,’.’), 1
       write(*,’(1x,a,i7)’) atleast(’CHAPTER 2 : The end ’,i,’.’),       1234
       write(*,’(1x,a,i7)’) atleast(’APPENDIX ’,i,’.’),                  1235
   end program demo_atleast

Results:

  [abcdefghij]
  [abcdefghij          ]

CHAPTER 1 : The beginning ....1 CHAPTER 2 : The end ..........1234 APPENDIX .....................1235

CHAPTER 1 : The beginning .... 1 CHAPTER 2 : The end .......... 1234 APPENDIX ..................... 1235

AUTHOR

John S. Urban

LICENSE

Public Domain


atleast (3) July 05, 2020
Generated by manServer 1.08 from 89f64747-8dbe-4f02-a6a2-78acb01a42a6 using man macros.