.nf NAME jucmd(3f) SYNOPSIS/USAGE jucmd(3f) from module M_history lets you add command line history editing to your program. To use it, read input lines into a character variable and then pass them to the routine. The returned string can then be parsed or read from with an internal READ. So if you have an existing READ READ(5,101)A,I,K replace it with something like USE M_HISTORY,ONLY : JUCMD CHARACTER(LEN=255) :: LINE READ(5,'(A)') LINE CALL JUCMD(LINE) READ(LINE,101)A,I,K Then if anyone enters "r" on a line by itself or a line beginning with "r ", the user will enter the command history editing mode. DESCRIPTION Usage from programs calling jucmd(3f): r # enter command history editing mode r [directive] # recall and display or edit previously entered commands Enter an R command on a line by itself to enter redo mode. The last command entered is displayed, preceded by an !. The character you respond with in column 1 controls what happens next. 1. Use a positioning directive (/,l,u,d,N) to find the command to start editing if it was not the last command entered. 2. Next enter an editing directive (c,m) as described below. 3. Once the change is executed you will be prompted for another edit directive 4. Once done editing (or listing) enter: ☆ a blank line (to execute the displayed command) ☆ a period (.) on a line by itself (which means cancel). N stands for a number in the following directives. LISTING COMMAND HISTORY (buffer set to last line displayed) l|p N # list from line N. -N shows N last lines L|P N # same as 'l' except no line numbers (for pasting) /string # search for simple string in all history lines POSITIONING TO PREVIOUS COMMANDS u N # up through buffer d N # down through buffer N # load line number EDITING THE CURRENT BUFFER LINE (Changing and Modifying) c/oldstring/newstring/ # change string s (for substitute) is a synonym for c. mmod_string If the first character of your entry is m or blank, REPLACE a string by entering a replacement character under it LEAVE a character alone by leaving a space under it DELETE a character by putting a # character under it BLANK OUT a character by putting an & under it INSERT A STRING by entering ^STRING# HELP h|? # display help text DUMPING THE COMMAND HISTORY w FILENAME # write entire command history to specified file EXAMPLE r !math c(1)*sin(c(1)) # last command is displayed c/sin/cos/ # change a substring !math c(1)*cos(c(1)) ^1+# # insert a string !math c(1)*cos(1+c(1)) 2 )) # replace characters !math c(2)*cos(1+c(1)))) ## # delete characters !math c(2)*cos(1+c(1)) && & # replace characters with spaces !mat c 2)*cos(1+c(1)) . # stop NOTES For the "c" directive the second character becomes the delimiter. Only use a delimiter of / or % or @. In the future other characters may not work. The "modify" directive takes a little practice if you were never a CDC NOS user but this single directive accommodates positionally deleting, replacing, and inserting text. In this implementation it is hard to put the strings "&" and "#" into your new commands. to put a # character into a string put something else there and change it to a # using the 'c' command. To put an & into a string use the same method or insert it using ^&#. As written, this module uses Fortran unit 71.