Build Number [Question]! - Glint - 28.09.2012
Hello guys i didn't know where to post this it seemed for me more then a discussion then a question because i want to know HOW exactly you can make it.
However my question is : let's say a script has a build number now every-time we compile we have to go through it and change it before we compile (+1) and to be honest it will be pain in the ass if you are compiling a lot.
Are there any ways that we can increase the build number every-time the compiler compiles the script ?
Re: Build Number [Question]! -
zDevon - 28.09.2012
That's a nice question and something I could see as useful, although sadly I don't think it could be done. Not through SAMP scripting alone at least.
Re: Build Number [Question]! -
Joe Staff - 28.09.2012
I suppose nothing automated is possible within Pawno itself, but I have seen one or two third party programs that I suppose could be modified for this feature. Look around the forums.
Re: Build Number [Question]! -
Calgon - 28.09.2012
Having a build number for a community/live server confuses players, just keep the version numbering system simple so players know when an update has been implemented.
If you're just doing this script for yourself/generally in private, you could (probably) make a batch script to +1 a version number somewhere in the Pawn file and then run the compiler for it.
Re: Build Number [Question]! - Glint - 28.09.2012
I read something like that in the forums two years ago but i really can't remember where, and when.
It really is useful for some case scenarios.
Re: Build Number [Question]! -
Vince - 28.09.2012
I currently run SVN which keeps track of version numbers as long as I don't forget to actually log the changes. Then I run a batch file which copies the svn log to my server directory and creates a file in the scriptfiles directory with content like:
Code:
r48 | Vince | 2012-09-28 11:29:23 +0200 (vr, 28 sep 2012)
Whenever I want it, I can read that file with fread and display the information. I tried including the file at first, but that didn't work out because of errors.
Re: Build Number [Question]! - Glint - 28.09.2012
Quote:
Originally Posted by Vince
Whenever I want it, I can read that file with fread and display the information. I tried including the file at first, but that didn't work out because of errors.
|
I tried to create a batch file when someone runs / compiles the script in PAWNO that batch script will run and it will create a new file with a variable that is set to 0, the file would be .txt extension.
So everytime we hit run the batch runs and +1's the variable into the .txt file.
So later on we can use fread to read the file into our script.
However i bumped into some trouble in the batch file.
Re: Build Number [Question]! - rjjj - 28.09.2012
I have written a code to help you
![afro](images/smilies/mrgreen.gif)
:
Code:
@ECHO OFF
TITLE Compilation
:: Replace "Source.pwn" in the line below with the name of your Pawn script file.
SET FileName="Source.pwn"
(
ECHO.Option Explicit
ECHO.Dim Fso, Text, x
ECHO.ReDim Lines^(0^)
ECHO.Set Fso = CreateObject^("Scripting.FileSystemObject"^)
ECHO.Set Text = Fso.OpenTextFile^(%FileName%^)
ECHO.While Not Text.AtEndOfStream
ECHO. x = Text.Line - 1
ECHO. ReDim Preserve Lines^(x^)
ECHO. Lines^(x^) = Text.ReadLine^(^)
ECHO. If InStr^(Lines^(x^), "const BuildNumber = "^) = 1 Then
ECHO. Lines^(x^) = "const BuildNumber = " ^& CInt^(Mid^(Lines^(x^), 21, Len^(Lines^(x^)^) - 21^)^) + 1 ^& ";"
ECHO. End If
ECHO.Wend
ECHO.Text.Close^(^)
ECHO.Fso.DeleteFile^(%FileName%^)
ECHO.Set Text = Fso.CreateTextFile^(%FileName%^)
ECHO.For Each x In Lines
ECHO. Text.WriteLine^(x^)
ECHO.Next
ECHO.Text.Close^(^)
) > Modify.vbs
CSCRIPT //NOLOGO Modify.vbs
DEL Modify.vbs
PAWNCC %FileName%
PAUSE > NUL
Save this as a batch file and put it in the same folder of
pawncc.exe ![Tongue](images/smilies/razz.gif)
.
Then move your Pawn script file to that folder and add this to the top of it:
The value of that constant will be increased by 1 and the compilation will happen each time you run the batch file
![afro](images/smilies/mrgreen.gif)
.
I hope that I have helped
![Tongue](images/smilies/razz.gif)
.
Re: Build Number [Question]! - Glint - 28.09.2012
Quote:
Originally Posted by rjjj
I have written a code to help you ![afro](images/smilies/mrgreen.gif) :
Code:
@ECHO OFF
TITLE Compilation
:: Replace "Source.pwn" in the line below with the name of your Pawn script file.
SET FileName="Source.pwn"
(
ECHO.Option Explicit
ECHO.Dim Fso, Text, x
ECHO.ReDim Lines^(0^)
ECHO.Set Fso = CreateObject^("Scripting.FileSystemObject"^)
ECHO.Set Text = Fso.OpenTextFile^(%FileName%^)
ECHO.While Not Text.AtEndOfStream
ECHO. x = Text.Line - 1
ECHO. ReDim Preserve Lines^(x^)
ECHO. Lines^(x^) = Text.ReadLine^(^)
ECHO. If InStr^(Lines^(x^), "const BuildNumber = "^) = 1 Then
ECHO. Lines^(x^) = "const BuildNumber = " ^& CInt^(Mid^(Lines^(x^), 21, Len^(Lines^(x^)^) - 21^)^) + 1 ^& ";"
ECHO. End If
ECHO.Wend
ECHO.Text.Close^(^)
ECHO.Fso.DeleteFile^(%FileName%^)
ECHO.Set Text = Fso.CreateTextFile^(%FileName%^)
ECHO.For Each x In Lines
ECHO. Text.WriteLine^(x^)
ECHO.Next
ECHO.Text.Close^(^)
) > Modify.vbs
CSCRIPT //NOLOGO Modify.vbs
DEL Modify.vbs
PAWNCC %FileName%
PAUSE > NUL
Save this as a batch file and put it in the same folder of pawncc.exe ![Tongue](images/smilies/razz.gif) .
Then move your Pawn script file to that folder and add this to the top of it:
The value of that constant will be increased by 1 and the compilation will happen each time you run the batch file ![afro](images/smilies/mrgreen.gif) .
I hope that I have helped ![Tongue](images/smilies/razz.gif) .
|
Thanks mate it worked, FINALLY!
Here eat a virtual cookie :P
EDIT: Can you tell me what exactly you did.
Re: Build Number [Question]! -
Sniper Kitty - 28.09.2012
Quote:
Originally Posted by [Lexi]
Thanks mate it worked, FINALLY!
Here eat a virtual cookie :P
EDIT: Can you tell me what exactly you did.
|
It's called
Batch programming/scripting.
Re: Build Number [Question]! -
Y_Less - 28.09.2012
Quote:
Originally Posted by Vince
I currently run SVN which keeps track of version numbers as long as I don't forget to actually log the changes. Then I run a batch file which copies the svn log to my server directory and creates a file in the scriptfiles directory with content like:
.
|
I'm pretty sure SVN has an inbuilt feature for that (properties/keywords), but I'm not sure of the syntax. Plus that's just commit number, not build number.
Quote:
Originally Posted by Sniper Kitty
It's called Batch programming/scripting.
|
No it isn't, all that code does it generate a VB script and run that instead.
Anyway, I've been trying to think of an elegant way to do this, but can't (I even checked the documentation and there was nothing). So it does look like you'll have to use a custom script. Anyway, this is what things called "makefiles" are explicitly designed for - you might want to look them up!
Re: Build Number [Question]! -
Sniper Kitty - 28.09.2012
Quote:
Originally Posted by Y_Less
No it isn't, all that code does it generate a VB script and run that instead.
|
http://www.dreamincode.net/forums/to...torial-part-1/
http://www.youtube.com/watch?v=PPsPBX7-BoQ
Correct me if I'm wrong, but that code looks ALOT similar to these '
Batch Tutorials'... No?
Re: Build Number [Question]! -
Y_Less - 28.09.2012
Well yes, sort of:
pawn Код:
) > Modify.vbs
CSCRIPT //NOLOGO Modify.vbs
That is a batch script, but all it does is print some lines to a file, save it as a .VBS file, then run that file instead (even though everything they want can be done in pure batch scripting). "echo" is like "print", or in this case like "fwrite".
Re: Build Number [Question]! -
Sniper Kitty - 28.09.2012
Okay =]
Re: Build Number [Question]! - Glint - 28.09.2012
Quote:
Originally Posted by Sniper Kitty
It's called Batch programming/scripting.
|
Why are you Quoting me ? I know what is it!
Re: Build Number [Question]! - rjjj - 29.09.2012
Quote:
Originally Posted by [Lexi]
Thanks mate it worked, FINALLY!
Here eat a virtual cookie :P
EDIT: Can you tell me what exactly you did.
|
I programmed the batch file to create another code file, made with VBScript, which would loop through the lines of the Pawn script file, storing each of them in a dynamic array
![Tongue](images/smilies/razz.gif)
.
When doing this, if the declaration of
BuildNumber was found, its value would be increased through string manipulation, variable subtype conversion and arithmetic operation.
Then the .pwn file would get deleted and another one would get made using the lines stored in that array
![afro](images/smilies/mrgreen.gif)
.
Finally, the Batch Script code would run the Pawn compiler.
I hope that I have helped
![Tongue](images/smilies/razz.gif)
.
Re: Build Number [Question]! - Glint - 29.09.2012
Quote:
Originally Posted by rjjj
I programmed the batch file to create another code file, made with VBScript, which would loop through the lines of the Pawn script file, storing each of them in a dynamic array ![Tongue](images/smilies/razz.gif) .
When doing this, if the declaration of BuildNumber was found, its value would be increased through string manipulation, variable subtype conversion and arithmetic operation.
Then the .pwn file would get deleted and another one would get made using the lines stored in that array ![afro](images/smilies/mrgreen.gif) .
Finally, the Batch Script code would run the Pawn compiler.
I hope that I have helped ![Tongue](images/smilies/razz.gif) .
|
Thanks mate i already gave you a virtual cookie, so i can now
Re: Build Number [Question]! -
zgintasz - 29.09.2012
Quote:
Originally Posted by rjjj
I programmed the batch file to create another code file, made with VBScript, which would loop through the lines of the Pawn script file, storing each of them in a dynamic array ![Tongue](images/smilies/razz.gif) .
When doing this, if the declaration of BuildNumber was found, its value would be increased through string manipulation, variable subtype conversion and arithmetic operation.
Then the .pwn file would get deleted and another one would get made using the lines stored in that array ![afro](images/smilies/mrgreen.gif) .
Finally, the Batch Script code would run the Pawn compiler.
I hope that I have helped ![Tongue](images/smilies/razz.gif) .
|
Maybe I didn't understand, but why to recreate all .pwn file? It can be very huge. You can just create another file, add "const BuildNumber = 1" to that file and do the same, what you are doing for .pwn file. And of course, include that file to main gamemode file.
Re: Build Number [Question]! -
Y_Less - 29.09.2012
Quote:
Originally Posted by zgintasz
Maybe I didn't understand, but why to recreate all .pwn file? It can be very huge. You can just create another file, add "const BuildNumber = 1" to that file and do the same, what you are doing for .pwn file. And of course, include that file to main gamemode file.
|
That's the way I would do it, in fact you can even put half the declaration in one file and just the number in another.
Re: Build Number [Question]! - rjjj - 29.09.2012
Quote:
Originally Posted by zgintasz
Maybe I didn't understand, but why to recreate all .pwn file? It can be very huge. You can just create another file, add "const BuildNumber = 1" to that file and do the same, what you are doing for .pwn file. And of course, include that file to main gamemode file.
|
I have just tried to make a program which could automate the original poster's work
![Tongue](images/smilies/razz.gif)
.
Well, if that person wants a more optimised code, your trick is able to solve his problem
![afro](images/smilies/mrgreen.gif)
.
I hope that I have helped
![Tongue](images/smilies/razz.gif)
.