

InterviewSolution
Saved Bookmarks
1. |
Solve : %%BLAH or %BLAH%!??!?!?? |
Answer» <html><body><p>I know that %variables_have_percent_marks% but what %%is_this? is it also a variable?Take a nice long look at for /? the next time you open the command prompt...you may just learn something. <br/><br/>In the mean time, here is what you wanted:<br/>%variables% are used with the <a href="https://interviewquestions.tuteehub.com/tag/set-11758" style="font-weight:bold;" target="_blank" title="Click to know more about SET">SET</a> command are are called variables. Whatever their value is replaces it. <br/>%%a is not an actual variable. It is a token used in for loops. It only substitutes the value while in a for loop. It can't be changed manually, like a regular variable. <br/><br/>For example, both these codes will do the exact same thing, but they are different as you can see. <br/> Code: <a>[Select]</a>echo off<br/>:loop<br/>set /a num+=1<br/>echo %num%<br/>if %num%==10 goto stop<br/>goto loop<br/>:stop<br/>pause Code: <a>[Select]</a>echo off<br/>for /l %%a in (1,1,10) do echo %%a<br/>pausealso, it's only double-percent <a href="https://interviewquestions.tuteehub.com/tag/signs-236644" style="font-weight:bold;" target="_blank" title="Click to know more about SIGNS">SIGNS</a> when in a batch file. you can type for commands on the command line, but you must use a single percent sign:<br/><br/> Code: <a>[Select]</a>C:\Windows>for /f "tokens=*" %P in ('dir /s /<a href="https://interviewquestions.tuteehub.com/tag/b-236590" style="font-weight:bold;" target="_blank" title="Click to know more about B">B</a>') do echo %P<br/>set a=1&call echo %%a%% Code: <a>[Select]</a>Microsoft Windows <a href="https://interviewquestions.tuteehub.com/tag/xp-747558" style="font-weight:bold;" target="_blank" title="Click to know more about XP">XP</a> [Version 5.1.2600<br/>(C) Copyright 1985-2001 Microsoft Corp<br/><br/>d:\batch>set a=1&call echo %%a%%<br/>%1%<br/><br/>d:\batch><br/> Quote from: Geek-9pm on February 24, 2010, 11:08:48 PM</p><blockquote> Code: <a>[Select]</a>Microsoft Windows XP [Version 5.1.2600<br/>(C) Copyright 1985-2001 Microsoft Corp<br/><br/>d:\batch>set a=1&call echo %%a%%<br/>%1%<br/><br/>d:\batch><br/> <br/></blockquote> <br/>my thoughts <a href="https://interviewquestions.tuteehub.com/tag/exactly-977868" style="font-weight:bold;" target="_blank" title="Click to know more about EXACTLY">EXACTLY</a>... not sure what is being said with that...test it in a .bat file Quote from: Prince_ on February 24, 2010, 10:58:14 PM<blockquote>set a=1&call echo %%a%%<br/></blockquote> Quote from: Prince_ on February 25, 2010, 12:52:56 AM<blockquote>test it in a .bat file<br/></blockquote> <br/><br/><br/>C:\>type a25.bat<br/> Code: <a>[Select]</a>echo off<br/><br/>REM "Test it in a .bat file"<br/><br/>set a=1&call echo %%a%%<br/><strong>Output:</strong><br/><br/>C:\> a25.bat<br/>1<br/><br/>C:\><br/><br/> Not worth bananas. Please do not waster the bananas.</body></html> | |