Calling external file - cmd shuts

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Message
Author
keyboard1333
Posts: 21
Joined: 23 Aug 2012 00:07

Re: Calling external file - cmd shuts

#16 Post by keyboard1333 » 24 Aug 2012 17:34

Thanks for all your help foxidrive!

Another question -

Code: Select all

cls
IF NOT "%~1"=="" (
   set "gotit="
   for /f "delims=" %%a in (Data\inventory.fldr) do if "%%a"=="%1" set item=%%a
   if defined %item% (
      echo TRUE
   ) else (
      echo FALSE
   )

   pause
) else (
   echo equip what?
   pause
)


echos false whether or not the item is in inventory.fldr

foxidrive
Expert
Posts: 6031
Joined: 10 Feb 2012 02:20

Re: Calling external file - cmd shuts

#17 Post by foxidrive » 24 Aug 2012 18:40

reaper17 wrote:Another question -

@echo off
for /f "delims=" %%a in (Data\inventory.fldr) do echo if "%%a"=="%1" set item=%%a
if defined %item% (
echo TRUE
) else (
echo FALSE
)
pause


echos false whether or not the item is in inventory.fldr


Here's a tip. Reduce the code to a small subset, and then run it as above with the echo in place and examine the screen text to see why it fails.

I suspect it has to do with quotes around %1

Post Reply