Requires: UpdateRT.lg32
Updates the OCX file in real time.
UpdateRuntime
UpdateRuntime performs a real time update of the OCX file; it should be placed as the first line of any program in which this function is required - after any Library declarations - so that the OCX is patched BEFORE any other commands or functions are called.
When you create a new file, either by opening GFABASIC without "Load MRU file..." set or by selecting "New" from the File Menu, this command and its library are automatically inserted at the top of the listing. If you would rather the command was not included in the new program, simply delete it. However, this will not stop the same thing happening on the creation of every subsequent new program.
Every instance of GFABASIC loads a copy of the OCX file into memory and it is this copy, rather than than file on the hard drive, which is updated using this command. If more than one instance of GFABASIC is running simultaneously, only the OCX files in memory in which instance UpdateRuntime has been called will be updated: this allows patched and unpatched instances to run at the same time as can be shown in the following example:
Open two instances of GFA Basic.
In the first, add this code:
Print SinH(56)
Local a% = 56
Print SinH(a%)
In the second, add this code:
$Library "UpdateRT"
UpdateRuntime ' Patches GfaWin23.Ocx
Print SinH(56)
Local a% = 56
Print SinH(a%)
Now run them both, in whichever order you wish: the first will cause a Stack Overflow error due to assigning a variable to SinH, while the second will not.
The reason for this command is the ever-increasing occurence of false-positive results reported by certain antivirus software with every new release of an updated OCX which culminated in version 2.39 being pulled as it was becoming too much of a chore chasing up the vendors and getting them to classify the OCX as safe. Therefore, all further patches and fixes not included in version 2.38 will, in future, be applied using this command.
New versions of the UpdateRT.lg32 library will be released when necessary and any relevant fixes will be referenced with the library version number; to make it easy to discover which version of the library you have installed, the UpdateRTVersion constant is included and exported.
$Library "UpdateRT"
UpdateRuntime ' Patches GfaWin23.Ocx
Text 10, 10, "Version Number: " & UpdateRTVersion
You do not have to add the code to the beginning of your programs if they are working as they should, just as, when new versions of the OCX were released, you didn't have to copy them across to all of your compiled programs if they did not need it.
In fact, in some cases, you may wish NOT to add the code if you have instituted workarounds for known bugs which have been fixed in the latest release.
This is actually an advantage of using the UpdateRT library instead of a new OCX release as, with the latter, although you could choose not to update the OCX files with your compiled programs, if you needed to edit their source code, you could run into problems as the editor would be using the latest version with all the fixes. (You could swap in and out older versions to use with the editor, but that's far more fiddly than adding or removing two lines of code).
Furthermore, the UpdateRT library actually gives more choice and flexibility as, because it is a library and its source code is in the Include folder, you can copy and edit the source code to remove fixes you don't want and create a custom UpdateRT library specific to the requirements of your particular program.
Finally, what happens if the development team reverts to releasing OCX files?
As previously stated, the UpdateRT library works with the OCX file attached to either the editor or, once compiled, accompanying the EXE file.
In the former case, if development of the library is discontinued, it could be converted into an empty shell which does nothing, so that, although it might be called, it will make no changes and have no effect. Either that or, more likely, it will test for the version of the OCX that is loaded and apply fixes - or not - accordingly. Either way, you will not need to frantically go through all your programs to remove the code to keep them working.
There would only be potential for issues in the latter case - with compiled programs - as, by adding the new OCX file, the library may well be adding fixes where it shouldn't. In this instance, you could either keep the old versions of the OCX with the compiled file or recompile the program from source code to work with the new one.
{Created by Sjouke Hamstra; Last updated: 29/03/2022 by James Gaite}