|
forums.silverfrost.com Welcome to the Silverfrost forums
|
View previous topic :: View next topic |
Author |
Message |
patrickm
Joined: 21 Jul 2023 Posts: 3
|
Posted: Fri Jul 21, 2023 4:43 pm Post subject: DIRENT@ problem on FTN 8.95.0 |
|
|
The example program from the manual:
PROGRAM DIRENT
CHARACTER (LEN=20)::PAT,FILE
INTEGER (KIND=2)::ATTR,DATE,TIME,EC
INTEGER (KIND=3)::SIZE
CALL COUA@('Input directory pattern:')
READ '(A)',PAT
EC=0
DO WHILE(EC == 0)
CALL DIRENT@(PAT,0,FILE,ATTR,DATE,TIME,SIZE,EC)
IF (EC == 0) PRINT '(A,I6,I6,I6,I6)',FILE, ATTR, DATE, TIME, SIZE
!Do not call DIRENT@(PAT2,...) from here
END DO
END PROGRAM DIRENT
Does not work for either x64 or Win32
For x64 I get DIRENT@ is an undefined symbol during linking.
For Win32 the program links OK, but on running there is an error:
In DIRENT@ - dummied out at present |
|
Back to top |
|
|
DanRRight
Joined: 10 Mar 2008 Posts: 2863 Location: South Pole, Antarctica
|
Posted: Fri Jul 21, 2023 8:16 pm Post subject: |
|
|
Use get_filtered_file@
Extracted from the code :
Code: |
title = 'Select File'
path = '.'
file_name = 'a.rtg'
filter_names(1) = 'RTG files'
filters(1) = '*.rtg'
filter_names(2) = 'All files'
filters(2) = '*.*'
number_of_filters = 2
must_exist = .true.
call get_filtered_file@(title, file_name, path, filter_names, filters, number_of_filters, must_exist)
file_nameRTGsel = file_name
|
Last edited by DanRRight on Sat Jul 22, 2023 8:40 pm; edited 1 time in total |
|
Back to top |
|
|
PaulLaidler Site Admin
Joined: 21 Feb 2005 Posts: 8011 Location: Salford, UK
|
Posted: Sat Jul 22, 2023 7:54 am Post subject: |
|
|
The routine to use is FILES@.
It looks like DIRENT@ is an FTN77 routine that should not be in the FTN95 documentation. |
|
Back to top |
|
|
JohnCampbell
Joined: 16 Feb 2006 Posts: 2580 Location: Sydney
|
Posted: Sat Jul 22, 2023 8:01 am Post subject: |
|
|
Hopefully this post of using files8@ answers some questions Code: | PROGRAM DIRENT_test
! SUBROUTINE FILES@(PAT, N, NMAX, FILES, ATTR, DATE, TIME, FILE_SIZE)
integer*2, parameter :: nmax = 1024
CHARACTER (LEN=128) PAT,FILES(NMAX)
INTEGER (KIND=2) N, i
INTEGER (KIND=2) ATTR(NMAX), DATE(NMAX), TIME(NMAX)
! INTEGER (KIND=3) FSIZE(NMAX)
REAL (KIND=2) FSIZE(NMAX)
integer (KIND=4) jsize
character :: cattr*6, cdate*10, ctime*8
CALL COUA@('Input directory pattern:')
READ '(A)',PAT
call FILES8@ (PAT, N, NMAX, FILES, ATTR, DATE, TIME, FSIZE)
DO i = 1,n
cattr = attr_string (attr(i))
cdate = date_string (date(i))
ctime = time_string (time(i))
jsize = fsize(i)
write (*,11) i, cattr, cdate, ctime, jsize, trim(FILES(i))
END DO
write (*,*) n, ' files located for ', trim(pat)
11 format (i4, a8, a12, a9, i13, 2x, A)
contains
character*10 function date_string (dos_date)
! http://forums.silverfrost.com/viewtopic.php?t=210&highlight=compressed+date
character*10 string
integer*2 dos_date
integer date_day, date_month, date_year
date_day = ibits(dos_date, 0, 5)
date_month = ibits(dos_date, 5, 4)
date_year = ibits(dos_date, 9, 7) + 1980
write ( string,fmt="(i2,'/',i2.2,'/',i4)" ) date_day, date_month, date_year
date_string = string
end function date_string
character*8 function time_string (dos_time)
character*8 string
integer*2 dos_time
integer time_second, time_minute, time_hour
time_second = ibits(dos_time, 0, 5)*2
time_minute = ibits(dos_time, 5, 6)
time_hour = ibits(dos_time, 11, 5)
write ( string,fmt="(i2,':',i2.2,':',i2.2)" ) time_hour, time_minute, time_second
time_string = string
end function time_string
character*6 function attr_string ( dos_attr )
use msw32prm
! http://forums.silverfrost.com/viewtopic.php?t=211&highlight=file+attributes
character*6 string
integer*2 dos_attr
string = ' '
if (iand(dos_attr, FILE_ATTRIBUTE_DIRECTORY) > 0) string = trim(string) // 'D' ! " directory" 16
if (iand(dos_attr, FILE_ATTRIBUTE_HIDDEN) > 0) string = trim(string) // 'H' ! " hidden" 2
if (iand(dos_attr, FILE_ATTRIBUTE_NORMAL) > 0) string = trim(string) // 'N' ! " normal" 128
if (iand(dos_attr, FILE_ATTRIBUTE_READONLY) > 0) string = trim(string) // 'R' ! " read only" 1
if (iand(dos_attr, FILE_ATTRIBUTE_ARCHIVE) > 0) string = trim(string) // 'A' ! " archive" 32
if (iand(dos_attr, FILE_ATTRIBUTE_SYSTEM) > 0) string = trim(string) // 'S' ! " system" 4
if (iand(dos_attr, FILE_ATTRIBUTE_TEMPORARY) > 0) string = trim(string) // 'T' ! " temporary" 256
attr_string = string
end function attr_string
END PROGRAM DIRENT_test |
|
|
Back to top |
|
|
JohnCampbell
Joined: 16 Feb 2006 Posts: 2580 Location: Sydney
|
Posted: Sat Jul 22, 2023 8:20 am Post subject: |
|
|
FILES8@ is very useful but a bit quirky, as it supports up to nmax = 2^31-1 files. (Presumably DOS file system is the same)
I have used character (len=256) files(nmax), although larger might be supported, check DOS FILE name limit ?
Not sure why FILES8@ is real*8 size ?
Once you get the hang of pat options, you can scan the whole disk, subject to Windows security restrictions. If a file has a directory attribute, you can then recursively search that tree and off you go.
I use it to search a disk and list all files, eg modified since a certain date.
Note time is given in UTC, which can be difficult to update to local time, especially if the file date/time is near midnight on 1-Jan or worse midnight on 1-Mar |
|
Back to top |
|
|
LitusSaxonicum
Joined: 23 Aug 2005 Posts: 2393 Location: Yateley, Hants, UK
|
Posted: Sun Jul 23, 2023 11:18 am Post subject: |
|
|
Wouldn't it be a great idea if someone went through the documentation for the old FTN77 libraries, identifying which routines still work, which ones don't work, and which ones have been superceded?
Eddie |
|
Back to top |
|
|
PaulLaidler Site Admin
Joined: 21 Feb 2005 Posts: 8011 Location: Salford, UK
|
Posted: Mon Jul 24, 2023 7:20 am Post subject: |
|
|
Eddie
I think that DIRENT is exceptional. It is in the export table for salflibc.dll so it was assumed that it had been ported to FTN95 and therefore included in the documentation. It was never implement because FILES@ (or FILES8@) is better.
The documentation is intended to include all relevant routines. Possible exceptions are routines like RS (right shift) that ought to be replaced by Standard Fortran 90 routines and low level routines like LOC and CORE4. |
|
Back to top |
|
|
LitusSaxonicum
Joined: 23 Aug 2005 Posts: 2393 Location: Yateley, Hants, UK
|
Posted: Mon Jul 24, 2023 9:21 am Post subject: |
|
|
Hi Paul,
Well, that is (or are) maybe the ones that don't work. What I also suspect is that there are many useful routines in the support for FTN77. Not everyone knows about FTN77, or even that its documentation is online.
Eddie |
|
Back to top |
|
|
patrickm
Joined: 21 Jul 2023 Posts: 3
|
Posted: Mon Jul 24, 2023 5:33 pm Post subject: |
|
|
Thank you for the suggestions. I have rewritten my program, different from the manual example, to use FILES@, and everything is working now.
Patrick |
|
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
|