[UP]


Manual Reference Pages  - modif (3)

NAME

modif(3f) - [M_strings:EDITING] emulate the MODIFY command from the line editor XEDIT (LICENSE:PD)

CONTENTS

Synopsis
Description
Examples
Author
License

SYNOPSIS

subroutine modif(cline,cmod)

character(len=*) :: cline ! input string to change character(len=*) :: cmod ! directive provides directions on changing string

DESCRIPTION

MODIF(3f) Modifies the line currently pointed at using a directive that acts much like a line editor directive. Primarily used to create interactive utilities such as input history editors for interactive line-mode programs.

the modify directives are as follows-

    DIRECTIVE EXPLANATION

^STRING#
  Causes the string of characters between the ^ and the next # to be inserted before the characters pointed to by the ^. an ^ or & within the string is treated as a regular character. If the closing # is not specified, MODIF(3f) inserts the remainder of the line as if a # was specified after the last nonblank character.

There are two exceptions. the combination ^# causes a # to be inserted before the character pointed to by the ^, and an ^ as the last character of the directives causes a blank to be inserted.

# (When not the first # after an ^) causes the character above it to be deleted.
& Replaces the character above it with a space.
(SPACE) A space below a character leaves it unchanged.
Any other character replaces the character above it.

EXAMPLES

Example input/output:

   THE INPUT LINE........ 10 THIS STRING  TO BE MORTIFD
   THE DIRECTIVES LINE...        ^ IS THE#        D#  ^IE
   ALTERED INPUT LINE.... 10 THIS IS THE STRING  TO BE MODIFIED

Sample program:

   program demo_modif
   use M_strings, only : modif
   implicit none
   character(len=256)           :: line
   integer                      :: ios
   integer                      :: count
   integer                      :: COMMAND_LINE_LENGTH
   character(len=:),allocatable :: COMMAND_LINE
      ! get command name length
      call get_command_argument(0,length=count)
      ! get command line length
      call get_command(length=COMMAND_LINE_LENGTH)
      ! allocate string big enough to hold command line
      allocate(character(len=COMMAND_LINE_LENGTH+200) :: COMMAND_LINE)
      ! get command line as a string
      call get_command(command=COMMAND_LINE)
      ! trim leading spaces just in case
      COMMAND_LINE=adjustl(COMMAND_LINE)
      ! remove command name
      COMMAND_LINE=adjustl(COMMAND_LINE(COUNT+2:))
      INFINITE: do
         read(*,’(a)’,iostat=ios)line
         if(ios.ne.0)exit
         call modif(line,COMMAND_LINE)
         write(*,’(a)’)trim(line)
      enddo INFINITE
   end program demo_modif

AUTHOR

John S. Urban

LICENSE

Public Domain


modif (3) July 05, 2020
Generated by manServer 1.08 from f202f595-530c-488f-a308-2522f5119ec9 using man macros.