CMNAM

Platform

x64, Win32

Purpose

To read a token from the command line.

Syntax

CHARACTER (LEN=*) FUNCTION CMNAM()

Description

This function is useful for programs which are to be used as commands with arguments on the command line. Arguments (or "tokens") are separated by spaces (not slashes).

Return value

CMNAM reads a token and returns it as the character result. Spaces are returned when tokens are exhausted.

Notes

This is a Silverfrost library function.

Example

!This program operates like the MS-DOS COPY command.
!Eg. store the program in COPY.FOR and type:
!FTN95 COPY /LGO /PARAMS
<FIRST file> <SECOND file>    PROGRAM COPY_FILE
     CHARACTER (LEN=20)::CMNAM,FILE2
     CHARACTER (LEN=128)::DATA
     INTEGER (KIND=2)::KEY
     LOGICAL::L
    OPEN(UNIT=3,FILE=CMNAM(),STATUS='READONLY',ERR=200) 
     FILE2=CMNAM()
    INQUIRE(FILE=FILE2,EXIST=L)
     IF (L) THEN PRINT *,'File to be written already exists &
      & OK to overwrite? (y/n)' 
      CALL GET_KEY@(KEY)
      IF((KEY /= 89).AND.(KEY /= 121)) STOP
      PRINT*,'y'
     ENDIF
    OPEN(UNIT=4,FILE=FILE2,STATUS='MODIFY',ERR=210)
!Copy file one line at a time       
     DO
      READ(3,'(A)',END=220) DATA 
      WRITE(4,'(A)') DATA 
     END DO
200  PRINT*,'File to be read does not exist' 
     STOP
210  PRINT*,'File to be written can not be created'
220 END PROGRAM COPY_FILE

 

 

Basket
Empty
 
Copyright © 1999-2024 Silverfrost Limited