Manual Reference Pages  - bundle (3m_strings)

NAME

bundle(3f) - [M_strings:ARRAY] return up to twenty strings of arbitrary length as an array (LICENSE:PD)

CONTENTS

Synopsis
Description
Options
Examples
Author
License

SYNOPSIS

function bundle(str1,str2,...str20,len) result (vec)

    character(len=*),intent(in),optional   :: str1, str2 ... str20
    integer,intent(in),optional            :: len

DESCRIPTION

Given a list of up to twenty strings create a string array. The length of the variables will be the same as the maximum length of the input strings unless explicitly specified via LEN.

This is an alternative to the syntax

     [ CHARACTER(LEN=NN) :: str1, str2, ... ]

that by default additionally calculates the minimum length required to prevent truncation.

OPTIONS

str1,str2, ... str20
  input strings to combine into a vector
len length of returned array variables

EXAMPLES

Sample Program:

   program demo_bundle
   use M_strings, only: bundle
   implicit none
   character(len=*),parameter :: fmt= "(*(’""’,a,’""’:,’,’,1x))"
   character(len=:),allocatable :: array(:)
      print fmt, bundle("one")
      print fmt, bundle("one","two")
      print fmt, bundle("one","two","three")
      array=bundle("one","two","three","four","five","six","seven")
      write(*,’(*(g0))’)’size=’,size(array),’,len=’,len(array)
      write(*,’("[",a,"]")’)array
   end program demo_bundle

Results:

 > "one"
 > "one", "two"
 > "one  ", "two  ", "three"
 > size=7,len=5
 > [one  ]
 > [two  ]
 > [three]
 > [four ]
 > [five ]
 > [six  ]
 > [seven]

AUTHOR

John S. Urban

LICENSE

Public Domain


Nemo Release 3.1 bundle (3m_strings) January 10, 2025
Generated by manServer 1.08 from 1782874d-e10b-430c-817e-484df7279094 using man macros.