Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.sys.acorn.programmer > #600

Re: A one-liner to save (any)file with the date as filename

From Jeremy Nicoll - news posts <jn.nntp.scrap007@wingsandbeaks.org.uk>
Newsgroups comp.sys.acorn.programmer
Subject Re: A one-liner to save (any)file with the date as filename
Date 2011-08-13 02:51 +0100
Message-ID <mpro.lpuftg007kdes02qk@wingsandbeaks.org.uk.invalid> (permalink)
References <d2b97e0152.rogerarm@rogerarm.freeuk.com> <3b5bfae8-59cc-4846-b711-272a435e45f9@q1g2000vbj.googlegroups.com>

Show all headers | View raw


jgharston <jgh@arcade.demon.co.uk> wrote:

> Roger Darlington wrote:
> > I want a simple one-liner to insert in the run-file of FTPc that will
> > save a file (any file, one of zero length) that has the date and time
> > as the filename of that file.
> 
> I've always found the LEFT/MID/RIGHT functions of *Set hard to work
> out, so I tend to use something like this:
> 
> REM > GetTime
> A$=TIME$
> A$=MID$(A$,12,4)+MID$(A$,8,3)+MID$(A$,6,2)+MID$(A$,17,2)+MID$(A$,
> 20,2)+MID$(A$,23,2)
> OSCLI "Set Sys$TimeName "+A$
> OSCLI "Set Sys$DateName "+LEFT$(A$,9)
> 
> then in an Obey file use something like:
> 
> /<path>GetTime
> Create <path><Sys$TimeName> 0

If you follow that with 

  SetType <path><Sys$TimeName> &123

or similar, picking a hexadecimal filetype number that isn't in use within
the <path> concerned for any other file, then the newly created file will be
given that specific filetype, and will then be the only file with that
filetype inside that folder.

This makes it easy to get rid of the file created on a previous run before
creating a new one.  You do it by: 

  Repeat Delete <path> -Type &123

- that is, by asking RO to perform the 'Delete' command against every file
it finds in <path> which has the filetype &123.




An alternative method could be something like the following, which creates a
file called  LastUsed within the app's directory.  The file is created as an
Obey file (so can later be clicked to run it if you think that's worthwhile)
and contains a command that will then tell you the relevant date and time. 
Add the following lines to the app (FTPc)'s !Run file:

Remove <Obey$Dir>.LastUsed
Create <Obey$Dir>.LastUsed
SetType <Obey$Dir>.LastUsed Obey

Echo ERROR This app was last used at <Sys$Time> on <Sys$Date><Sys$Year> { >
<Obey$Dir>.LastUsed } 

(The last line has probably wrapped, but is one line.  Note that the spaces
around the opening & closing curly bracket are required.)

What these commands do is:

a) remove any previously-created LastUsed file from the directory
b) Create a new empty LastUsed file
c) Change that file's filetype to Obey

The next line is more complicated.  Normally 

  Echo this that other

writes the text 'this that other' to the screen (or task window).  Changing
it to 

  Echo this that other { > somefile }

redirects the output so instead of it going to the screen it ends up in the
specified file.  So the command above writes:

 ERROR This app was last used at <Sys$Time> on <Sys$Date><Sys$Year>

into the LastUsed Obey file.  The values at that instant of <Sys$Time> etc
are used so the actual line in the Obey file will say something like

 ERROR This app was last used at 01:23:45 on ... 

When the Obey file is run that line is treated as a command, and what it
does is display a RO error box with that message in it.

-- 
Jeremy C B Nicoll - my opinions are my own.

Email sent to my from-address will be deleted. Instead, please reply
to newsreplyaaa@wingsandbeaks.org.uk replacing "aaa" by "284".  

Back to comp.sys.acorn.programmer | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

A one-liner to save (any)file with the date as filename Roger Darlington <rogerarm@freeuk.com> - 2011-08-12 08:46 +0100
  Re: A one-liner to save (any)file with the date as filename "John Williams (News)" <UCEbin@tiscali.co.uk> - 2011-08-12 10:31 +0200
    Re: A one-liner to save (any)file with the date as filename "John Williams (News)" <UCEbin@tiscali.co.uk> - 2011-08-12 10:38 +0200
  Re: A one-liner to save (any)file with the date as filename jgharston <jgh@arcade.demon.co.uk> - 2011-08-12 04:22 -0700
    Re: A one-liner to save (any)file with the date as filename Jeremy Nicoll - news posts <jn.nntp.scrap007@wingsandbeaks.org.uk> - 2011-08-13 02:51 +0100
  Re: A one-liner to save (any)file with the date as filename Martin Bazley <martin.bazley@blueyonder.co.uk> - 2011-08-12 15:02 +0100
    Re: A one-liner to save (any)file with the date as filename Rick Murray <heyrickmail-usenet@yahoo.co.uk> - 2011-08-13 01:03 +0200
  Re: A one-liner to save (any)file with the date as filename druck <news@druck.org.uk> - 2011-08-13 15:06 +0100
  Re: A one-liner to save (any)file with the date as filename Roger Darlington <rogerarm@freeuk.com> - 2011-08-16 08:23 +0100

csiph-web