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

Another beginner's question

4 views
Skip to first unread message

Gerard

unread,
Mar 4, 2010, 2:32:15 AM3/4/10
to
Hi,

when I startup my computer a dos-sreen appears with a menu.txt which runs as
follows:

U kunt kiezen uit de volgende toepassingen:

A. Scor4
B. Word
C. CSW
D. Outlook
E. Firefox
Druk de lettertoets van uw keuze en druk op enter (Tr: Press the key of your
choice and then do Enter")

Now what I would like is, that, after pressing d, for instance, I can choose
another key without leaving outlook (in this case). But the dosscreen does
not give the possiblitiy for an input. The cursos hovers somewhere under the
prompt. When I close outlook I can press a key again.
What to do in order to be able to choose a key, and, before leaving the
application in question, to choose another one?
(I hope I made myself clear..)

Regards,
Gerard


billious

unread,
Mar 4, 2010, 2:48:13 AM3/4/10
to

"Gerard" <gmb...@xs4all.nl> wrote in message
news:4b8f6203$0$22938$e4fe...@news.xs4all.nl...

Instead of executing say, scor4 you should START the executable

START "windowtitle" executablename executableparameters

(so much easier if you were to supply at least a representative sample of
your batch)

for instance, you may have

if /i "%response:~0,1%"=="A" scor4

change this to

if /i "%response:~0,1%"=="A" CALL "sometext" scor4

billious

unread,
Mar 4, 2010, 3:20:43 AM3/4/10
to

"billious" <billio...@hotmail.com> wrote in message
news:WcadnVJ7Vspd-BLW...@westnet.com.au...

Make that

if /i "%response:~0,1%"=="A" START "sometext" scor4


Gerard

unread,
Mar 4, 2010, 7:29:37 AM3/4/10
to

"billious" <billio...@hotmail.com> schreef in bericht
news:WcadnVJ7Vspd-BLW...@westnet.com.au...

Maybe it is indeed more practical when I add the script I use for loading
applications.
Let me quote what I have for "D", outlook express: (d.bat)
@echo off
if not %1#==# goto hulp
cd\
cd "c:\program files\outlook express"
msimn.exe
cd c:\bach
cls
type menu.txt
start cmd /k

:HULP
echo %0 roept de internetbrowser op en brengt u daarna weer terug naar het
menu

The question is: how to change this script in order for the menu.bat, while
outlook is still on the screen, to funtion properly, so that other
applacations of the menu-list can be chosen.

What you mentioned in your mail: if /i "%response:~0,1%"=="A" CALL
"sometext" scor4

is no stuff for a beginner, I am afraid; however, I would very much like to
hear an explanation of the script:).

Thanks in advance for your help!

Regards,
Gerard


foxidrive

unread,
Mar 4, 2010, 9:00:44 AM3/4/10
to
On Thu, 4 Mar 2010 13:29:37 +0100, "Gerard" <gmb...@xs4all.nl> wrote:

>@echo off
>if not %1#==# goto hulp
>cd\
>cd "c:\program files\outlook express"
>msimn.exe
>cd c:\bach
>cls
>type menu.txt
>start cmd /k


This can be streamlined.

If you create c:\bach\menu.bat like this

@echo off
c:
cd "\bach"
start "" cmd /k type menu.txt
exit

then (in the case of Windows multi-threaded programs) there is no need to
change the working directory or drive, so you can use this single start
command, followed by the batch file path\name.

@echo off
if not %1#==# goto hulp

start "" "c:\program files\outlook express\msimn.exe"
c:\bach\menu.bat


You can end each menu selection batch file with c:\batch\menu.bat
Note that you do not need to use CALL c:\batch\menu.bat because it is
transferring control to c:\batch\menu.bat

Also the "" after the START keyword is required in W2K/XP/Vista etc if
there is another quoted path\filename or parameter following it.


--
Regards,
Mic

billious

unread,
Mar 4, 2010, 11:40:59 AM3/4/10
to

"Gerard" <gmb...@xs4all.nl> wrote in message
news:4b8fa7b5$0$22937$e4fe...@news.xs4all.nl...
Still haven't quite got a handle on your menu-handling method, and only
assuming you are using NT+ rather than 98/me because you are requiring ENTER
to be pushed after the letter-choice.

@echo off
:: label MENU - for looping
:menu
:: clear the screen
cls
:: display the menu
type menu.txt
:: force deletion of variable "response"
(set response=)
:: get a response from the user
set /p response=Druk de lettertoets van uw keuze en druk op enter
:: Just ask again if the user didn't respond
if not defined response goto menu
:: Go through the choices
if /i "%response:~0,1%"=="A" START "sometext" scor4
if /i "%response:~0,1%"=="B" START "sometext" word
:: .... and so on with other choices
:: Allow choice of "X" to exit from the menu-system
if /i "%response:~0,1%"=="X" exit
:: finally, loop back again
goto menu

should work

Note that "::" is a commonly-user replacement for REM - remarks

(set var=)
makes the SET command less vulnerable to stray spaces at the end of a line.
Some editors remove those spaces, some retain them. If there ARE spaces at
the end of lines, then
(set var=)
will set the enviroment variable 'var' to "undefined" whereas
set var=
will set the enviroment variable 'var' to have a value of the terminal
spaces on the line. This leads to hard-to-debug faults since the spaces are
not particularly visible.

if /i "%response:~0,1%"=="A" START "sometext" scor4

means

IF
/i -> case-insensitive
"..."=="..." - by quoting, the string is made insensitive to NULL contents
and spaces. It's a more robust version of your 'if not %1#==#' where the "#"
has been added in case %1 is null or a space
%response:~0,1% -> The substring of RESPONSE, starting at "character 0
(characters are numbered C-style - the first character in the string is
'character number 0)" and length 1 character. In this case, this results in
the first character of the string

START is the command to be run. START creates a new process - see the
documentation. The quoted-string as the first parameter becomes the
window-title for the new process. In theory, it's optional but best for a
beginner to always specify it - even if you make it a null-string. After the
new process is started, the batch will continue to the next line (see the
START documentation for how to change this...)


*** Note that from the prompt,
START /?
IF /?
etc. will produce documentation.

SET /?

will show information on the substringing facilities.


It would also be possible to use

...
:: Go through the choices
SET response=%response:~0,1%
if /i "%response%"=="A" START "sometext" scor4
if /i "%response%"=="B" START "sometext" word
:: .... and so on with other choices

which might be easier to maintain.

and for your purposes, perhaps

if /i "%response%"=="D" CALL d.bat

might work better for you - where you've already written D.BAT (note here
you are CALLing d.bat rather than STARTing it)

But modify D.bat as follows:

@echo off


cd\
cd "c:\program files\outlook express"

START "OUTLOOK EXPRESS" msimn.exe
cd c:\bach

** Note the START command and window-title; after MSIMN.EXE is started, its
window remains open while the batch restores the current directory to
C:\bach for the BATCH window and then the CALLed batchfile D.bat terminates;
the processing then returns to your main MENU batchfile because D.BAT was
CALLed from that MENU.BAT file.


Gerard

unread,
Mar 4, 2010, 12:17:17 PM3/4/10
to

"foxidrive" <got...@woohoo.invalid> schreef in bericht
news:afevo5tb7nq1ofijn...@4ax.com...

Thank you very much!!!!!

Just one thing:

in my menu.text there is a possibility to choose a prompt with goes to a
directory called "VK".

I have made this script:

@echo off
if not %1#==# goto HULP
for %%a in (cls prompt) do %%a $p$g
cd c:\vk
uit
:HULP
echo %0 brengt u van en uit het menu naar dos

That seems a bit complicated to me.
Do you have an alternative?
I know that something like

"cd:\vk
start cmd /k"

not works, but I don't see clearly the reason for that. Could you give an
explanation?

Many thanks!

Gerard


foxidrive

unread,
Mar 4, 2010, 12:49:09 PM3/4/10
to
On Thu, 4 Mar 2010 18:17:17 +0100, "Gerard" <gmb...@xs4all.nl> wrote:

>Just one thing:
>
>in my menu.text there is a possibility to choose a prompt with goes to a
>directory called "VK".
>
>I have made this script:
>
>@echo off
>if not %1#==# goto HULP
>for %%a in (cls prompt) do %%a $p$g
>cd c:\vk
>uit
>:HULP
>echo %0 brengt u van en uit het menu naar dos
>
>That seems a bit complicated to me.
>Do you have an alternative?

It is normal for the prompt to already be set so I omitted that.
This is not really simpler but shows a way of doing it:

@echo off
if not %1#==# goto HULP

cls
c:
cd "c:\vk"
start "" cmd /k echo VK is ready:
quit


:HULP
echo %0 brengt u van en uit het menu naar dos

--
Regards,
Mic

Gerard

unread,
Mar 4, 2010, 1:24:19 PM3/4/10
to

"foxidrive" <got...@woohoo.invalid> schreef in bericht
news:vesvo5dgsfh4d5h32...@4ax.com...
> Micedit dos

But now you go back to "bach", not to the "VK" directory...

Gerard


Gerard

unread,
Mar 4, 2010, 1:34:56 PM3/4/10
to

"foxidrive" <got...@woohoo.invalid> schreef in bericht
news:vesvo5dgsfh4d5h32...@4ax.com...

Sorry, I made a mistak, your script is OK: thank you!!

Regards,
Gerard


Todd Vargo

unread,
Mar 4, 2010, 4:43:23 PM3/4/10
to

Having read all of the responses thus far, I'm perplexed at why you don't
assign shortcut keys to the shortcuts of the respective programs. Other than
for educational purposes, this reinvention of the wheel seems to be
defeating the purpose of the "start" menu and/or shortcut keys.

--
Todd Vargo
(Post questions to group only. Remove "z" to email personal messages)


--- news://freenews.netfront.net/ - complaints: ne...@netfront.net ---

Gerard

unread,
Mar 4, 2010, 5:07:26 PM3/4/10
to

"Todd Vargo" <tlv...@sbcglobal.netz> schreef in bericht
news:hmp9hu$255q$1...@adenine.netfront.net...

The answer is in the subject: "another beginner's question". Your being
perplexed perplexes me.
But feel free to explain what you mean: I am eager to learn..

Regards,
Gerard


Gerard

unread,
Mar 4, 2010, 6:36:49 PM3/4/10
to

"billious" <billio...@hotmail.com> schreef in bericht
news:LLCdnQj2mNsDfxLW...@westnet.com.au...

Hi,

Thank you for your extended comment. I am afraid that it is, at this moment,
too difficult for me to understand due to lack of knowledge in this field: I
am a beginner in batch-files.
I'll save your explanation, and study, and after a certain time - not too
long I hope - I will be able to understand it and, maybe, ask for some
clarification.
Thanks again!

Regard,
Gerard
>
>
>


Sjouke Burry

unread,
Mar 4, 2010, 6:35:50 PM3/4/10
to
I dont think you can, the current application will eat al chars,
or lets you end the program.
If your OS is true DOS, you might try ro write a TRS program to
catch certain chars.
Other than that, no.

Todd Vargo

unread,
Mar 4, 2010, 11:30:57 PM3/4/10
to
> The answer is in the subject: "another beginner's question". Your being
> perplexed perplexes me.
> But feel free to explain what you mean: I am eager to learn..

I typically write batches that do something which the OS does not already
provide.

Tim Meddick

unread,
Mar 5, 2010, 2:47:26 PM3/5/10
to
I keep telling you, foxidrive, that including the empty quotation marks (START
command) with a non-console app (i.e. a Windowed application) are totally
unnecessary...

e.g.

start c:\progra~1\outloo~1\msimn.exe

...is perfectly acceptable!

==

Cheers, Tim Meddick, Peckham, London. :-)


foxidrive

unread,
Mar 5, 2010, 3:30:45 PM3/5/10
to
On Fri, 5 Mar 2010 19:47:26 -0000, "Tim Meddick" <timme...@gawab.com>
wrote:

>I keep telling you, foxidrive, that including the empty quotation marks (START
>command) with a non-console app (i.e. a Windowed application) are totally
>unnecessary...

You're quite wrong.


--
Regards,
Mic

foxidrive

unread,
Mar 5, 2010, 3:54:15 PM3/5/10
to
On Sat, 06 Mar 2010 07:30:45 +1100, foxidrive <got...@woohoo.invalid>
wrote:

A case in point, using your short pathnames with the start command.


@echo off
md "u & me"
copy "%windir%\explorer.exe" "u & me"
start U&ME~1\explorer.exe

--
Regards,
Mic

billious

unread,
Mar 5, 2010, 10:30:47 PM3/5/10
to

"Tim Meddick" <timme...@gawab.com> wrote in message
news:hmrn4k$484$1...@speranza.aioe.org...

The issue is that the inclusion of the redundant title is NEVER an error,
but the omission MAY lead to an error because the START command has
badly-defined, ambiguous syntax.

Consistent inclusion of the redundant title means that there is one fewer
side-issue to confuse the beginner.

Programmers commonly abandon the minimalist approach after they find
difficulties in maintaining their own too-clever-by-half code six months
after writing it. Sometimes it takes two or more such such experiences for
the lesson to be learned. Sometimes, the lesson is never learned and these
people tend to become managers whose talent extend to talking about the job
but not to doing it.


Todd Vargo

unread,
Mar 5, 2010, 11:12:44 PM3/5/10
to
Tim Meddick wrote:
>I keep telling you, foxidrive, that including the empty quotation marks
>(START command) with a non-console app (i.e. a Windowed application) are
>totally unnecessary...
>
> e.g.
>
> start c:\progra~1\outloo~1\msimn.exe
>
> ...is perfectly acceptable!

Your lack of quoting is not only annoying, it is obvious that you did not
read the final sentence of his post, or you refuse to acknowledge it (which
ever the case may be).

<quote>


Also the "" after the START keyword is required in W2K/XP/Vista etc if
there is another quoted path\filename or parameter following it.

</quote>

Obviously, *if* a parameter being passed requires quoting, then the
minimalist approach falls apart quickly when someone happens to copy/paste
snippets of code that exclude it.

start c:\path-to~1\some~1\prog~1.exe %1

%1 may be quoted or not quoted on a per use basis which demonstrates that
either you teach others to include the empty string consistently, or you
provide a tutorial every time someone copies minimalist code and can not
figure out why it keeps failing even after having read the start/? help over
and over.

Tim Meddick

unread,
Mar 7, 2010, 11:07:09 AM3/7/10
to
I accept now that what you've been saying is true.

I have to say that I didn't quite understand what it was you were saying about the
"start" syntax last time.

This is because, after some time trying to test out what I thought you were saying, I
couldn't find any ambiguities.

This was a result of, because I detest quoted long pathnames, I converted virtually
every one to the short ["dos-compatible"] form.

If the start command finds an unquoted path to a program it will execute it, even if
quotes are used as a second parameter thereafter.

But I see now how this would be confusing for beginners and all syntax should be
proofed as much as possible for all circumstances and eventualities.

...so that's me apologising then...

==

Cheers, Tim Meddick, Peckham, London. :-)


"foxidrive" <got...@woohoo.invalid> wrote in message
news:akr2p5lst2dmqmrpm...@4ax.com...

0 new messages