Discussions related to Visual Prolog
Harrison Pratt
VIP Member
Posts: 439
Joined: 5 Nov 2000 0:01

Accessing IDE Variables & Version Information

Unread post by Harrison Pratt »

(1) Is there a built-in way to retrieve IDE variables (Tools > IDE Variables...) ?

I am using this approach:

Code: Select all

    run() :-         % Existing IDE variable 'TestVar' set to "MyTestVariableAsString"         console::write("\nStarting test ...\n"),         RootKey = @"SOFTWARE\Prolog Development Center\Visual Prolog6\settings\toolsDirList",         Key = "TestVAR", % NOT case-sensitive         if string(V) = registry::tryGetValue(registry::currentUser, RootKey, Key) then             console::write("Found value: ", V)         else             console::writef("Not found: Key '%' under '%'", Key, RootKey)         end if,         console::write("\nPress enter to exit."),         _ = console::readLine().
Of course, IDE variables are not portable to applications delivered outside the development environment.

(2) How can I retrieve the project's 'File Flags' information (Project Settings > Version Information > File Flags)?
User avatar
Thomas Linder Puls
VIP Member
Posts: 1398
Joined: 28 Feb 2000 0:01

Re: Accessing IDE Variables & Version Information

Unread post by Thomas Linder Puls »

(1) No. We are using an approach similar to yours.

(2) Version Information is stored in a version file (typically main.version).

The version file can be shared by several projects, and hence the information will become the same in all those programs.

The information is in xml format, but you dont really have to consider that, because there is an (undocumented) API for accessing it (requires Commercial Edition).

To access a version file you will code like this:

Code: Select all

VersionData = vip\versionDataFactory::get(vip\versionData::interfaceVersion, "main.version")
The result is an object of this type:

Code: Select all

namespace vip   interface versionData   constants     interfaceVersion = 1.   domains     versionType = versionType(unsigned N1, unsigned N2, unsigned N3, unsigned N4).   properties     company : string.     author : string.     copyright : string.     trademarks : string.     fileVersion : versionType.     productVersion : versionType.   properties     ffDebug : boolean.     ffPrerelease : boolean.     ffPatched : boolean.     ffSpecialBuild : boolean.     ffPrivateBuild : boolean.   predicates     saveData : ().   end interface versionData
On the version info tab there is also a Description and that actually comes from the project file (which can be accessed in a similar way):

Code: Select all

ProjectData = vip\projectDataFactory::get(vip\projectData::interfaceVersion, "myproject.vipprj")
Regards Thomas Linder Puls
PDC
Harrison Pratt
VIP Member
Posts: 439
Joined: 5 Nov 2000 0:01

Re: Accessing IDE Variables & Version Information

Unread post by Harrison Pratt »

Ahhhhh ... thank you very much, Thomas!

(2) Works better for me with the code modified as below, otherwise the properties are unassigned. Apparently the predicate doesn't fail or cause an exception if the file is missing.

VersionData = vip\versionDataFactory::get(vip\versionData::interfaceVersion, @"..\main.version")

Cheers,
Harrison
User avatar
Thomas Linder Puls
VIP Member
Posts: 1398
Joined: 28 Feb 2000 0:01

Re: Accessing IDE Variables & Version Information

Unread post by Thomas Linder Puls »

Last thing first: The file does not have to exist, because the interface is also used to create such files (i.e. using save).

"main.version" was just meant as an informative indication; if you mean some particular file you must of course provide a proper path to that file.

From you path I can see that the program is accessing its own version file, which indicates to me that you perhaps mean something different.

"main.version" is use by the build system to create a version resource which is linked into your program. So "main.version" is a source file, the version resource is the corresponding target in your executable.

And therefore the question is whether you want your program to read "main.version" or the resulting version resource inside the program?
Regards Thomas Linder Puls
PDC
Harrison Pratt
VIP Member
Posts: 439
Joined: 5 Nov 2000 0:01

Re: Accessing IDE Variables & Version Information

Unread post by Harrison Pratt »

Oh, now I understand!

"main.version" is use by the build system to create a version resource which is linked into your program. So "main.version" is a source file, the version resource is the corresponding target in your executable.

I'd want the resource, of course. :D
User avatar
Thomas Linder Puls
VIP Member
Posts: 1398
Joined: 28 Feb 2000 0:01

Re: Accessing IDE Variables & Version Information

Unread post by Thomas Linder Puls »

The default about dialogs contains one or more versionControls. Such a versionControl can format information from programs own version resource.

So by looking at that code you will be able to see how to read version (resource) information.
Regards Thomas Linder Puls
PDC
Harrison Pratt
VIP Member
Posts: 439
Joined: 5 Nov 2000 0:01

Re: Accessing IDE Variables & Version Information

Unread post by Harrison Pratt »

Got it!

It's simple to extend the File Version parameters in aboutDialog.pro, but I don't see how to access the File Flags Project Settings (i.e., "Debug", "Prerelease", ... ) or Product Version in versonControl.pro. These parameters are not defined in versionControl.i
User avatar
Thomas Linder Puls
VIP Member
Posts: 1398
Joined: 28 Feb 2000 0:01

Re: Accessing IDE Variables & Version Information

Unread post by Thomas Linder Puls »

Well, it seems that we have duplicated some code for this. And that we could have provided a more full interface.

Anyways, the fileVersion class contains more code for this. But you will have to create your own code for this.

The information is in the vs_fixedfileinfo struct (which for some strange reason is declared locally in the class rather than globally in fileSystem_native).

Code: Select all

domains     vs_fixedfileinfo =         vs_fixedfileinfo(             unsigned Signature,             unsigned StrucVersion,             unsigned FileVersionMS, % notice that most significant is before least significant (unlike I386)             unsigned FileVersionLS,             unsigned ProductVersionMS, % notice that most significant is before least significant (unlike I386)             unsigned ProductVersionLS,             unsigned FileFlagsMask,             unsigned FileFlags,             unsigned FileOS,             unsigned FileType,             unsigned FileSubtype,             unsigned FileDateMS, % notice that most significant is before least significant (unlike I386)             unsigned FileDateLS).
You can see how the Debug flag is masked out in getFileVersionInfo
Regards Thomas Linder Puls
PDC
Harrison Pratt
VIP Member
Posts: 439
Joined: 5 Nov 2000 0:01

Re: Accessing IDE Variables & Version Information

Unread post by Harrison Pratt »

Now it is clear, thanks!
Harrison Pratt
VIP Member
Posts: 439
Joined: 5 Nov 2000 0:01

Re: Accessing IDE Variables & Version Information

Unread post by Harrison Pratt »

Here is a small point I noticed while working on this topic -- there is no code to retrieve legalTrademarks or originalFileName.

Code: Select all

constants % in fileVersion.CL     companyNameApi = "CompanyName".     fileVersionApi = "FileVersion".     legalCopyrightApi = "LegalCopyright".     fileDescriptionApi = "FileDescription".     legalTrademarks = "LegalTrademarks".  % <== THERE IS NO CODE USING THIS CONSTANT in fileVersion.PRO     originalFilename = "OriginalFilename". % <== THERE IS NO CODE USING THIS CONSTANT in fileVersion.PRO     productName = "ProductName".     productVersion = "ProductVersion".
The trademark string can be recalled with the code below, so the information IS stored. Likewise, the original file name is also stored, but there is no way to access it..

Code: Select all

class predicates     getTradeMarkinfo : (string PNE) -> string Tm. clauses     getTradeMarkInfo(Filename) = Tm :-         VerInfoBin = loadVersionInfo(Filename),         LangAndCP = getLanguageAndCodePageKey(VerInfoBin),         Tm = getFileVersionInformation(VerInfoBin, legalTrademarks, LangAndCP).
Thanks again for your help. :D
Post Reply