Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.sys.acorn.programmer > #295 > unrolled thread
| Started by | Roger Darlington <rogerarm@freeuk.com> |
|---|---|
| First post | 2011-05-13 10:55 +0100 |
| Last post | 2011-05-19 21:14 +0100 |
| Articles | 9 — 6 participants |
Back to article view | Back to comp.sys.acorn.programmer
Reading Date Stamp of a file Roger Darlington <rogerarm@freeuk.com> - 2011-05-13 10:55 +0100
Re: Reading Date Stamp of a file Roger Darlington <rogerarm@freeuk.com> - 2011-05-13 11:20 +0100
Re: Reading Date Stamp of a file Rick Murray <heyrickmail-usenet@yahoo.co.uk> - 2011-05-14 03:10 +0200
Re: Reading Date Stamp of a file Graham Pickles <graham@durain.demon.co.uk> - 2011-05-13 11:39 +0100
Re: Reading Date Stamp of a file jgh@arcade.demon.co.uk (Jonathan Graham Harston) - 2011-05-14 00:35 +0100
Re: Reading Date Stamp of a file Roger Darlington <rogerarm@freeuk.com> - 2011-05-18 13:44 +0100
Re: Reading Date Stamp of a file Chris Johnson <chrisjohnson+news@spamcop.net> - 2011-05-18 15:23 +0100
Re: Reading Date Stamp of a file Roger Darlington <rogerarm@freeuk.com> - 2011-05-19 09:30 +0100
Re: Reading Date Stamp of a file druck <news@druck.org.uk> - 2011-05-19 21:14 +0100
| From | Roger Darlington <rogerarm@freeuk.com> |
|---|---|
| Date | 2011-05-13 10:55 +0100 |
| Subject | Reading Date Stamp of a file |
| Message-ID | <416aadd251.rogerarm@rogerarm.freeuk.com> |
In BBC BASIC/RISC OS there is always more than one command to perform any one function. Could the readers tell me which is the SIMPLEST command to use to read the date stamp of a file within a program, and in what format is the date stamp returned? I don't need the time stamp, just the date. (I realise I may get both date and time anyway). -- Cheers Roger Too lazy to turn over your CD?: Get a CD-re-winder.
[toc] | [next] | [standalone]
| From | Roger Darlington <rogerarm@freeuk.com> |
|---|---|
| Date | 2011-05-13 11:20 +0100 |
| Message-ID | <5ab1afd251.rogerarm@rogerarm.freeuk.com> |
| In reply to | #295 |
On 13 May 2011, Roger Darlington wrote: > In BBC BASIC/RISC OS there is always more than one command to perform > any one function. > Could the readers tell me which is the SIMPLEST command to use to read > the date stamp of a file within a program, and in what format is the > date stamp returned? I don't need the time stamp, just the date. (I > realise I may get both date and time anyway). Actually, thinking more about it, I need it to compare the date/time stamp of two files within the program, and if one is newer than the other, then I want to perform some actions (which don't involve copying). If there is a command that might return the date/time stamp as a single number (rather than as 17-Jan-2010) then I wont need to convert 17-Jan-2010 to some single number. -- Cheers Roger "An invisibility cloak that works at optical wavelengths is nowhere in sight"
[toc] | [prev] | [next] | [standalone]
| From | Rick Murray <heyrickmail-usenet@yahoo.co.uk> |
|---|---|
| Date | 2011-05-14 03:10 +0200 |
| Message-ID | <4dcdd66c$0$14671$ba4acef3@reader.news.orange.fr> |
| In reply to | #296 |
On 13/05/2011 12:20, Roger Darlington wrote:
> Actually, thinking more about it, I need it to compare the date/time
> stamp of two files within the program, and if one is newer than the
> other, then I want to perform some actions (which don't involve
> copying).
You will need to call OS_File 17.
On entry:
R0 is 17.
R1 is a string giving the filename (with path).
On exit:
R0 is the object type: 0-not found, 1-File, 2-Dir, 3-Image
R2 is the load address
R3 is the exec address
R4 is the length (if you need this)
R5 are the file attributes (RW/rw stuff, if you need this)
Load & exec are a hangover from the 6502 days. On a RISC OS system (at
least for the older versions, not sure if 4+ changes things), Load and
Exec are a 64 bit value split up as follows:
Load Exec
FFFtttdd dddddddd
Where FFF is &FFF (i.e. upper 12 bits are all set). "ttt" is the
filetype (0 to &FFF), and the rest ('ddd...') is the file's time stamp.
Note well that the value is a five byte value, so a simple word
comparison ( IF !blah% = !meh% THEN ...) won't work.
You could use OS_ConvertDateAndTime with a format string to convert the
date/time to something more manageable - for example
"%CE%YR%MN%DY%24%MI%SE" will return a value such as "20110514030754"
(2011/05/14, 03h07.54) which could be parsed into a number and compared.
As we're running in decreasing magnitude, a higher number is a later date...
> If there is a command that might return the date/time stamp as a
> single number (rather than as 17-Jan-2010) then I wont need to convert
> 17-Jan-2010 to some single number.
There is no simple command in BASIC, however the SYS command offers easy
access to a multitude of OS functions, which can do exactly what is
required.
Best wishes,
Rick.
[toc] | [prev] | [next] | [standalone]
| From | Graham Pickles <graham@durain.demon.co.uk> |
|---|---|
| Date | 2011-05-13 11:39 +0100 |
| Message-ID | <e07bb1d251.graham@durain.demon.co.uk> |
| In reply to | #295 |
In message <416aadd251.rogerarm@rogerarm.freeuk.com>
Roger Darlington <rogerarm@freeuk.com> wrote:
> In BBC BASIC/RISC OS there is always more than one command to perform
> any one function.
> Could the readers tell me which is the SIMPLEST command to use to read
> the date stamp of a file within a program, and in what format is the
> date stamp returned? I don't need the time stamp, just the date. (I
> realise I may get both date and time anyway).
How about
DIM stamp% 5,date% 32
REM next line is up to you...
filespec$="HostFS::HardDisc4.$.Folders"
SYS "XOS_File",17,filespec$ TO found%,,load%,exec%
stamp%!0=exec%:stamp%?4=load%
SYS "OS_ConvertStandardDateAndTime",stamp%,date%,32 TO date$
PRINT RIGHT$(date$,11)
Regards,
--
Graham Pickles
www.whitbymuseum.org.uk Whitby Museum
Those who get too big for their britches will be exposed in the end
[toc] | [prev] | [next] | [standalone]
| From | jgh@arcade.demon.co.uk (Jonathan Graham Harston) |
|---|---|
| Date | 2011-05-14 00:35 +0100 |
| Message-ID | <110514005501@arcade.demon.co.uk> |
| In reply to | #297 |
graham@durain.demon.co.uk wrote: > > Could the readers tell me which is the SIMPLEST command to use to read > > the date stamp of a file within a program, and in what format is the > > SYS "XOS_File",17,filespec$ TO found%,,load%,exec% > stamp%!0=exec%:stamp%?4=load% ...and the 5-byte number stamp%?0 to stamp%?4 /is/ the single number that can be used to compare with other datestamps. It is a centisecond count from 00:00:00-01-Jan-1900. -- J.G.Harston - jgh@mdfs.net - mdfs.net/jgh
[toc] | [prev] | [next] | [standalone]
| From | Roger Darlington <rogerarm@freeuk.com> |
|---|---|
| Date | 2011-05-18 13:44 +0100 |
| Message-ID | <d61650d551.rogerarm@rogerarm.freeuk.com> |
| In reply to | #297 |
On 13 May 2011, Graham Pickles wrote:
> In message <416aadd251.rogerarm@rogerarm.freeuk.com>
> Roger Darlington <rogerarm@freeuk.com> wrote:
>> In BBC BASIC/RISC OS there is always more than one command to perform
>> any one function.
>> Could the readers tell me which is the SIMPLEST command to use to read
>> the date stamp of a file within a program, and in what format is the
>> date stamp returned? I don't need the time stamp, just the date. (I
>> realise I may get both date and time anyway).
> How about
> DIM stamp% 5,date% 32
> REM next line is up to you...
> filespec$="HostFS::HardDisc4.$.Folders"
> SYS "XOS_File",17,filespec$ TO found%,,load%,exec%
> stamp%!0=exec%:stamp%?4=load%
Well, I have run with this one.
Here's the program I have:
FOR loop to get different files
load%=0 : exec%=0 : length%=0
filespec$="<Obey$Dir>" + "." + AZletter$ + "." + SubName$ + "." +
SubName$ + "/htm"
filespec$="HostFS::HardDisc4.$.~IYO4.Default.Sep03.!WildFlowers.Flowers"
+ "." + AZletter$ + "." + SubName$ + "." + SubName$ + "/htm"
PRINT filespec$
SYS"OS_File",17,filespec$ TO found%,,load%,exec%,length%
PRINT ~load%, ~exec%, length%'
NEXT
GIVES THE FOLLOWING PRINTOUT:
Note that I have deleted the XOS_File and used OS_File, so as to prove
it never errors.
HostFS::HardDisc4.$.~IYO4.Default.Sep03.!WildFlowers.Flowers.A.Aconite(Winter).A
conite(Winter)/htm
0 3834830 29368192
The load address is always '0', the exec address is always &3834830
and the size is always 29368192bytes.
for every file it comes across (BTW the files it comes across are only
of order 30kB in size, NOT 29MB!!)
--
Cheers
Roger
My friends think I'm surreal, but I've never been near a sword
[toc] | [prev] | [next] | [standalone]
| From | Chris Johnson <chrisjohnson+news@spamcop.net> |
|---|---|
| Date | 2011-05-18 15:23 +0100 |
| Message-ID | <51d5592e50chrisjohnson+news@spamcop.net> |
| In reply to | #306 |
In article <d61650d551.rogerarm@rogerarm.freeuk.com>, Roger Darlington <rogerarm@freeuk.com> wrote: > SYS"OS_File",17,filespec$ TO found%,,load%,exec%,length% > PRINT ~load%, ~exec%, length%' > NEXT You should check the value of found% - if it is 0, object was not found, 1 is a file, 2 is a dir, 3 is an image file. If found% = 0, then you need to check the contents of filespec$. The PRM states that the values of R2, R3, R4, R5 are corrupted if object not found (found% = 0). -- Chris Johnson
[toc] | [prev] | [next] | [standalone]
| From | Roger Darlington <rogerarm@freeuk.com> |
|---|---|
| Date | 2011-05-19 09:30 +0100 |
| Message-ID | <03a9bcd551.rogerarm@rogerarm.freeuk.com> |
| In reply to | #307 |
On 18 May 2011, Chris Johnson wrote: > In article <d61650d551.rogerarm@rogerarm.freeuk.com>, > Roger Darlington <rogerarm@freeuk.com> wrote: >> SYS"OS_File",17,filespec$ TO found%,,load%,exec%,length% >> PRINT ~load%, ~exec%, length%' >> NEXT > You should check the value of found% - if it is 0, object was not > found, 1 is a file, 2 is a dir, 3 is an image file. > If found% = 0, then you need to check the contents of filespec$. The > PRM states that the values of R2, R3, R4, R5 are corrupted if object > not found (found% = 0). Many thanks to all respondents, I have now got it going successfully :-) Actually, I can't help thinking that there might have been some clever way of hi-jacking the *Copy command to achieve the same end, by making it error, trapping the error, and doing my own thing rather than letting it copy 'newer', but that is just theoretical now. I have done it using one of the above respondents method. -- Cheers Roger All who wander are not lost
[toc] | [prev] | [next] | [standalone]
| From | druck <news@druck.org.uk> |
|---|---|
| Date | 2011-05-19 21:14 +0100 |
| Message-ID | <ir3to0$t25$2@dont-email.me> |
| In reply to | #312 |
On 19/05/2011 09:30, Roger Darlington wrote: > Actually, I can't help thinking that there might have been some clever > way of hi-jacking the *Copy command to achieve the same end, You don't touch *Copy programically, use the appropriate OS_FSControl reason code, which is what the command line tool calls. > by making > it error, trapping the error, and doing my own thing rather than > letting it copy 'newer', but that is just theoretical now. That's not so easy without nastiness. ---druck
[toc] | [prev] | [standalone]
Back to top | Article view | comp.sys.acorn.programmer
csiph-web