1.

Solve : More Batch file Problems?

Answer»

Alright.  I'm using a batch file to update the version.h file of the projecy when I run the full build batch on it.  However, I've got a problem.

Code: [Select]echo.      unsigned long GetVersionDay()      { >> version.h
echo.                  char DAY[15]; >> version.h
echo.                  memset(&Day[0],0,15); >> version.h
echo.                  memcpy(&Day[0],&VERSION_DATE[4],2); >> version.h
echo.                  return atoi(Day); >> version.h
echo.      } >> version.h
echo. >> version.h
echo.      unsigned long GetVersionMonth() { >> version.h
echo.                  char Month[15]; >> version.h
echo.                  memset(&Month[0],0,15); >> version.h
echo.                  memcpy(&Month[0],&VERSION_DATE[7],2); >> version.h
echo.                  return atoi(Month); >> version.h
echo.      } >> version.h
echo. >> version.h
echo.      unsigned long GetVersionYear()      { >> version.h
echo.                  char Year[15]; >> version.h
echo.                  memset(&Year[0],0,15); >> version.h
echo.                  memcpy(&Year[0],&VERSION_DATE[10],4); >> version.h
echo.                  return atoi(Year); >> version.h
echo.      } >> version.h
Up until this point everything is working fine, but when I try to echo-append the lines with ampersands "&" in them the code tries to EXECUTE what comes after the & instead of just appending the thing into the file.  For example, in line 3 it will try to execute "Day[0]" as if it's a command.

I have no idea how to fix this.  Does anyone have any ideas?Some symbols are used by the batch processor itself which can have unintended results. Try preceding the & with a ^

Ex.

echo.   memset(^&Day[0],0,15); >> version.h

More importantly, why are you using a batch file to create a file that could be more easily created by any editor?

Just a thought. The reason I want to make it with the batch file is that I want hte whole thing AUTOMATED.  There's probably an easier way out there, but batch files is what I ended up doing.   :-/

Thanks for your advise though.    I'll check that out.I know sidewinder loves his dos.....but if you in hurry.... you could have look here>> its  your choice>http://www.robvanderwoude.com/index.htmlActually Merlin I would prefer to convert all Windows users to WinScript. For some reason everybody seems to be blindly attached to batch language. The new script for Longhorn (MSH/MONAD) looks SUSPICIOUSLY like VB.NET which will probably have everyone running back to batch language.

*sigh* WELL the more forward we go......the more backward we go?........nothing new i reckon!>>>master plan of msoft......clampdown of the hardware makers >>using msoft products....next clampdown on the software programmersAnother problem.  I want to have the date in a file name, problem is that the date is done like this: mm/dd/yyyy.  A file name can't have a "/' in it.  Any ideas on hwo to overcome that?Sorry ms can i impose on you?? you will get more results/answers if you post your thread in the dos section.....ah!  *feels stupid* yes, um....  I might.  Thank you.  *shuffles off*



Discussion

No Comment Found