Omnis Technical Note TNID0005 May 2007
Adding version info to your application
For Omnis Studio 3 or above
By Andreas Pfeiffer
"Not this indoctrination again!", I probably hear you say. Yes, I am always keen to stress the importance of documenting your own code using comments and other methods, but here I'd like to point out a technique that lets you add version information to your application, without much effort (well, almost). And along the way you will appreciate the fact that changes should be documented, and can, to an extent, be displayed for the end user's benefit. At this point you might say, "Why not use the Omnis VCS?" Well, although the built-in Version Control System (VCS) in Omnis has become very powerful and mature - and I would really recommend you use it for most of your Omnis projects - some developers may want to complete small projects without the VCS. For those special cases the following tech tip might be helpful - you could regard the following technique as "VCS Lite".
The "About" code class
Those of you familiar with my technical advise (and occasional comments
on the Omnis developer list) know that I tell everybody not to use code
classes, ever! This is absolutely true, but with just one tiny exception:
the use of a code class that we could call an "About" class. In this context,
the code class will take on a different job than code classes usually
do. The only thing you have to do manually is to add a method to the code
class for this simple technique to work. Then any changes you make to
your application will be stored as a comment in the method text of this
method. For each new method you store a version number, such as "1.00"
or "1.01". Using this technique, you now have the possibility at any time
to find out the changes to your code.
Display the version number automatically
In order to display the last version number you only have to create a
new method in your Startup_Task called "$getVersion Number" which returns
the name of the last method created:
Do $classes.about.$methods.$makelist($Ref.$name,$ref.$methodtext)
Returns methodList
; the code class is called 'about'
Quit method methodList.[methodList.$linecount()].c1
Now you can add the latest version number to the title of your application at any time:
Set Omnis window title {MyApplication, Version [$ctask.$getVersionNumber()]}
Display changes
Create a window with a Headed List Box with two columns. Associate the
Headed List box via its $dataname with an instance variable of the type
List "ivList". In the $construct() method of this window, simply create
a list with all methods of the 'about' code class and therefore display
all changes:
Do $classes.about.$methods.$makelist(
$ref.$name,$ref.$methodtext,$ref.$ident) Returns ivList
Do ivList.$sort($ref.c3,kTrue)
Do ivList.$sendall(
$ref.c2.$assign(replaceall(ivList.[ivList.$line].c2,'; ','')))
The last line deletes the unnecessary semicolons. The window should now display all entries of the 'about' code class starting with the latest one. You can display this window to end users, so long as you can 'go public' with your comments.