History: Query Ogre Version
Source of version: 6 (current)
Copy to clipboard
{maketoc}
!!About "Query Ogre Version"
The following tool is designed for Windows (it has been tested on Windows XP).
It adds a shell extension under the explorer and allows you to query the version of Ogre, the file (or the directory) is belong to.
Once you have merged the .reg file, you can right click a file (or a directory) and select the "Query Ogre Version" entry.
!!Source Code
__queryOgreVersion.reg__
{CODE(wrap="1", colors="reg")}Windows Registry Editor Version 5.00
[HKEY_CLASSES_ROOT\*\shell\OgreVersion]
@="Query Ogre3D version"
[HKEY_CLASSES_ROOT\*\shell\OgreVersion\command]
@="wscript.exe your_path_here\\queryOgreVersion.vbs \"%1\""
[HKEY_CLASSES_ROOT\Directory\shell\OgreVersion]
@="Query Ogre3D version"
[HKEY_CLASSES_ROOT\Directory\shell\OgreVersion\command]
@="wscript.exe your_path_here\\queryOgreVersion.vbs \"%1\""{CODE}
__queryOgreVersion.vbs__
{CODE(wrap="1", colors="vb")}' VB Script Document
Dim gSHELL
Dim gFSO
Dim gARGS
Set gArgs = WScript.Arguments
Set gSHELL = CreateObject( "WScript.Shell" )
Set gFSO = CreateObject( "Scripting.FileSystemObject" )
'-------------------------------------------------------------------------------
function FindOgreHeader( in_path )
result =""
path = in_path
If not(gFSO.FolderExists(path)) Then
call SplitFilename(path, directory, basefilename, extension )
path = directory
if not(gFSO.FolderExists(path)) Then
FindOgreHeader = result
exit function
end if
end if
path = Lcase(path)
tokens = Split( path, "\" )
nbTokens=UBound(tokens)+1
ogreHeader = "\ogreMain\include\OgrePrerequisites.h"
concat = ""
for i=0 to nbTokens-1
concat = concat & tokens(i)
if gFSO.FileExists(concat & ogreHeader ) then
result = concat & ogreHeader
exit for
end if
concat = concat & "\"
next
FindOgreHeader = result
end function
'-------------------------------------------------------------------------------
function MySplit( in_text)
Dim NumWords, a()
NumWords = 0
spaceTokens = Split( in_text, " ")
nbSpaceToken =UBound(spaceTokens)
for i=0 to nbSpaceToken
tabTokens = Split( spaceTokens(i), vbTab )
nbTabToken = UBound( tabTokens )
if( nbTabToken=0 ) then
redim preserve a(NumWords+1)
a(NumWords) = spaceTokens(i)
NumWords = NumWords + 1
else
for j = 0 to nbTabToken
if tabTokens(j)<>"" then
redim preserve a(NumWords+1)
a(NumWords) = tabTokens(j)
NumWords = NumWords + 1
end if
next
end if
next
MySplit = a
end function
'-------------------------------------------------------------------------------
function UnQuote(in_text)
result = in_text
if Len(in_text)>=2 then
if Right(in_text,1)="""" and left(in_text,1)="""" then
result = Mid(in_text, 2, Len(in_text)-2)
end if
end if
UnQuote = result
end function
'-------------------------------------------------------------------------------
function GetOgreVersion( in_path )
result = "not found!"
ogreHeader = FindOgreHeader( in_path )
if ogreHeader<>"" then
Set inputFile = gFSO.OpenTextFile(ogreHeader, 1)
major= ""
minor = ""
patch = ""
name = ""
ended = false
count = 0
line = 0
Do While ((inputFile.AtEndOfStream <> True) and not(ended))
line = line + 1
readBuffer = Trim(inputFile.ReadLine)
tokens = MySplit( readBuffer)
on error resume next
nbTokens=UBound(tokens)
If err.number <> 0 then
nbTokens = 0
end if
On Error Goto 0
if nbTokens>=3 then
if tokens(0)="#define" then
if tokens(1)="OGRE_VERSION_MAJOR" then
major = tokens(2)
count = count+1
elseif tokens(1)="OGRE_VERSION_MINOR" then
minor = tokens(2)
count = count+1
elseif tokens(1)="OGRE_VERSION_PATCH" then
patch = tokens(2)
count = count+1
elseif tokens(1)="OGRE_VERSION_SUFFIX" then
suffix = tokens(2)
count = count+1
elseif tokens(1)="OGRE_VERSION_NAME" then
name = tokens(2)
count = count+1
end if
end if
end if
if count=5 then
ended = true
end if
Loop
inputFile.Close
result = major & "." & minor & "." & patch & " " & UnQuote(suffix) & vbCrLf & "codename = " & UnQuote(name)
end if
GetOgreVersion = result
end function
'-------------------------------------------------------------------------------
Sub SplitFilename( inFilename, outDirectory, outBaseFilename, outExtension )
posSlash = InStrRev( inFilename, "/" )
posAntislash = InStrRev( inFilename, "\" )
posDirectory = posSlash
If ( posAntislash > posSlash ) Then
posDirectory = posAntislash
End If
outDirectory = Mid( inFilename, 1, posDirectory )
outBaseFilename = Right( inFilename, len(inFilename)-posDirectory )
posExtension = InStrRev( outBaseFilename, "." )
outExtension = Right( outBaseFilename, len(outBaseFilename)-posExtension )
if posExtension<>0 then
outBaseFilename = Left( outBaseFilename, posExtension-1)
end if
End Sub
'----------------------------------- MAIN --------------------------------------
if( gArgs.Count>=0 ) then
path = gArgs(0)
version = GetOgreVersion( path )
msgbox "version="&version, vbInformation, "Ogre3D Information"
end if{CODE}