The following example demonstrates using CrossScript to increment a build number:
var file = "buildnum.h"
var text = "#define BUILDNUMBER "
var s = CWSys.readStringFromFile(file);
if (s == undefined)
n = 1;
n = eval(s.substring(text.length)) + 1;
CWSys.writeStringToFile(file, text + n);
Add a file called getbuildnum.h to your project containing the following code:
Add a file called getbuildnum.c to your project containing the following code:
Now, to combine these: