Riporto questa discussione apparsa nella M.l. ufficiale:
" I was wondering if the equivalent of App.Major (vb6) exists in Gambas?
Example:
' Visual Basic 6.0
Label1.Caption = "Version: " & App.Major & "." & App.Minor & "." _
& App.Revision
Riaan "
" Hoi,
put those in a class
' Gambas class file : clsVerion
' Version Info
'
' Call as follows:
' DIM cVersion as new clsVersion
'
' Print cVersion.VersionMajor & "." & cVersion.VersionMinor & " Build # " &
cVersion.Build
'
Property Read Version ' Full version eg. 1.2.39
Property Read VersionMajor As String ' Major part eg. 1
Property Read VersionMinor As String ' Minor Part eg. 2
Property Read VersionSmall As String ' Major and Minor eg. 1.2
Property Read Build As String ' Revision eg. 39
Private Versie As String
Public Sub _new()
Versie = Application.Version
End
Private Function Version_Read() As String
Return Versie
End
Private Function VersionMajor_Read() As String
Return Left(Versie, InStr(Versie, ".") - 1)
End
Private Function VersionMinor_Read() As String
Return Mid(versie, InStr(Versie, ".") + 1, RInStr(Versie, ".") -
InStr(Versie, ".") - 1)
End
Private Function Build_Read() As String
Return Right(Versie, RInStr(Versie, ".") - 2)
End
Private Function VersionSmall_Read() As String
Return Left(Versie, RInStr(Versie, ".") - 1)
End
' ============= End of Class =============
Alain Baudrez "
" Ow Alain, my poor fingers!
How about just
Application.Version.Split(".")[0] ' for the major
Application.Version.Split(".")[1] ' for the minor
Application.Version.Split(".")[2] ' for the revision
or for your OP's example
Label1.Caption = "Version: " & Application.Version
:-)
Bruce "
" My turn !!
Dim aVersion as String[] = scan(sVersion,"*.*.*")
Print aVersion[0]
Work also with split.
Fabien Bodard "
...continua...
" Ha!
Dim aVersion As String[] = Scan(Application.Version, "*.*.*")
Print aVersion[0]
= 48 keystrokes
Print Split(Application.Version, ".")[0]
= 25 keystrokes
:-)
Bruce "
" Because i've used an intermediate var to reduce the calls.
One day this can maybe be writed :
Print Application.Version.Split(".")[0]
lol
One of my dreams ...
Print "Hello World".Len
Print MySTring.Replace("s","t").Replace("O","P")
Print "Gambas".Mid(3,4) ----> mbas
Fabien Bodard "