Saved Bookmarks
| 1. |
Solve : is it a bug?? |
|
Answer» Can SOMEONE tell me what's going on with this? C:\Documents and Settings\user\Desktop>testBut, if I double click the bat file to open, I get this: Quote y I'm pulling my hair out trying to figure out what's wrong. The outer if statement (simplified for troubleshooting) also has something to do with it, but I need it. Code: [Select]@echo off IF 1==1 ( SET /P _ans= echo [%_ans%] SET _ans IF /i "%_ans%" == "y" ( echo yes ) ) pause This may HELP. I added a prompt messages. Not sure why you wouldn't have one when requesting input. Also what is the purpose of the outer if statement? Code: [Select]@echo off if 1==1 ( set /p _ans=Prompt goes here: call echo [%%_ans%%] set _ans call if /i "%_ans%"=="y" ( echo yes ) ) pause Code: [Select][quote author=Sidewinder link=topic=115488.msg771696#msg771696 date=1296228053] what is the purpose of the outer [b]if[/b] statement? Since the test "IF 1==1" will always be satisfied I fail to see the point of it. What's with all that CALL stuff? IGNORING the redundant outer IF test... phatpaul, clearly you have noticed the problem of setting and expanding VARIABLES inside parentheses, but equally clearly you are not aware of the solution - delayed expansion. Google for more information. Code: [Select]setlocal enabledelayedexpansion if 1==1 ( set /p _ans=Prompt goes here: echo [!_ans!] if /i "!_ans!"=="y" ( echo yes ) ) |
|