String in Int klappt nicht

  • Hallo zusammen,

    ich habe ein kleines Script für meine MP3s geschrieben, um die Bitrate zu kontrollieren. So weit so gut, allerdings bekommen ich eben dies **** Bitrate nicht in Integer formatiert. Hier mein Code:

    Spoiler anzeigen
    [autoit]

    MsgBox(0,"",Int(StringReplace(_GetExtProperty("C:\Testmp3.mp3", 28)," kBit/s","")))

    [/autoit] [autoit][/autoit] [autoit]

    Func _GetExtProperty($sPath, $iProp)
    Local $iExist, $sFile, $sDir, $oShellApp, $oDir, $oFile, $aProperty, $sProperty
    $iExist = FileExists($sPath)
    If $iExist = 0 Then
    SetError(1)
    Return 0
    Else
    $sFile = StringTrimLeft($sPath, StringInStr($sPath, "\", 0, -1))
    $sDir = StringTrimRight($sPath, (StringLen($sPath) - StringInStr($sPath, "\", 0, -1)))
    $oShellApp = ObjCreate("shell.application")
    $oDir = $oShellApp.NameSpace($sDir)
    $oFile = $oDir.Parsename($sFile)
    If $iProp = -1 Then
    Local $aProperty[35]
    For $i = 0 To 34
    $aProperty[$i] = $oDir.GetDetailsOf($oFile, $i)
    Next
    Return $aProperty
    Else
    $sProperty = $oDir.GetDetailsOf($oFile, $iProp)
    If $sProperty = "" Then
    Return 0
    Else
    Return $sProperty
    EndIf
    EndIf
    EndIf
    EndFunc ;==>_GetExtProperty

    [/autoit]

    Mache ich irgendwas falsch? Könnt ihr das nachvollziehen?

    Einmal editiert, zuletzt von Taek (27. Januar 2012 um 19:31)

  • Achte mal auf die Konsolenausgabe ;)

    Spoiler anzeigen
    [autoit]

    sBitrate = _GetExtProperty("C:\Testmp3.mp3", 28)
    ConsoleWrite($sBitrate & @LF)

    [/autoit] [autoit][/autoit] [autoit]

    Func _GetExtProperty($sPath, $iProp)
    Local $iExist, $sFile, $sDir, $oShellApp, $oDir, $oFile, $aProperty, $sProperty
    $iExist = FileExists($sPath)
    If $iExist = 0 Then
    SetError(1)
    Return 0
    Else
    $sFile = StringTrimLeft($sPath, StringInStr($sPath, "\", 0, -1))
    $sDir = StringTrimRight($sPath, (StringLen($sPath) - StringInStr($sPath, "\", 0, -1)))
    $oShellApp = ObjCreate("shell.application")
    $oDir = $oShellApp.NameSpace($sDir)
    $oFile = $oDir.Parsename($sFile)
    If $iProp = -1 Then
    Local $aProperty[35]
    For $i = 0 To 34
    $aProperty[$i] = $oDir.GetDetailsOf($oFile, $i)
    Next
    Return $aProperty
    Else
    $sProperty = $oDir.GetDetailsOf($oFile, $iProp)
    If $sProperty = "" Then
    Return 0
    Else
    Return $sProperty
    EndIf
    EndIf
    EndIf
    EndFunc ;==>_GetExtProperty

    [/autoit]
  • [autoit]

    MsgBox(0,"",Int(StringTrimLeft(StringReplace(_GetExtProperty("E:\......mp3", 28)," kBit/s",""),1)))

    [/autoit]

    ...hat geklappt, inder Tat kommt in der Konsole "?160 kBit/s" - bei einer Stringausgabe in einer Messagebox wird das Fragezeichen nicht angezeigt, komisch ?(

    Vielen Dank für die schnelle Hilfe! :)