ur

convert 4 section to 3 section version

12 posts in this topic

#1 ·  Posted

In the present product I have version in the About section as  4 section one like (10.00.00.2456)

And the version in other products I have version number like (97.000.2456 , 10.000.2345)

 

Is there any UDF or function to convert 4 digit format to 3 digit one.?

I need that for version comparison of different products.

Share this post


Link to post
Share on other sites



#2 ·  Posted

Why not use _VersionCompare function?

Share this post


Link to post
Share on other sites

#3 ·  Posted

39 minutes ago, Subz said:

Why not use _VersionCompare function?

It won't work in this case as the format is different.

As the first string is 10.000.2345 and second is 10.00.00.2345.And the VersionCompare will result as -1

Share this post


Link to post
Share on other sites

#4 ·  Posted

Returns 1 for me (Version 1 is greater):

#include <Misc.au3>

MsgBox(0,'', _VersionCompare("10.000.2345", "10.00.00.2345"))

 

Share this post


Link to post
Share on other sites

#5 ·  Posted

Yeah, but it should be equal.. 

Share this post


Link to post
Share on other sites

#6 ·  Posted

Why would it be equal?  It's normally implied that a version has four sections, when one section is omitted it assumes 0, so 10.000.2345 would become 10.000.2345.0.

  • 10 = Major revision
  • 00 = Minor revision

The last two can be mixed depending on the developer

  • 00 = Patch release
  • 2345 = Build number

Share this post


Link to post
Share on other sites

#7 ·  Posted

The 4 version format is olde format in window and it is converted to 3 section format from windowws 7 onwards.

If you check in server 2008, both file and product version of a exe are 4 section and from windows 2012 it is different.

So , if we leave about the standards, is there any solution to convert the 4 section to 3 section format.?

Share this post


Link to post
Share on other sites

#8 ·  Posted

What is the exact conversion between the 2 formats for my understanding?  (so I don't have to do the research myself)

Jos


Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

#9 ·  Posted

Actually, the  first string is 10.000.2345 and second is 10.00.00.2345

As the 4 section one, 2nd and 3rd should be merged.

may be if 10.01.34.2345 then it merged as 10.134.2345

if 10.00.34.2345 then it merged as 10.034.2345

 

 

Share this post


Link to post
Share on other sites

#11 ·  Posted

No, I tried to code, but someone in my team mentioend that a solition already exists as UDF in the portal.

 

Share this post


Link to post
Share on other sites

#12 ·  Posted

3 minutes ago, ur said:

No, I tried to code, but someone in my team mentioend that a solition already exists as UDF in the portal.

No idea what this means. What did you try to code? 
It could very well be somebody tackled this issue before but to me it is as simple as this:

#include <Misc.au3>

Func _My_VersionCompare($sVersion1, $sVersion2)
    $V1 = StringSplit($sVersion1, ".")
    $V2 = StringSplit($sVersion2, ".")
    If $V1[0] = 4 Then
        $sVersion1 = $V1[1] & "." & $V1[2] & $V1[3] & "." & $V1[4]
    EndIf
    If $V2[0] = 4 Then
        $sVersion2 = $V2[1] & "." & $V2[2] & $V2[3] & "." & $V2[4]
    EndIf
    Return _VersionCompare($sVersion1, $sVersion2)
EndFunc   ;==>_My_VersionCompare


ConsoleWrite('_VersionCompare("10.000.2345", "10.00.00.2345") = ' & _VersionCompare("10.000.2345", "10.00.00.2345") & '    >Error code: ' & @error & @CRLF) ;### Debug Console
ConsoleWrite('_My_VersionCompare("10.000.2345", "10.00.00.2345") = ' & _My_VersionCompare("10.000.2345", "10.00.00.2345") & '    >Error code: ' & @error & @CRLF) ;### Debug Console

Agree? :)

Jos

1 person likes this

Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now

  • Similar Content

    • TheDcoder
      By TheDcoder
      Hi, I have a 2D array with 2 columns, the 1st column contains a "version string" and the 2nd column contains a generic string. I want to sort it in the descending order so the latest version comes first.
      #include <Array.au3> Local $aVersionsAndReleases[4][2] = [["0.2.8.9", "Release #1"], ["0.2.9.10", "Release #3"], ["0.2.9.11", "Release #4"], ["0.2.8.10", "Release #2"]] _ArraySort($aVersionsAndReleases, 1) ConsoleWrite(_ArrayToString($aVersionsAndReleases, ' - ')) _ArrayDisplay($aVersionsAndReleases) Unfortunately, _ArraySort isn't working here . This is the output generated by the script:
      0.2.9.11 - Release #4 0.2.9.10 - Release #3 0.2.8.9 - Release #1 0.2.8.10 - Release #2 The expected result should be:
      0.2.9.11 - Release #4 0.2.9.10 - Release #3 0.2.8.10 - Release #2 0.2.8.9 - Release #1 I am looking to develop an function which does this... but I don't know where to start . Can someone help me get started? Thanks in Advance!
      - TD.
    • careca
      By careca
      Hi, im trying to get the file version. "16.612.1119.0"
      This is what i did, and what i got.
      ConsoleWrite(FileGetVersion (@ScriptDir&"\SciTE4AutoIt3.exe", "FileVersion") &@CRLF) Result:
      ${MyVersion}
      What am i missing here?

    • Vivaed
      By Vivaed
      I am trying to read all the files in a folder, then whatever file is newest, keep only that one and delete the rest.
      Example files:  (these all have version numbers embedded in them, I dont want to rely on the file name)
      Faint.exe
      Faint-v2.0.exe
      Faint-v3.0.exe
      Faint-v4.0.exe
       
      What I have so far:
      #include <File.au3> RemoveOldFiles() ConsoleWrite(FileGetVersion("C:\WB Resources\FAINT_DONT_LINK_THESE\Faint-v4.0.0.exe") &@CRLF) Func RemoveOldFiles() Local $aFileList = _FileListToArray("C:\WB Resources\FAINT_DONT_LINK_THESE\", "*.exe",$FLTA_FILES) For $i = 0 To UBound($aFileList) - 1 $aFileVersion = FileGetVersion($aFileList[$i]) ConsoleWrite($aFileList[$i] & @CRLF) ConsoleWrite($aFileVersion & @CRLF) Next EndFunc OUTPUT: >Running:(3.3.14.2):C:\Program Files (x86)\AutoIt3\autoit3_x64.exe "C:\Users\bot\ownCloud\WellBeats\Delete Old Files\delete-test.au3" --> Press Ctrl+Alt+Break to Restart or Ctrl+Break to Stop 3 0.0.0.0 a.exe 0.0.0.0 b.exe 0.0.0.0 Faint-v4.0.0.exe 0.0.0.0 4.0.0.18 <-- This is the correct file version.... +>07:34:26 AutoIt3.exe ended.rc:0 +>07:34:26 AutoIt3Wrapper Finished. >Exit code: 0 Time: 0.6647 Not sure what I am missing here?
      Thanks!
    • ur
      By ur
      How to get the thrid number of a file version.
      Example: Let's say I have a file with below properties.
      I want only the third number like here it is 1941 as highlighted.
      Is there any built in function to get it??

    • IT_9600
      By IT_9600
      Hello,
      how can I read the complete Version and Build-Numer for Windows 10?
      If I execute "winver.exe" in windows command-line I get the Build "10586.420".
      When I run "@OSBuild" in autoit I get "10586" and when I run "FileGetVersion(@SystemDir & "\WinVer.exe"" I get "10.0.10586.0".
      How can I get the rest of the number 420?
      Thanks for help!