Enter Home Page

JUCMD(3F): Fortran-based Input History Editor

John S. Urban, 1988,2009,2011 (last change: Mar 2013)

NAME

JUCMD(3f)

SYNOPSIS

The Fortran procedure JUCMD(3f) lets a programmer easily add input line recall and editing to interactive CLI (Command Line Interface) programs.

DESCRIPTION

the JUCMD(3f) routine lets you list, save, and modify your interactively entered program input.

The JUCMD(3f) input history editor is simple to use, portable, reusable and reliably (it has been used for decades). A line editor model is used; which means no special escape characters or control characters are required. In addition, there is built-in help.

Typically, only a few minutes are required to master usage; especially for those familiar with a line editor.

JUCMD(3f) is modeled on the MODIFY and CHANGE commands in the CDC NOS line editor XEDIT; and the related NOS command REDO.

Sample run of example program

In this example (using the sample program at the end of this document), we will execute the command

 echo This isss a Test

and use a few of the features to change it to

 echo This is a new TEST

and then execute the edited command.

sh-3.2$ ./redo
--------------------------------------------------
 TEST OF JUCMD(3f) COMMAND INPUT EDITOR

 Enter a few commands to be passed to the shell
 and then enter "r" or "r r_command" on the input
 line to go into history edit mode.
 once in history edit mode you may enter
 "?" to get some help.
 Enter the command "quit" to exit
--------------------------------------------------
>echo This isss a Test
This isss a Test
>date
Sun May 31 23:54:09 EDT 2009
>pwd
/cygdrive/c/urbanjs/MYCYGWIN/DISKA/public_html/public/CLONE/JUCMD
>r
00001 echo This isss a Test
00002 date
00003 pwd
!pwd
>1
!echo This isss a Test
             ##   t
!echo This is a test
                ^new #
!echo This is a new test
c/test/TEST/
!echo This is a new TEST

This is a new TEST
>quit

That is,

  1. run the test program and type system commands,
  2. then type "r" on a line by itself to go into edit mode. By default, you will be editing the last line you entered, shifted one character to the right by an exclamation character.
  3. Select the line to edit by entering it's line number or by using the /,l,u, and d commands
  4. edit the selected line. For example
  5. You will stay in edit mode until you enter a return on a blank line to feed it to your program; or enter "." or "q" .

If you enter "?" while in command edit mode, help is displayed:

#-----------------------------------------------------------------------------# |REDO MODE OPTIONS (where N is a number): | |-----------------------------------------------------------------------------| |LIST HISTORY(and set buffer to last printed line): | | l|p N # list from line N. -N shows N last lines | | L|P N # same as l without line numbers | | /string # search for simple string | | w|D file # write entire history to a file | |-----------------------------------------------------------------------------| |SET BUFFER TO A LINE: | | u|b N # up/back through buffer | | d|f N # down/forward through buffer | | N # load line number | |-----------------------------------------------------------------------------| |EDIT BUFFER: | | c|s/oldstring/newstring/ # change/substitute | | mmod_string # Modify with line number header | | mod_string # Modify (replace, delete, insert) | | # -- deletes | | & -- replaces with a blank | | ^STRING# -- inserts a string | | -- blank leaves as-is | | Any other -- replaces character | |-----------------------------------------------------------------------------| |RETURN TO NORMAL COMMAND MODE: | | # return and execute command in buffer | | .|q # quit and return a blank line | |-----------------------------------------------------------------------------| |HELP: | | h|? # display this help text | #-----------------------------------------------------------------------------#

Compilation

Compilation of the test program and module varies depending on your programming environment, but here is an example that builds the test program using gfortran(1):

   gfortran -DTESTPRG90 -J. -static M_history.f90 redo.F90

Source and Related Files

A simple man(1)-page for jucmd(3f) should be added to your environment if you install the module.