[UP]


Manual Reference Pages  - system_readline (3)

NAME

system_readline(3f) - [M_readline] Call readline(3c) from Fortran (LICENSE:PD)

CONTENTS

Synopsis
Description
Example
Author
License

SYNOPSIS

character(kind=c_char,len=*),intent(in) :: prompt character(kind=c_char,len=*),intent(out) :: line

DESCRIPTION

The system_readline(3f) uses the ISO_C_BINDING module to create a binding to the GNU readline(3c) procedure from Fortran programs.

EXAMPLE

The test program is basically just a read loop that prompts for lines of input read with readline(3c). You can edit the line being read with readline(3c) per its documentation. At a minimum, you can probably move around the line with the left and right arrow keys, and insert characters by typing them wherever you moved the cursor to, and use the DEL/ RUBOUT key to delete characters and such. If you use a GNU/Linux shell with command line editing, you are probably familiar with readline(3c)’s function.

It quits if you enter ’q’ on an input line, and it dumps the history if you enter ’h’.

It is presented here as a Bourne shell script that creates the necessary files and does a "compile, load, and go"

the test program

   program demo_system_readline
      use m_readline, only : system_readline
      implicit none
      character(len=256) :: line
      integer            :: cstat
      character(len=256) :: sstat

write(*,*)’ ____________________________________________________________’ write(*,*)’ Your input lines are now editable using the GNU’ write(*,*)’ readline(3C) procedure. By default, up-arrow and’ write(*,*)’ down-arrow go thru the history lines; left and right arrow’ write(*,*)’ keys and delete and just typing characters let you do’ write(*,*)’ simple editing. Far more input control is available.’ write(*,*)’ See the browser pages and man(1) pages for readline(3c).’ write(*,*)’ ____________________________________________________________’ write(*,*)’ Enter text and then edit it. "q" quits; "h" display history:’

do call system_readline(line,’readline>’) ! read editable input line if(line.eq.’q’) stop call execute_command_line(trim(line),cmdstat=cstat,cmdmsg=sstat) enddo end program demo_system_readline

AUTHOR

John S. Urban

LICENSE

Public Domain

Although this interface to readline(3c) is released as Public Domain, note that the Readline library itself is free software, distributed under the terms of the [GNU] General Public License, version 2.


system_readline (3) October 17, 2020
Generated by manServer 1.08 from 21e2c5fb-8fd2-42ab-b400-35010e5fdf1d using man macros.