Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

DoublePrompt alternative to ExitPrompt

5 views
Skip to first unread message

John Savage

unread,
Dec 4, 2001, 7:04:37 PM12/4/01
to
"William Allen" <ma...@mayfly13.fsnet.co.uk> writes:
>Benny Pedersen (often posts stuff in alt.msdos.batch and
>his posts are always worth reading) discovered a very
>elegant and simple way of echoing a Custom Prompt
>message. It's called the ExitPrompt technique (documented
>in Note 1). It's ideal for logging these sorts of messages:
>
>This one-liner in your script at the appropriate point:
>
>ECHO.EXIT|%COMSPEC%/k PROMPT Page fault (reloading) $d $t$_|find " "
>
>will display a message like:
>Page fault (reloading) Wed 28/11/2001 14:49:01.11

Thanks for posting that, William. I had missed its origin. Because it
uses a Win95+ switch, unavailable on early DOS, I hadn't paid it much
attention. Though it has been at the back of my mind to try for a
one-line alternative with fewer restrictions on it, and your above
post prompted me (NPI) to look further.

I've come up with a PromptRem alternative:

command/c for %%i in (prompt ::) do %%i Stardate=$t on $d$_|find "-" >tmp1

It eliminates that input pipe, at the expense of extra text. Tried this
only on DOS 7, but is anticipated to work on all versions. There is no
contamination of the console's command history buffer here, either.

In practice, it's probably easier to remember DoublePrompt:
command/c for %%i in (1 2) do prompt Stardate$q$t on $d$_|find ".">tmp1
--
John Savage (for email, replace "ks" with "k" and delete "n")

Benny Pedersen

unread,
Dec 4, 2001, 8:34:34 PM12/4/01
to

"John Savage" <rook...@suburbian.com.au> wrote news:011205000110507.05Dec01$rook...@suburbian.com...

Hi,

I don't know if my older discovery is better than
my later one, i.e. the ExitPromt syntax.

My english is not better than my Danish, so, I havn't got
any grasp about that doskey history.

Both switches C and K is old documentation for DOS 6, so
I don't understand what you are saying about the Win9x
switches either?

The one thing I know is that my old discovery:

@%comspec%/c For %%v in (1 2) do Prompt Current drive is $
n$_|Find/v "_"

is much documented, on minimum 4 different locations at my Homepage:

http://2dos.homepage.dk/batutil/help/how/VARIOUS.HTM
http://2dos.homepage.dk/batutil/help/PROMPT_E.HTM
http://2dos.homepage.dk/batutil/help/BATCHSUP.HTM

and in this News Group.

%comspec%/c For %%v in (1 2) do Prompt If %%9'==' %%0 $d 3 4 5
6 7 8 9$_Date %%2$_|Find/v "$">~Date.bat

Tom L. repudiatiod/rejection?? it long time ago. (something
about that the Prompt got a value) but I didn't saw that as
a problem (I used the Win95 OSR2 version along with mouse
execution of my batch files running in small DOS windows).

I guess that the above answer by Tom caused all readers
to think that I was an idiot and I loosed the credit :-(

I know that it is hard to contribute with something new and
I guess that people often uses old learning as GOTO and
CHOICE and so... but some of us, I think including your self,
found that the batch is an interesting hobby :-)

Benny Pedersen,
btw. John, do you never read my post because it's bad English?
?

Outsider

unread,
Dec 5, 2001, 2:36:19 AM12/5/01
to
Benny Pedersen wrote:
>
...snipped

> The one thing I know is that my old discovery:
>
> @%comspec%/c For %%v in (1 2) do Prompt Current drive is $
> n$_|Find/v "_"
>
> is much documented, on minimum 4 different locations at my Homepage:
>
> http://2dos.homepage.dk/batutil/help/how/VARIOUS.HTM
> http://2dos.homepage.dk/batutil/help/PROMPT_E.HTM
> http://2dos.homepage.dk/batutil/help/BATCHSUP.HTM


I don't know how many people have independently discovered this technique,
but it has been documented by Dirk van Deun on June 7,1996 and also earlier;
that was the article's last revision date.

http://dirk.rave.org/batcoll.all
http://student.vub.ac.be/~dvandeun/batcoll.all

--------------------------from a usenet article---------------------------

Someone said that this first part of your problem can't be done. Well
it's not too easy, but it can be done. The fastest way I have found to
create a string containing characters that are normally unprintable, such
as the '>' or escape characters, is to use the COMMAND FOR, and PROMPT
statements together. For example, the following sequence outputs X > 1 to
the screen by using the dollar sign equivalent of the greater than sign in
the PROMPT.

COMMAND/E:1999/CFOR %%v IN (1 2) DO PROMPT X $G 1$_ | FIND "$"/V

....more

---------------------------------------------------------------------------

--
<!-Outsider//->
MS-DOS 6.22, Windows for Workgroups 3.11, Netscape Communicator 4.08

William Allen

unread,
Dec 5, 2001, 3:14:38 AM12/5/01
to
"John Savage" wrote in message
...snip

> I had missed its origin. Because it
> uses a Win95+ switch, unavailable on early DOS, I hadn't paid it much
> attention.

The COMMAND.COM /K switch was added to MS-DOS from
version 6.0 (Reference: "Running MS-DOS" Van Wolverton, p445)

...snip


> I've come up with a PromptRem alternative:
>
> command/c for %%i in (prompt ::) do %%i Stardate=$t on $d$_|find "-" >tmp1
>

...snip


> Tried this
> only on DOS 7, but is anticipated to work on all versions. There is no
> contamination of the console's command history buffer here, either.

Fails prior to MS-DOS 2.0 (no FIND). Fails if date separator is not [-]
character. Produces doubled message lines in MS-DOS 3.2 when
date separator _is_ the [-] character:

============Screen capture from MS-DOS 3.2
C:\>type a:\forprmpt.bat
ver
command /e:2048 /c for %%i in (prompt ::) do %%i Stardate=$t on $d$_|find "-"

C:\>a:\forprmpt

C:\>ver

MS-DOS Version 3.20

C:\>command /e:2048 /c for %i in (prompt ::) do %i Stardate=$t on $d$_|find "-"
Stardate= 8:09:32.67 on Wed 5-12-2001
Stardate= 8:09:32.67 on Wed 5-12-2001

C:\>
C:\>
============End screen capture

Furthermore, a more suitable workaround filter character based on $Q
(translated to [=] in the required line) for the ForPrompt method of echoing
Prompt messages was posted by the team here to alt.msdos.batch on:
Sat, 27 Oct 2001 13:05:10 as:

:: Finding an excuse to use [=] in a date/time stamp:
%COMSPEC%/cFOR %%L IN (1 2) DO PROMPT Date+time$q$t $d [comment]$_|find "="

--
(pp) William Allen


Mike Jones

unread,
Dec 5, 2001, 4:26:41 AM12/5/01
to

"John Savage" <rook...@suburbian.com.au> wrote in message
news:011205000110507.05Dec01$rook...@suburbian.com...
[]

> I've come up with a PromptRem alternative:
>
> command/c for %%i in (prompt ::) do %%i Stardate=$t on $d$_|find "-"
>tmp1
>
> It eliminates that input pipe, at the expense of extra text. Tried
this
> only on DOS 7, but is anticipated to work on all versions. There is no
> contamination of the console's command history buffer here, either.
>
> In practice, it's probably easier to remember DoublePrompt:
> command/c for %%i in (1 2) do prompt Stardate$q$t on $d$_|find
".">tmp1

for guaranteed internaitonalism (but longer)

command/c for %%i in (1 2) do prompt Stardate$q$t on $d$_|find /V
"pr">tmp1


John Savage

unread,
Dec 12, 2001, 5:25:18 PM12/12/01
to
"Benny Pedersen" <b.ped...@get2net.dk> writes:
>"John Savage" <rook...@suburbian.com.au> wrote news:011205000110507.05Dec01$rook...@suburbian.com...
>> I've come up with a PromptRem alternative:
>> In practice, it's probably easier to remember DoublePrompt:
>> command/c for %%i in (1 2) do prompt Stardate$q$t on $d$_|find ".">tmp1

Ack. So I actually took a step backwards? Looks like I just haven't
been paying attention. Anyway, the method deserves another run, to
remind those who can't use ExitPrompt that most of the cases can be
converted into a DoublePromt line that is compatible with earlier
DOS versions.

>My english is not better than my Danish, so, I havn't got
>any grasp about that doskey history.

The use of Up-Arrow to recall the last command.

>Both switches C and K is old documentation for DOS 6, so
>I don't understand what you are saying about the Win9x
>switches either?

Were this a Windoze newsgroup, then I would consider DOS 6.2 and its
Windoze 3.1 to be the 'early' version. But this is a DOS newsgroup,
and the history of DOS goes back a lot farther. I view DOS 3.3 and
DOS 5 to be the 'early' versions still in use for which compatible
batch programs are practiceable, with the versions in Windoze 95 and
98 to be the 'recent' versions. This is not an arbitrary division,
but rather one imposed by the introduction in version 6 of CHOICE and
ERRORLEVEL's in FIND. These improvements, meagre as they may now seem,
made for some major changes in the capabilities of pure batch
programming, more so than any other. (I found that the CHOICE binary
from DOS 6.22 worked just fine in DOS 5. I asked here whether the
same applied to the FIND executable, but no one responded.)

> %comspec%/c For %%v in (1 2) do Prompt If %%9'==' %%0 $d 3 4 5
>6 7 8 9$_Date %%2$_|Find/v "$">~Date.bat
>
>Tom L. repudiatiod/rejection?? it long time ago. (something
>about that the Prompt got a value) but I didn't saw that as
>a problem (I used the Win95 OSR2 version along with mouse
>execution of my batch files running in small DOS windows).

I can't fault it when run in DOS anyway.

>btw. John, do you never read my post because it's bad English?

You are doing just fine. Keep it up.

Charles Dye

unread,
Dec 14, 2001, 6:40:04 PM12/14/01
to
John Savage <rook...@suburbian.com.au> wrote in message news:<011213000092554.13Dec01$rook...@suburbian.com>...

> 98 to be the 'recent' versions. This is not an arbitrary division,
> but rather one imposed by the introduction in version 6 of CHOICE and
> ERRORLEVEL's in FIND. These improvements, meagre as they may now seem,
> made for some major changes in the capabilities of pure batch
> programming, more so than any other. (I found that the CHOICE binary
> from DOS 6.22 worked just fine in DOS 5. I asked here whether the
> same applied to the FIND executable, but no one responded.)

FIND.EXE wants one specific DOS version. But it does its version
check using 21/30, which means that you can fool it using SETVER.
Alternatively, it's trivial to patch the executable so that the
version check is more reasonable -- permit operation under DOS 5
and later, for instance.

--
Charles Dye ras...@highfiber.com

0 new messages