Page 1 sur 1
[R] Problème Sound.au3
Posté : ven. 22 janv. 2010 19:52
par Narmeke
Bonjours tous le monde !
J'ai un petit souci avec Sound.au3

, lors de l'appelle d'une fonction, j'obtiens une erreur.
Je suis sous Vista, et j'aimerais que quelq'un m'UP son Sound.au3 pour tester si j'ai la même erreur !
Merci d'avance !
Re: [..] Problème Sound.au3
Posté : sam. 23 janv. 2010 00:12
par Tlem
Si vous ne donnez pas la teneur de l'erreur, comment voulez-vous que l'on puise vous aider ...
Re: [..] Problème Sound.au3
Posté : sam. 23 janv. 2010 08:32
par Narmeke
Oui, c'est vrai
Alors mon message d'errreur est le suivant :
Code : Tout sélectionner
Line 443 (File "C:\Program Files\AutoIt3\Include\Sound.au3"):
If $aSndID[1] <> 0 Then
If ^ ERROR
Error: Array variable has incorrect number of subscipts or subscipt dimension range exeeded.
Extrait de Sound.au3
Code : Tout sélectionner
If StringInStr($aSndID[0], '!') Then Return SetError(3, 0, 0) ; invalid file/alias
;tell mci to use time in milliseconds
__mciSendString("set " & $aSndID[0] & " time format miliseconds")
;receive position of sound
$iSndPosMs = Number(__mciSendString("status " & $aSndID[0] & " position", 255))
[color=#FF0000]If $aSndID[1] <> 0 Then[/color] [color=#40FF00]; <=== Ligne 442 (c'est ici que se situe mon erreur)[/color]
$iSndPosMs -= $aSndID[2]
EndIf
;modify data and assign to variables
_TicksToTime($iSndPosMs, $iSndPosHour, $iSndPosMin, $iSndPosSecs)
Re: [..] Problème Sound.au3
Posté : sam. 23 janv. 2010 11:41
par Tlem
L'erreur que vous obtenez signale simplement que (dans votre cas)
$aSndID n'est pas un tableau.
Il faut donc remonter plus avant dans le code et voir quand ce tableau est sensé être créé ou initialisé et pourquoi il ne l'est pas.

Re: [..] Problème Sound.au3
Posté : sam. 23 janv. 2010 12:05
par Narmeke
La fonction complète :
Code : Tout sélectionner
Func _SoundPos($aSndID, $iMode = 1)
;Declare variables
Local $iSndPosMs, $iSndPosMin, $iSndPosHour, $iSndPosSecs, $sSndPosFormat, $vTemp
;validate $iMode
If $iMode <> 1 And $iMode <> 2 Then Return SetError(1, 0, 0)
If Not IsArray($aSndID) Then
If Not FileExists($aSndID) Then Return SetError(3, 0, 0) ; invalid file/alias
$vTemp = FileGetShortName($aSndID)
Dim $aSndID[1] = [$vTemp]
EndIf
If StringInStr($aSndID[0], '!') Then Return SetError(3, 0, 0) ; invalid file/alias
;tell mci to use time in milliseconds
__mciSendString("set " & $aSndID[0] & " time format miliseconds")
;receive position of sound
$iSndPosMs = Number(__mciSendString("status " & $aSndID[0] & " position", 255))
If $aSndID[1] <> 0 Then
$iSndPosMs -= $aSndID[2]
EndIf
;modify data and assign to variables
_TicksToTime($iSndPosMs, $iSndPosHour, $iSndPosMin, $iSndPosSecs)
;assign formatted data to $sSndPosFormat
$sSndPosFormat = StringFormat("%02i:%02i:%02i", $iSndPosHour, $iSndPosMin, $iSndPosSecs)
;return correct variable
If $iMode = 1 Then Return $sSndPosFormat
If $iMode = 2 Then Return $iSndPosMs
EndFunc ;==>_SoundPos
Pas Facile ^^
Re: [..] Problème Sound.au3
Posté : sam. 23 janv. 2010 12:24
par Tlem
Sans la possibilité de tester en situation réelle, je ne peut vous donner que quelques directions de recherche.
La fonction _SoundPos($aSndID, $iMode = 1) est initialisée avec deux paramètres, dont un ($iMode) est optionnel.
$aSndID quant à lui peut contenir le nom d'un fichier, ou un tableau.
La condition entre la ligne 6 de la fonction, teste si $aSndID est un tableau. Si il ne l'est pas, alors on vérifie que le fichier existe. Si le fichier n'existe pas alors on renvoi une erreur, sinon on stocke dans la variable $aSndID[0] le nom court (8+3) du chemin+fichier.
Je vous conseil donc de rajouter ligne 12 (juste avant la ligne ;tell mci to use time in milliseconds) une ligne de debug afin de contrôler que la variable $aSndID[0] contient bien le nom court d'un fichier avant de continuer le code.
Re: [..] Problème Sound.au3
Posté : sam. 23 janv. 2010 13:06
par Narmeke
Code : Tout sélectionner
Func _SoundPos($aSndID, $iMode = 1)
;validate $iMode
If $iMode <> 1 And $iMode <> 2 Then Return SetError(1, 0, 0)
If Not __SoundChkSndID($aSndID) Then Return SetError(3, 0, 0) ; invalid Sound ID or file name
;tell mci to use time in milliseconds
__SoundMciSendString("set " & $aSndID[0] & " time format miliseconds")
;receive position of sound
Local $iSndPosMs = Number(__SoundMciSendString("status " & $aSndID[0] & " position", 255))
If $aSndID[1] <> 0 Then
$iSndPosMs -= $aSndID[2]
EndIf
If $iMode = 2 Then Return $iSndPosMs
;$iMode = 1 (hh:mm:ss)
;modify data and assign to variables
Local $iSndPosMin, $iSndPosHour, $iSndPosSecs
__SoundTicksToTime($iSndPosMs, $iSndPosHour, $iSndPosMin, $iSndPosSecs)
;assign formatted data to $sSndPosFormat
Local $sSndPosHMS = StringFormat("%02i:%02i:%02i", $iSndPosHour, $iSndPosMin, $iSndPosSecs)
;return correct variable
Return $sSndPosHMS
EndFunc ;==>_SoundPos
Et voilà le travail ^^
Cela fonctionne parfaitement a présent.
Merci Tlem
