modif(3f) - [M_strings:EDITING] emulate the MODIFY command from the line editor XEDIT (LICENSE:PD)
Synopsis
Description
Examples
Author
License
subroutine modif(cline,cmod)
character(len=*) :: cline ! input string to change ! directive provides directions on changing string character(len=*) :: cmod
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-
Any other character replaces the character above it.
^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.
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 MODIFIEDSample program:
program demo_modif use M_strings, only : modif implicit none character(len=256) :: line integer :: iostat 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=iostat)line if(iostat /= 0)exit call modif(line,COMMAND_LINE) write(*,(a))trim(line) enddo INFINITE end program demo_modif
John S. Urban
Public Domain
Nemo Release 3.1 | modif (3m_strings) | January 10, 2025 |