Re: [Lazarus] Build Number

2010-07-23 Thread Kjow
2010/7/23 Paul Ishenin webpi...@mail.ru:
  23.07.2010 6:12, Mattias Gaertner wrote:

 Is it possible to use inside the application the build number? Since
 Lazarus has an auto-increment of the build number, I would to include
 a label with the revision in the gui of my app... :)

 No.

 Unless you write a tool/script that is called before compile and
 updates an include file used by the application. The IDE does that for
 svn revision number.

 I think Kjow is asking about the auto increment build number feature which
 increases the version  on every build. If so then yes - it is possible to
 show in a label. If you need an easy class to extract the version
 information from the resource I can publish it.

es, I mean the build number of developed applications, not lazarus or fpc.

When I do Build all the build number of my developed application
will increase (e.g. 0.0.0.1 - 0.0.0.2 - 0.0.0.3 - etc ), and if I
want to include this info in the GUI of the same application I need to
modify everytime by hand this value. So it would be very nice if there
will be a constant where get this value dinamically.

Regards,
Kjow

--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] Build Number

2010-07-23 Thread Paul Ishenin

23.07.2010 15:50, Kjow wrote:

When I do Build all the build number of my developed application
will increase (e.g. 0.0.0.1 -  0.0.0.2 -  0.0.0.3 -  etc ), and if I
want to include this info in the GUI of the same application I need to
modify everytime by hand this value. So it would be very nice if there
will be a constant where get this value dinamically.


This constanst is stored as a resource of your application. You can read 
it by accessing this resource.


I attached a small utility unit which helps with the version info 
extraction.


Here is a small example of how to use it (add vinfo and versiontypes 
units to your uses section):


procedure TForm1.Button1Click(Sender: TObject);

  function ProductVersionToString(PV: TFileProductVersion): String;
  begin
Result := Format('%d.%d.%d.%d', [PV[0],PV[1],PV[2],PV[3]])
  end;

var
  Info: TVersionInfo;
begin
  Info := TVersionInfo.Create;
  Info.Load(HINSTANCE);
  ShowMessage(ProductVersionToString(Info.FixedInfo.FileVersion));
  ShowMessage(ProductVersionToString(Info.FixedInfo.ProductVersion));
  Info.Free;
end;

Best regards,
Paul Ishenin.
unit vinfo;

{$mode objfpc}

interface

uses
  Classes, SysUtils, resource, versiontypes, versionresource;

type
  { TVersionInfo }

  TVersionInfo = class
  private
FVersResource: TVersionResource;
function GetFixedInfo: TVersionFixedInfo;
function GetStringFileInfo: TVersionStringFileInfo;
function GetVarFileInfo: TVersionVarFileInfo;
  public
constructor Create;
destructor Destroy; override;

procedure Load(Instance: THandle);
property FixedInfo: TVersionFixedInfo read GetFixedInfo;
property StringFileInfo: TVersionStringFileInfo read GetStringFileInfo;
property VarFileInfo: TVersionVarFileInfo read GetVarFileInfo;
  end;

implementation

{ TVersionInfo }

function TVersionInfo.GetFixedInfo: TVersionFixedInfo;
begin
  Result := FVersResource.FixedInfo;
end;

function TVersionInfo.GetStringFileInfo: TVersionStringFileInfo;
begin
  Result := FVersResource.StringFileInfo;
end;

function TVersionInfo.GetVarFileInfo: TVersionVarFileInfo;
begin
  Result := FVersResource.VarFileInfo;
end;

constructor TVersionInfo.Create;
begin
  inherited Create;
  FVersResource := TVersionResource.Create;
end;

destructor TVersionInfo.Destroy;
begin
  FVersResource.Free;
  inherited Destroy;
end;

procedure TVersionInfo.Load(Instance: THandle);
var
  Stream: TResourceStream;
begin
  Stream := TResourceStream.CreateFromID(Instance, 1, PChar(RT_VERSION));
  try
FVersResource.SetCustomRawDataStream(Stream);
// access some property to load from the stream
FVersResource.FixedInfo;
// clear the stream
FVersResource.SetCustomRawDataStream(nil);
  finally
Stream.Free;
  end;
end;

end.

--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] Build Number

2010-07-23 Thread Mattias Gaertner
On Fri, 23 Jul 2010 15:59:00 +0800
Paul Ishenin i...@kmiac.ru wrote:

 23.07.2010 15:50, Kjow wrote:
  When I do Build all the build number of my developed application
  will increase (e.g. 0.0.0.1 -  0.0.0.2 -  0.0.0.3 -  etc ), and if I
  want to include this info in the GUI of the same application I need to
  modify everytime by hand this value. So it would be very nice if there
  will be a constant where get this value dinamically.
 
 This constanst is stored as a resource of your application. You can read 
 it by accessing this resource.
 
 I attached a small utility unit which helps with the version info 
 extraction.
 
 Here is a small example of how to use it (add vinfo and versiontypes 
 units to your uses section):
 
 procedure TForm1.Button1Click(Sender: TObject);
 
function ProductVersionToString(PV: TFileProductVersion): String;
begin
  Result := Format('%d.%d.%d.%d', [PV[0],PV[1],PV[2],PV[3]])
end;
 
 var
Info: TVersionInfo;
 begin
Info := TVersionInfo.Create;
Info.Load(HINSTANCE);
ShowMessage(ProductVersionToString(Info.FixedInfo.FileVersion));
ShowMessage(ProductVersionToString(Info.FixedInfo.ProductVersion));
Info.Free;
 end;

Maybe it should be added somewhere in the documentation?
including the requirements.

Mattias

--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] Build Number

2010-07-23 Thread Paul Ishenin

23.07.2010 16:05, Mattias Gaertner wrote:

Maybe it should be added somewhere in the documentation?
including the requirements.


I wish to add it somewhere to fpc but don't know the right place.

Btw, is it possible to add a unit to the documentation?

Best regards,
Paul Ishenin.


--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] Build Number

2010-07-23 Thread Paul Ishenin

23.07.2010 16:12, Kjow wrote:

Thank you, but my Lazarus (r26732M) can't find vinfo unit.


vinfo unit was attached with the mail.


Other question: Is this procedure multiplatform compatible? ( =  Does
it work on Linux?)


Yes.

Best regards,
Paul Ishenin.


--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] Build Number

2010-07-23 Thread Sven Barth

Hi!

Am 23.07.2010 00:58, schrieb waldo kitty:

on the surface, this would seem to be similar to the C style
preprocessor stuff that takes macros like __DATE__ and __TIME__ and
converts them to the current date and time and writes them into the
object code... i did something like this for TP6/BP6 way back in the
day... set those as consts in an include that was rewritten each time by
my preprocessor before the command line compiler was called... actually
using them (ie: forcing them to be included in the binary) required that
at least one const string be used in the execution of the program...
these didn't have to be used in the code but they were included such
that one could see them in the binary when it was viewed via a hex
editor/viewer...


Did you know about this:

===

program Foo;

{$apptype console}

begin
  Writeln({$I %DATE%} + ' ' + {$ %TIME%});
  Readln;
end.

===

Output:

2010/07/23 10:13:40

===

It's documented here: 
http://www.freepascal.org/docs-html/prog/progsu38.html#x45-430001.1.38


Regards,
Sven

--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] Build Number

2010-07-23 Thread Mattias Gaertner
On Fri, 23 Jul 2010 16:12:28 +0800
Paul Ishenin i...@kmiac.ru wrote:

 23.07.2010 16:05, Mattias Gaertner wrote:
  Maybe it should be added somewhere in the documentation?
  including the requirements.
 
 I wish to add it somewhere to fpc but don't know the right place.
 
 Btw, is it possible to add a unit to the documentation?

For FCL units: ask Michael.


Mattias

--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] Build Number

2010-07-23 Thread Kjow
2010/7/23 Paul Ishenin i...@kmiac.ru:
 23.07.2010 16:12, Kjow wrote:

 Thank you, but my Lazarus (r26732M) can't find vinfo unit.

 vinfo unit was attached with the mail.

 Other question: Is this procedure multiplatform compatible? ( =  Does
 it work on Linux?)

 Yes.

 Best regards,
 Paul Ishenin.

Oops! :)
Thank you! In gmail, when there is a file attached, there isn't a
great visibility.

--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] Build Number

2010-07-23 Thread waldo kitty

On 7/23/2010 04:12, Kjow wrote:

2010/7/23 Paul Ishenini...@kmiac.ru:

This constanst is stored as a resource of your application. You can read it
by accessing this resource.

I attached a small utility unit which helps with the version info
extraction.

Here is a small example of how to use it (add vinfo and versiontypes units
to your uses section):


Thank you, but my Lazarus (r26732M) can't find vinfo unit.


did you miss the attachment(s)??


--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] Build Number

2010-07-23 Thread waldo kitty

On 7/23/2010 04:17, Sven Barth wrote:

Hi!

Am 23.07.2010 00:58, schrieb waldo kitty:

on the surface, this would seem to be similar to the C style
preprocessor stuff that takes macros like __DATE__ and __TIME__ and
converts them to the current date and time and writes them into the
object code... i did something like this for TP6/BP6 way back in the
day... set those as consts in an include that was rewritten each time by
my preprocessor before the command line compiler was called... actually
using them (ie: forcing them to be included in the binary) required that
at least one const string be used in the execution of the program...
these didn't have to be used in the code but they were included such
that one could see them in the binary when it was viewed via a hex
editor/viewer...


Did you know about this:


whoa! wow!! how about that! i'd have never thought to even try something like 
that... it looks the same as including environment variables in 4DOS/4OS2/4NT 
with the percents on both sides like that :) :) :)


i guess i'm going to have to figure out how to separate FPC from Lazarus so as 
to get a better base of FPC's offerings before attempting to dance the GUI 
dance... getting them in one package is nice except that one can get confused 
about what it available in Lazarus vs what is available in FPC...


i really do wish that the help files would come preinstalled in the available 
installation packages... installing on win and *nix leaves a lot to be desired 
as far as the built in F1 help stuff goes... especially when one has to go in 
and fill in the blanks with some unknown directory value(s) that are not readily 
apparent :? i won't even mention having a PDF of the documentation as i know 
that there's still work going on for the german language book that i hope will 
be released in english before too long...


thanks for sharing that :) if it were only that easy to grab other values like 
the compilation version number originally spoken of in this thread ;)




===

program Foo;

{$apptype console}

begin
Writeln({$I %DATE%} + ' ' + {$ %TIME%});
Readln;
end.

===

Output:

2010/07/23 10:13:40

===

It's documented here:
http://www.freepascal.org/docs-html/prog/progsu38.html#x45-430001.1.38

Regards,
Sven

--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus




--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] Build Number

2010-07-23 Thread Kjow
2010/7/23 waldo kitty wkitt...@windstream.net:
 On 7/23/2010 04:12, Kjow wrote:

 2010/7/23 Paul Ishenini...@kmiac.ru:

 This constanst is stored as a resource of your application. You can read
 it
 by accessing this resource.

 I attached a small utility unit which helps with the version info
 extraction.

 Here is a small example of how to use it (add vinfo and versiontypes
 units
 to your uses section):

 Thank you, but my Lazarus (r26732M) can't find vinfo unit.

 did you miss the attachment(s)??

Yes, I missed.
But as already wrote, then I found it. ;)

--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] Build Number

2010-07-22 Thread Mattias Gaertner
On Thu, 22 Jul 2010 23:42:41 +0200
Kjow antispamm...@gmail.com wrote:

 Hi all,
 
 Is it possible to use inside the application the build number? Since
 Lazarus has an auto-increment of the build number, I would to include
 a label with the revision in the gui of my app... :)

No.

Unless you write a tool/script that is called before compile and
updates an include file used by the application. The IDE does that for
svn revision number.

Mattias

--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] Build Number

2010-07-22 Thread Paul Ishenin

 23.07.2010 6:12, Mattias Gaertner wrote:



Is it possible to use inside the application the build number? Since
Lazarus has an auto-increment of the build number, I would to include
a label with the revision in the gui of my app... :)

No.

Unless you write a tool/script that is called before compile and
updates an include file used by the application. The IDE does that for
svn revision number.
I think Kjow is asking about the auto increment build number feature 
which increases the version  on every build. If so then yes - it is 
possible to show in a label. If you need an easy class to extract the 
version information from the resource I can publish it.


Best regards,
Paul Ishenin.

--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] Build Number

2010-07-22 Thread waldo kitty

On 7/22/2010 18:12, Mattias Gaertner wrote:

On Thu, 22 Jul 2010 23:42:41 +0200
Kjowantispamm...@gmail.com  wrote:


Hi all,

Is it possible to use inside the application the build number? Since
Lazarus has an auto-increment of the build number, I would to include
a label with the revision in the gui of my app... :)


No.

Unless you write a tool/script that is called before compile and
updates an include file used by the application. The IDE does that for
svn revision number.


on the surface, this would seem to be similar to the C style preprocessor stuff 
that takes macros like __DATE__ and __TIME__ and converts them to the current 
date and time and writes them into the object code... i did something like this 
for TP6/BP6 way back in the day... set those as consts in an include that was 
rewritten each time by my preprocessor before the command line compiler was 
called... actually using them (ie: forcing them to be included in the binary) 
required that at least one const string be used in the execution of the 
program... these didn't have to be used in the code but they were included such 
that one could see them in the binary when it was viewed via a hex editor/viewer...



--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus