Problem with For Again

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
Cleptography
Posts: 287
Joined: 16 Mar 2011 19:17
Location: scriptingpros.com
Contact:

Problem with For Again

#1 Post by Cleptography » 30 May 2011 21:09

Why doesn't this work like it should?

Code: Select all

@echo off

set^
 var=for^
 %%a^
 in^
 (deltaairlines)^
 do^
 set var=%%a
 set ser=a b c
 for /d %%e in (%ser%) do set ser=%%e:\
 echo.%var%&%var%&echo.%var%&&for %%x in (airforce) do set val=%%x
 set val=/%val:~-5,-4%&&set qua=quality
 set qua=/%qua:~-7,-6%
 set /a num=13+19
 for /d %%- in (control sytem) do set why=%%-
 for /f "tokens=1*" %%x in ("window washers of the world unite") do set win=%%x&set nxt=%%y
 set nxt=%nxt:~-20,-19%
 %var:~0,-10%^
 %val% %qua%^
 %ser%%win%%nxt%\%why%%num%

Ed Dyreen
Expert
Posts: 1569
Joined: 16 May 2011 08:21
Location: Flanders(Belgium)
Contact:

Re: Problem with For Again

#2 Post by Ed Dyreen » 30 May 2011 21:52

I solved one error for you, but I am not the 'solving other peoples problems' kind of guy.
More like the 'hint' one.

Code: Select all

@echo off

set var=for %%a in (deltaairlines) do set var=%%a
set ser=a b c
for /d %%e in (%ser%) do set ser=%%e:\
pause
echo.%var%^&%var% &echo.%var% &&for %%x in (airforce) do set val=%%x
pause
set val=/%val:~-5,-4%&&set qua=quality
set qua=/%qua:~-7,-6%
set /a num=13+19
for /d %%- in (control sytem) do set why=%%-
pause
for /f "tokens=1*" %%x in ("window washers of the world unite") do set win=%%x&set nxt=%%y
set nxt=%nxt:~-20,-19%
%var:~0,-10%^
%val% %qua%^
%ser%%win%%nxt%\%why%%num%

pause
exit /b

You don't understand some important rules yet.

What do u think this means ?
set^
var=for^

first you skip a line, then you continue it ? so eventiually you get this
setvar=for^

That is not a valid command.

Code: Select all

setvar wordt niet herkend als een interne
of externe opdracht, programma of batchbestand.
Druk op een toets om door te gaan. . .

Did you had your cup of coffee yet :wink: Ooo this is coming back at me :)

Cleptography
Posts: 287
Joined: 16 Mar 2011 19:17
Location: scriptingpros.com
Contact:

Re: Problem with For Again

#3 Post by Cleptography » 30 May 2011 22:49

Ed Dyreen wrote:Did you had your cup of coffee yet :wink: Ooo this is coming back at me :)

Caffeine and keystrokes and occasionally an unhealthy dose of energy drink.
This batch business is hieroglyphics to me. These ^ caret tp looking things make no sense,
and they always disappear from the screen when I try to echo them. It's like now they are here
now they are gone. Let's see David Blaine match that one.

I see what the problem was it did work until phpbb forms removed a couple of leading spaces.
:P

Ed Dyreen
Expert
Posts: 1569
Joined: 16 May 2011 08:21
Location: Flanders(Belgium)
Contact:

Re: Problem with For Again

#4 Post by Ed Dyreen » 30 May 2011 23:16

The ^ have a very special meaning, they are the most common causes of errors in batch.
And yes they dissapear because they should, they are used for all kind of things.

setlocal enabledelayedexpansion
echo. !
echo. ^!
echo.^^^!

read all of dostips &all threads, that should keep you buzzin for a while.

Cleptography
Posts: 287
Joined: 16 Mar 2011 19:17
Location: scriptingpros.com
Contact:

Re: Problem with For Again

#5 Post by Cleptography » 31 May 2011 00:02

I have read every ounce of this page many times over.

Ed Dyreen
Expert
Posts: 1569
Joined: 16 May 2011 08:21
Location: Flanders(Belgium)
Contact:

Re: Problem with For Again

#6 Post by Ed Dyreen » 31 May 2011 00:22

I studied this site as a beginner, I recommend you read it completely.
I recommend it because it is the best teacher I know but only for beginners.
Which makes it easier to read.
YOU MUST read this:
http://www.allenware.com/icsw/icswidx.htm

Post Reply