Welcome guest. Before posting on our computer help forum, you must register. Click here it's easy and free.

Author Topic: More Batch file Problems  (Read 3404 times)

0 Members and 1 Guest are viewing this topic.

mastersquirrel

  • Guest
More Batch file Problems
« on: July 15, 2005, 09:14:14 AM »
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?

Sidewinder



    Guru

    Thanked: 139
  • Experience: Familiar
  • OS: Windows 10
Re: More Batch file Problems
« Reply #1 on: July 15, 2005, 10:06:42 AM »
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. 8)
The true sign of intelligence is not knowledge but imagination.

-- Albert Einstein

mastersquirrel

  • Guest
Re: More Batch file Problems
« Reply #2 on: July 15, 2005, 10:10:58 AM »
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.

merlin_2

  • Guest
Re: More Batch file Problems
« Reply #3 on: July 15, 2005, 11:03:38 AM »
I know sidewinder loves his dos.....but if you in hurry.... you could have look here>> its  your choice>http://www.robvanderwoude.com/index.html

Sidewinder



    Guru

    Thanked: 139
  • Experience: Familiar
  • OS: Windows 10
Re: More Batch file Problems
« Reply #4 on: July 15, 2005, 11:47:09 AM »
Actually 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* :-[
The true sign of intelligence is not knowledge but imagination.

-- Albert Einstein

merlin_2

  • Guest
Re: More Batch file Problems
« Reply #5 on: July 15, 2005, 12:13:20 PM »
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 programmers

mastersquirrel

  • Guest
Re: More Batch file Problems
« Reply #6 on: July 15, 2005, 12:30:05 PM »
Another 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?

merlin_2

  • Guest
Re: More Batch file Problems
« Reply #7 on: July 15, 2005, 12:37:45 PM »
Sorry ms can i impose on you?? you will get more results/answers if you post your thread in the dos section.....

mastersquirrel

  • Guest
Re: More Batch file Problems
« Reply #8 on: July 15, 2005, 12:39:17 PM »
ah!  *feels stupid* yes, um....  I might.  Thank you.  *shuffles off*