get_arg(3f) - [M_unicode:SYSTEM] get command line argument (LICENSE:MIT)
Synopsis
Characteristics
Description
Options
Returns
Examples
Author
License
impure elemental function get_arg(position,default) result(out)
integer,intent=(in) :: position type(unicode_type),optional :: default type(unicode_type) :: out
DEFAULT may be default CHARACTER type as well.
get_arg(3) gets the value of the requested command line argument as TYPE(UNICODE_TYPE) .
position Position on command line of requested argument. Zero returns the name of the command executed. Non-existent positions default to returning a null string. default value to return if argument is not set or set to a blank value
out value assigned based on value of environment variable NAME
Sample program:
program demo_get_arg use M_unicode, only : get_arg, ut=> unicode_type, ch=>character use M_unicode, only : assignment(=), operator(//), write(formatted) implicit none integer :: position type(ut) :: default type(ut) :: value type(ut) :: smiley integer :: i character(len=*),parameter :: bracket= (1x,*("[",a,"]",:)) ! smiley=128515 ! set with Unicode code point default=Wish I was first //smiley//! ! set with unicode_type ! ! arguments can be type(unicode_type) or character ! but type(unicode_type) is always returned do position=0,command_argument_count() value=get_arg(position, default ) value=get_arg(position, default%character() ) ! write(*,*)value%character() write(*,(DT))default%get_arg(position) ! ! print each glyph surrounded by brackets write(*,bracket)(value%character(i,i),i=1,value%len()) enddo ! end program demo_get_argResults:
> demo_get_arg > demo_get_arg > [d][e][m][o][_][g][e][t][_][a][r][g]
John S. Urban
