 |
forums.silverfrost.com Welcome to the Silverfrost forums
|
View previous topic :: View next topic |
Author |
Message |
silverdan
Joined: 14 May 2009 Posts: 29
|
Posted: Fri Apr 30, 2010 10:24 pm Post subject: TODATE@ and TOTIME@ compile error |
|
|
I'm using the FILEINFO@ subroutine to return the size and time values. In the documentation it mentions using TOTIME@ and TODATE@ to then turn the times/dates into characters. However when i do so, I get the following errors:
Only CHARACTER variables can be assigned to CHARACTER variables, found REAL(KIND=1) C:\test\test\FreeFormat1.F95 12
Only CHARACTER variables can be assigned to CHARACTER variables, found REAL(KIND=1) C:\test\test\FreeFormat1.F95 13
Am I doing something wrong in the sample below?
Code: |
WINAPP
PROGRAM Test
CHARACTER(LEN=8) myDate
CHARACTER(LEN=8) myTime
CHARACTER(LEN=20) PATH
INTEGER (KIND=2) MODE, DEV, RDEV, NLINK, ERROR_CODE
INTEGER (KIND=3) SIZE, ATIME, MTIME, CTIME
PATH = 'C:\CalInstall.log'
Call FILEINFO@(PATH, MODE, DEV, RDEV, NLINK, SIZE, ATIME, MTIME, CTIME, ERROR_CODE)
myDate = TODATE@(ATIME)
myTime = TOTIME@(ATIME)
END PROGRAM Test
|
|
|
Back to top |
|
 |
IanLambley
Joined: 17 Dec 2006 Posts: 506 Location: Sunderland
|
Posted: Sun May 02, 2010 11:43 am Post subject: |
|
|
Yes, but only a small mistake, and it is not really your mistake, it should be stated in the documentation. You also need to define the functions as character*8. and in the case of the TODATE@, you can also define it and its destination variable as LEN=10 to give the two digits of the century as well. See code below:
Code: |
WINAPP
PROGRAM Test
CHARACTER(LEN=10) myDate, TODATE@
CHARACTER(LEN=8) myTime, TOTIME@
CHARACTER(LEN=20) PATH
INTEGER (KIND=2) MODE, DEV, RDEV, NLINK, ERROR_CODE
INTEGER (KIND=3) SIZE, ATIME, MTIME, CTIME
PATH = 'CalInstall.log'
Call FILEINFO@(PATH, MODE, DEV, RDEV, NLINK, SIZE, ATIME, MTIME, CTIME, ERROR_CODE)
myDate = TODATE@(ATIME)
myTime = TOTIME@(ATIME)
print *, mydate, ' ',mytime,atime
END PROGRAM Test
|
The clue that you have to declare the function type as character is in the documentation for DATE@. This also hints that four digit years may be available in other textual date related functions.
The standard for FORTRAN is to use variables beginning a-h, o-z as 4-byte reals and i-n as integer. That is no standard start characters for character variables. You did not use the implicit-none compiler switch, so it thought the functions were real, hence the error message. Using that option would have forced you to declare the function type at the point of use.
Regards
Ian |
|
Back to top |
|
 |
silverdan
Joined: 14 May 2009 Posts: 29
|
Posted: Mon May 03, 2010 3:26 pm Post subject: |
|
|
Thanks Ian, that was explained perfectly. |
|
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
|