Site hosted by Angelfire.com: Build your free website today!
PowerBuilder - Automatically Incrementing Build Numbers
 

 

Source :

Message: 2
Date: Wed, 05 Feb 2003 22:48:10 -0500
From: >
Subject: Automatic build numbers [was: libraries]

Here's one better: you can use this technique to automatically generate
build numbers. Create an NVO to hold the build and version numbers.

You can put any expression to the right of the equals in the
initialization statement as long as it contains only literals or
constants (So unfortunately you can't do "ii_dummy = ds.Retrieve()"
because of the object reference) Note that the variable ii_dummy serves
no purpose other than to enforce the syntax for compile-time evaluation
of the statement

I save the build & version numbers in the pb.ini file, but it can be
anywhere. The ini file does not need to exist at runtime (and would be
ignored even if it did). In the pb.ini file, add the following section
(the first two lines should have already been created when you saved
the
NVO above):

[Build]
MyApp.Build=1
MyApp.Version=v1.0

The way I set it up, the build increments automatically each time you
save the NVO or do a build which includes the NVO. With no outside
object references, incremental builds will usually not increase the
build number, though full builds always will. This is why the code is
in a separate NVO; if you put it someplace else like the app manager it
would increment each time you saved that object. (If you have a
dedicated build machine, this would not be an issue) The version
number
is set manually, but doing it my way doesn't require editing the code
(and incurring multiple needless checkouts if using version control) to
change the version, just a rebuild. You can also initialize the build
number manually to some other value.

You can then call the object to get the build and version numbers, as
in
this n_cst_appmanager.constructor () snippet:

n_cst_version lnv_version
this.of_SetVersion (lnv_version.of_getVersion () + &
' Build ' + string (lnv_version.of_getBuild ()) + &
' ' + string (lnv_version.of_getBuildDate (), 'mmm d,
yyyy - hh:mm AM/PM'))

Hope you find this useful!

Jim

Author : Jim Espaillat <solutions@delphinusinc.com
References Links : http://www.poboxes.com/jasonvogel
Source

forward
global type n_cst_version from nonvisualobject
end type
end forward

global type n_cst_version from nonvisualobject autoinstantiate
end type

type variables
private:
  constant string PB_PATH = 'C:\Sybase\PowerBuilder 8.0\pb.ini'
  constant string APP_NAME = 'MyApp'
  
  string    is_version = ProfileString (PB_PATH, 'Build', APP_NAME + '.Version', '')
	
  integer   ii_dummy = SetProfileString (PB_PATH, 'Build', APP_NAME + '.Build', &
                       string (ProfileInt (PB_PATH, 'Build', APP_NAME + '.Build', 0) + 1))

  integer   ii_build = ProfileInt (PB_PATH, 'Build', APP_NAME + '.Build', 0)
	
  datetime  idtm_build = DateTime (Today (), Now ())
end variables

forward prototypes
public function string of_getversion ()
public function integer of_getbuild ()
public function datetime of_getbuilddate ()
end prototypes

public function string of_getversion ();RETURN is_version
end function

public function integer of_getbuild ();RETURN ii_build
end function

public function datetime of_getbuilddate ();RETURN idtm_build
end function

on n_cst_version.create
call super::create
TriggerEvent( this, "constructor" )
end on

on n_cst_version.destroy
TriggerEvent( this, "destructor" )
call super::destroy
end on