PDA

View Full Version : Read PRODUCTVER from .Version



NewsArchive
04-02-2007, 10:50 AM
Hello,

what is the best approach to read the FILEVERSION out of the .Version file
for setting the [PRODUCTVER] ?

Thanks

Gregor

NewsArchive
04-12-2007, 03:38 AM
Hello,

here is what i am using to read the Version from the Clarion .Version file:

Set Variable %CVER_FILE% to "C:\develop\Application\Application.Version"
Set Variable %CVER_LINE% to ScriptItem->Find Line "FileVersion" from "%CVER_FILE%"
If %_SB_ERRORCODE% Equals "0" And %CVER_LINE% Greater Than "0" Then
Set Variable %CVER_TXTLINE% to ScriptItem->Get Line %CVER_LINE% from "%CVER_FILE%"
Set Variable %CVER_TXTLINE% to ScriptItem->Replace(%CVER_TXTLINE%, FILEVERSION, )
Set Variable %CVER_TXTLINE% to ScriptItem->Ltrim(%CVER_TXTLINE%)
Set Variable %CVER_TXTLINE% to ScriptItem->Replace(%CVER_TXTLINE%, ,, |)
Set Variable %CVER_LISTITEMS% to ScriptItem->Count List Items(%CVER_TXTLINE%)
Set Variable %CVER_MAJOR% to ScriptItem->Get List Item(%CVER_TXTLINE%, 1)
Set Variable %CVER_MINOR% to ScriptItem->Get List Item(%CVER_TXTLINE%, 2)
Set Variable %CVER_SUB% to ScriptItem->Get List Item(%CVER_TXTLINE%, 3)
Set Variable %CVER_BUILD% to ScriptItem->Get List Item(%CVER_TXTLINE%, 4)
/* Display Message Box
"%CVER_MAJOR%\n%CVER_MINOR%\n%CVER_SUB%\n%CVER_BUIL ..." -- "%CVER_TXTLINE%" */
#set compiler variable [PRODUCTVER] = "%CVER_MAJOR%.%CVER_MINOR%%CVER_SUB%"
End

Is there a way to find the .Version file out of the Source/EXE directory to set
%CVER_FILE% ?

Thank you
Gregor

NewsArchive
04-12-2007, 03:38 AM
Gregor,

What you do here is you set a "compiler variable" (only available at
compile-time) to a runtime variable (only available at installer run-time).
This is not possible.

"%CVER_MAJOR%.%CVER_MINOR%%CVER_SUB etc. are all runtime variables (resolved
if you *run* the installer).

In your case, [PRODUCTVER] contains "%CVER_MAJOR%.%CVER_MINOR%%CVER_SUB%"
(exactly what you see here, not any version value).

For example, you have this in your Clarion application:

TestVar CSTRING(260)
GETINI('test', 'myvar',,'c:\test.ini')

You cannot use TestVar here to do any "conditional compile". TestVar is
resolved at runtime, not compile time!

Friedrich

NewsArchive
04-12-2007, 03:38 AM
Thank you Friedrich,

so there is no way to read the PRODUCTVER from the .Version file by compile time?

Gregor

NewsArchive
04-12-2007, 03:53 AM
Gregor,

Sure, very easy to do! Develop an application (using SetupBuilder, Clarion,
Visual Studio, etc.) that reads the FILEVERSION from a file. Then write the
retrieved value to an INI file. BTW, you can do this with SetupBuilder with
3 lines of script code.

Something like that:

Set Variable %FILEVERSION% to ScriptItem->Get File Information(File Version
(Resource)) of file "c:\test\myapp.exe"

You can even extract the major/minor/release/build values.

Set Variable %MAJORVER% to ScriptItem->Extract Major Number(%FILEVERSION%)
Set Variable %MINORVER% to ScriptItem->Extract Minor Number(%FILEVERSION%)

Then write the version to an INI file.

In your project (.sb6), use the #run compiler directive to execute the above
application at compile time and then use #const to read the file version
value from the above INI into a constant. After that, set [PRODUCTVER] to
the constant.

! Start app to extract version info from an application
! Write result to an INI
#run c:\test\getver.exe

! Read value from INI into a constant
#const $PRODUCTVER$ = Get Value from INI file: c:\test\getver.ini

! Set [PRODUCTVER] to version
#set compiler variable [PRODUCTVER] = "$PRODUCTVER$"

Does this help?

--
Friedrich Linder
Lindersoft
www.lindersoft.com
+1.954.252.3910

"point. click. ship" - that's SetupBuilder 6
Create Windows Vista ready installations in minutes

-- Official Comodo Code Signing and SSL Certificate Partner

NewsArchive
04-12-2007, 07:01 AM
OK, what could be nicer as a warm, sunny spring day with a "WOW - so easy?!"
experience :-)
Thank you Friedrich

ClVersion.exe:
Set Variable %FILEVERSION% to ScriptItem->Get File Information(File Version
(Resource)) of file "%EXEFILE%"
Set Variable %MAJORVER% to ScriptItem->Extract Major Number(%FILEVERSION%)
Set Variable %MINORVER% to ScriptItem->Extract Minor Number(%FILEVERSION%)
Set Variable %SUBVER% to ScriptItem->Extract Revision Number(%FILEVERSION%)
Set Variable %BUILDVER% to ScriptItem->Extract Build Number(%FILEVERSION%)
Edit INI File "%_SB_INSTALLDIR%\VERSION.INI" (Always Install)
/* Content: [$PRODUCTVER$] */
/* Value = %MAJORVER%.%MINORVER%%SUBVER% */

MainSetupFile:
#const $EXEFILE$ = "C:\develop\Application.exe"
#run ClVersion.exe /V _SB_INSTALLDIR [OUTPUTDIR] /V EXEFILE $EXEFILE$ [Wait]
#const $PRODUCTVER$ = Get Value from INI file: [OUTPUTDIR]\VERSION.INI
#set compiler variable [PRODUCTVER] = "$PRODUCTVER$"
[...]

The only small drawback is setting of the $EXEFILE$.

Gregor

NewsArchive
04-12-2007, 07:01 AM
:)

What exactly is the problem with $EXEFILE$? Perhaps I have a solution (or
can check if SetupBuilder 6.5 already has a solution available).

Friedrich

NewsArchive
04-12-2007, 07:02 AM
It is not really a problem - only for convenience
It would be nice to set the main exe file path
by looping to the files from 'files and folders'.
I have already defined the main exe file what
I am looking for is the source path.

Gregor