|
forums.silverfrost.com Welcome to the Silverfrost forums
|
View previous topic :: View next topic |
Author |
Message |
leszpol
Joined: 25 Apr 2008 Posts: 29 Location: Gdynia-TriCity
|
Posted: Sat Apr 26, 2008 11:03 am Post subject: CMNAM PROBLEM |
|
|
Dera users
I precompiled sample program form Plato
which is attached to explain using form of
CMNAM function. The problem is that CMNAM
see external tocken (after compilation
like FTN95 COPY.F95 /LINK /PARAMS I obtained
COPY.EXE and run it like copy.exe abc.txt. When the program is run he always skips to the 201 label. In the code there isn't seen L logical variable as a .TRUE. When I force it and manualy wirte L=.TRUE. it
shows me 'File to be written already exists OK to overwrite? (y/n)'
but after pushing Y or y he skips to also to 201 label. Why isn't there seen
IF (L) THEN...It seems that it can't see that L is .TREU. It is very importan to me ? Can you help me ?
PROGRAM COPY_FILE
CHARACTER (LEN=20)::CMNAM,FILE2
CHARACTER (LEN=128)::DATA
INTEGER*2 K
LOGICAL::L
OPEN(UNIT=3,FILE=CMNAM(),STATUS='MODIFY',ERR=200)
FILE2=CMNAM()
INQUIRE(FILE=FILE2,EXIST=L)
IF (L) THEN
PRINT *,'********************************************************'
PRINT *,'File to be written already exists OK to overwrite? (y/n)'
PRINT *,'********************************************************'
CALL GET_KEY@(K)
IF((K /= 89).AND.(K /= 121)) STOP
PRINT*,'Y'
ENDIF
OPEN(UNIT=4,FILE=FILE2,STATUS='MODIFY',ERR=210)
DO
READ (3,'(A)',END=220) DATA
WRITE(4,'(A)') DATA
END DO
200 PRINT *,'******************************'
PRINT *,'File to be read does not exist'
PRINT *,'******************************'
STOP
210 PRINT *,'*************************************'
PRINT *,'File to be written can not be created'
PRINT *,'*************************************'
220 END PROGRAM COPY_FILE |
|
Back to top |
|
|
PaulLaidler Site Admin
Joined: 21 Feb 2005 Posts: 7925 Location: Salford, UK
|
Posted: Sat Apr 26, 2008 3:19 pm Post subject: |
|
|
It looks like the trailing spaces are causing a problem.
One approach is to use something like the following...
Code: | PROGRAM COPY_FILE
CHARACTER (LEN=20)::CMNAM,FILE2
CHARACTER (LEN=128)::DATA
INTEGER*2 K
LOGICAL::L
FILE2=CMNAM()
OPEN(UNIT=3,FILE=FILE2(1:LEN(FILE2)),STATUS='MODIFY',ERR=200)
INQUIRE(FILE=FILE2(1:LEN(FILE2)),EXIST=L)
IF (L) THEN
PRINT *,'********************************************************'
PRINT *,'File to be written already exists OK to overwrite? (y/n)'
PRINT *,'********************************************************'
CALL GET_KEY@(K)
IF((K /= 89).AND.(K /= 121)) STOP
PRINT*,'Y'
ENDIF
OPEN(UNIT=4,FILE=FILE2(1:LEN(FILE2)),STATUS='MODIFY',ERR=210)
DO
READ (3,'(A)',END=220) DATA
WRITE(4,'(A)') DATA
END DO
200 PRINT *,'******************************'
PRINT *,'File to be read does not exist'
PRINT *,'******************************'
STOP
210 PRINT *,'*************************************'
PRINT *,'File to be written can not be created'
PRINT *,'*************************************'
220 END PROGRAM COPY_FILE |
|
|
Back to top |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|