HP3000-L Archives

May 2002, Week 3

HP3000-L@RAVEN.UTC.EDU

Options: Use Monospaced Font
Show Text Part by Default
Show All Mail Headers

Message: [<< First] [< Prev] [Next >] [Last >>]
Topic: [<< First] [< Prev] [Next >] [Last >>]
Author: [<< First] [< Prev] [Next >] [Last >>]

Print Reply
Subject:
From:
Tom Emerson <[log in to unmask]>
Reply To:
Tom Emerson <[log in to unmask]>
Date:
Tue, 21 May 2002 09:18:47 -0700
Content-Type:
text/plain
Parts/Attachments:
text/plain (46 lines)
> -----Original Message-----
> From: Robert Mills
>
> As you can see from the following this does nothing on my machine.
>
> C:\WINDOWS\TEMP>set yyy=%DATE%
>
> C:\WINDOWS\TEMP>set
> TMP=C:\WINDOWS\TEMP
[...] (var 'yyy' not listed at all...)
>
That may be an NT/w2k extension to DOS -- under win98 this doesn't appear to
work.  However, a google search for "dos help" directed me to this page:
http://www.computerhope.com/batch.htm

and from and example on that page:

   echo @prompt set date=$d$_set time=$t$h$h$h > {a}.bat
   %comspec% /e:2048 /c {a}.bat > {b}.bat
   for %%v in ({b}.bat del) do call %%v {?}.bat
   echo %date% %time% >> log

This works by creating a batch file that sets the "prompt" to the command
"set date=...", wherein special substitutions are active ($D$ becomes the
date...).  This newly created command file is executed in a "sub shell" with
the output directed to another batch file.  Since the only "command" in the
first batch file is to set the prompt, only the "prompt" appears in the
batch file, and THIS batch file has a SPECIFIC value for the date & time.
Finally, the second batch file is called in such a way that it executes the
"prompt" and FINALLY sets the 'date' variable (which can now be dereferenced
as any other variable...)

[aside: note that the initial 'prompt set date=...' string sets two
variables -- 'date' gets the result of $d, the $_ causes a new line to be
emitted, and 'time' gets set to the result of $t WITH three backspaces ($h).
If you ommit the three $h's, you get times in the format hh:mm:ss.xx, or
down to the hundredth of a second...]

the above commands also do some automated cleanup of the two batch files.
The webpage also notes the file "log" must pre-exist for this [particular]
usage to work  (if you don't want or need to 'log' the values of these
variables in a file, you can ignore the last line...)

* To join/leave the list, search archives, change list settings, *
* etc., please visit http://raven.utc.edu/archives/hp3000-l.html *

ATOM RSS1 RSS2