If so, what command would you use to save the file and end the COPY
CON session?
The keyboard command is <F6> but I don't think I know how to put that
into a batch file.
Is there a way to put function key commands or control key commands
into a batch file?
P.S. Should I avoid the use of angle brackets to denote keys on a
keyboard? If so, is there another convention that is preferable?
Yes.
> If so, what command would you use to save the file and end the COPY
> CON session?
The two keys [Ctrl-Z] then [Return]
> The keyboard command is <F6> but I don't think I know how to put that
> into a batch file.
>
> Is there a way to put function key commands or control key commands
> into a batch file?
Yes, I've already posted a way to do this. See post
From: "William Allen"
Newsgroups: alt.msdos.batch
Subject: Text input to a Batch file with ANSI.SYS
Date: Tue, 9 Oct 2001 08:09:49 +0100
Message-ID: <9pu7ug$kf6qg$1...@ID-55970.news.dfncis.de>
You can read old Usenet posts at:
http://groups.google.com/advanced_group_search
Note: Google search by Message-ID is usually the quickest.
The Message-ID is the identifier in the <angle> brackets.
Simply cut-and-paste the Message-ID into Google page above.
The batch file concerned was:
====Begin cut-and-paste (omit this line)
@ECHO OFF
:: This script needs the standard ANSI.SYS driver loaded
:: Make an escape character in environment variable E
ECHO.EXIT|%COMSPEC%/e:4096/k PROMPT SET E=$E$_:>%TEMP%.\E.BAT
FOR %%C IN (CALL DEL) DO %%C %TEMP%.\E.BAT
:: Reassign [Return] key to [Return][Ctrl-Z][Return]
ECHO.%E%[13;13;26;13p%E%[1A
ECHO. Type a line of text and press [Return]:
:: This line accepts the input to INPUT.TXT
COPY CON INPUT.TXT>NUL
:: Remove [Ctrl-Z] screen echo and reset [Return] key to normal
ECHO.%E%[1A %E%[13;13p
:: Clear the ESC variable
SET E=
ECHO. The INPUT.TXT file now reads:
ECHO.
TYPE INPUT.TXT
ECHO.
DEL INPUT.TXT
====End cut-and-paste (omit this line)
To use the code above, cut-and-paste the text between the ==== lines
into a file with extension .BAT and base name of your choice. Lines
that don't begin with two spaces have wrapped in transmission. The
code was created and tested in Win9x GUI.
> P.S. Should I avoid the use of angle brackets to denote keys on a
> keyboard? If so, is there another convention that is preferable?
You can do what you please. Here, when we want to be precise,
we often use [brackets] to denote key combos. In particular, we
often use this notation:
1) Press [Ctrl] and hold it down while you press [P], release [P] still
holding [Ctrl] down while you then press [C], and then release both =
[Ctrl+[P][C]]
2) Press [Ctrl] and hold while you press [P], release both
then press [Ctrl] and hold while you press [C], then release
both =
[Ctrl+[P]] [Ctrl+[C]]
3) Press [Ctrl] and hold while you press [P], release both
then press [C] on its own =
[Ctrl+[P]] [C]
Other keypress combos (including triple-bucky ones) become:
a) Ctrl-Esc = [Ctrl+[Esc]]
b) Ctrl-Alt-N = [Ctrl+[Alt+[N]]]
c) Ctrl-Alt-Del = [Ctrl+[Alt+[Del]]]
However, these are standards that I and my partner use here.
You can do as you please, and use any terms you please.
--
William Allen
>
>Would it be possible to create a batch file that creates a text file
>using COPY CON?
Yes.
>
>If so, what command would you use to save the file and end the COPY
>CON session?
You answered your own question.
>
>The keyboard command is <F6> but I don't think I know how to put that
>into a batch file.
>
>Is there a way to put function key commands or control key commands
>into a batch file?
>
>P.S. Should I avoid the use of angle brackets to denote keys on a
>keyboard? If so, is there another convention that is preferable?
While you are typing the file's contents, the batch program is
suspended - in any case, there is no way the program could know you
where through typing unless you told it you were by entering the EOF
marker (F6 or Ctrl + Z). The marker to end copying has to come from
the source of the content - that's a necessary characteristic of
copying: either the contents must contain a marker, or the copy
function must find out the length of the source (the latter applies
only to existing files).
T.E.D. (tda...@gearbox.maem.umr.edu - e-mail must contain "batch" in the subject or my .sig in the body)
You mean totally automated? In other words, do you want the text that
will be in the resulting textfile to be contained in the batch file
itself (rather than actually entered by a person at a keyboard) ?
- Larry Weiss
Larry__Weiss wrote:
> You mean totally automated? In other words, do you want the text that
> will be in the resulting textfile to be contained in the batch file
> itself (rather than actually entered by a person at a keyboard) ?
Yup!
On the face of it, that's a pretty weird thing to want to do since
it's so much easier to create the same file with ECHO commands - if it
*could* be done, you'd probably have to use the echo commands anyway.
You can't use COPY CON in a batch script to populate a file's contents from
text within that batch script.
- Larry Weiss
You could use sed to do something like this. It would be neater
than a bunch of ECHO commands, and would avoid problems with any
syntactically significant characters embedded in the text.
Probably the trickiest part would just be getting the true name
of the batch file itself; the value returned in %0 frequently
lacks such minor details as the pathname of the batch and its
extension.
--
Charles Dye ras...@highfiber.com
This problem is only "hard" in legacy DOS pre-Windows 95/95/ME.
In the GUI, it's not a problem at all, since START will automatically
return the full short-form alias name of your script. This demo
places suitable START code into a Batch subroutine.
====Begin cut-and-paste (omit this line)
@ECHO OFF
IF (GOTO:)==(%1) %1%2 (Subroutine handler)
:: Demo lines
CALL %0 GOTO: _MYNAME
ECHO. Full short-form alias path+scriptname is: %NAME%
SET NAME=
GOTO EOF (=Subroutine code follows=)
:_MYNAME
start /m /w %0 GOTO: 1_MYNAME
FOR %%C IN (CALL DEL) DO %%C %TEMP%.\N.BAT
GOTO EOF
:1_MYNAME
ECHO.SET NAME=%0>%TEMP%.\N.BAT
:EOF (End-of-file)
====End cut-and-paste (omit this line)
To use the code above, cut-and-paste the text between the ==== lines
into a file with extension .BAT and base name of your choice. Lines
that don't begin with two spaces have wrapped in transmission. The
Batch code above was written and tested in the Win9x GUI.
--
William Allen
Suppose one is running DOS 7.x and the GUI is not running?
--
<!-Outsider//->
MS-DOS 6.22, Windows for Workgroups 3.11, Netscape Communicator 4.08
Possibility is an attitude. Impossibility is an opinion.