Pour cette fonction, votre objet doit avoir instancié la méthode getAttribut(nom attribut)
Code : Tout sélectionner
; Exemple de getAttribut
func getAttribut($pObj,$nomAttr)
   Local $valeur
   switch ($nomAttr)
       case 'toto'
           $valeur = $pObj.toto
      ...
  EndSwitch
  return $valeur
EndFunc
 Code : Tout sélectionner
; #FUNCTION# =========================================================================
; Name...........: _SpgmSearchObjet
; Description ...: Recherche dans un tableau d'objet
; Syntax ........: _SpgmSearchObjet($pTableau,$pSearch,$pAttributSearch,[$pAttributRetour=""])
; Parameters ....: $pTableau    - Le tableau d'objet
;               : $pSearch      - La valeur à recherchée
;           : $pAttributSearch  - L'attribut contenant cette valeur
;           : $pAttributRetour - L'attribut contenant la valeur de retour [Optional : Blanc, on retourne l'objet]
; Return values .: On Success La valeur ou l'objet
;                  On Failure - -1
; Error values ..: 0 si OK,100 si vide
; Remarks .......:
; Author         : 
; Version du     : V1.0 du 07/03/2013
;   Création
; =========================================================================
Func _SpgmSearchObjet(ByRef $pTableau, $pSearch, $pAttributSearch, $pAttributRetour = "")
    Local $xi = 0
    Local $objet
    Local $erreur = 100
    While ($erreur = 100 And $xi < UBound($pTableau))
        If ($pTableau[$xi] .getAttribut($pAttributSearch) = $pSearch) Then
            If ($pAttributRetour = "") Then
                $objet = $pTableau[$xi]
            Else
                $objet = $pTableau[$xi] .getAttribut($pAttributRetour)
            EndIf
            $erreur = 0
        Else
            $xi = $xi + 1
        EndIf
    WEnd
    SetError($erreur)
    Return $objet
EndFunc   ;==>_SpgmSearchObjet
 Code : Tout sélectionner
; #FUNCTION# =========================================================================
; Name...........: _SpgmWaitFile
; Description ...: Attend la fin d'un fichier
; Syntax ........: _SpgmWaitFile($pFile,[$pTimeOut = 0])
; Parameters ....: $pFile       - Le fichier
;                : $pTimeOut    - Le timeout [Optionnel]
; Return values .: On Success La taille du fichier
;                  On Failure - -1
; Error values ..: 0 si OK
; Remarks .......:
; Author         : 
; Version du     : V1.0 du 07/03/2013
;   Création
; =========================================================================
Func _SpgmWaitFile($pFile, $pTimeOut = 0)
    Local $xi = 0
    Local $xj = -1
    While (($xi < $pTimeOut Or $pTimeOut = 0) And (Not FileExists($pFile) Or FileGetSize($pFile) = 0))
        Sleep(1000)
        $xi = $xi + 1
    WEnd
    If ($xi <> $pTimeOut Or $pTimeOut = 0) Then
        $xi = 0
        While (($xi < $pTimeOut Or $pTimeOut = 0) And $xj <> FileGetSize($pFile))
            $xj = FileGetSize($pFile)
            $xi = $xi + 1
            Sleep(1000)
        WEnd
    EndIf
    If ($xi = $pTimeOut And $pTimeOut <> 0) Then SetError(-1)
    Return $xj
EndFunc   ;==>_SpgmWaitFile
 Code : Tout sélectionner
; #FUNCTION# =========================================================================
; Name...........: _SpgmCtrlDate
; Description ...: Controle d'une date
; Syntax ........: _SpgmCtrlDate([$pDate="",[$pHeure=""]])
; Parameters ....: $pDate   - La date à contrôler [optionnel]
;                : $pHeure  - L'heure à controler [optionnel]
; Return values .: On Success La Date/Heure TU et la Date/Heure Locale
;                  On Failure - Le message d'erreur
; Error values ..: 0 si OK,-1 si erreur
; Remarks .......:
; Author         : 
; Version du     : V1.0 du 07/03/2013
;   Création
; Analyse
; -1- Contrôle de la date
;  -11- Si ASAP,IMMEDIAT,blanc : Date du jour
;  -12- Si jj/mm/yyyy ou jj/mm/yy (lg 8 ou 10), retourner la date (yyyy/mm/jj) puis faire le controle
;  -13- Autres cas, date invalide
; -2- Contrôle de l'heure
;  -21- Si ASAP,IMMEDIAT,HH:MM ou blanc : Heure actuelle
;  -22- Contrôle date + heure
; -3- Récup de l'heure locale et de l'heure TU par rapport à l'heure demandée
; -4- Renvoyer les heures locales et TU (objet.dateLocal, objet.dateTu)
; =========================================================================
Func _SpgmCtrlDate($pDate = "", $pHeure = "")
    Local $date = "";  Date
    Local $dateLoc = "" ; Date Local
    Local $heure = ""; Heure
    Local $tu = False ; Tu ou Loc
    Local $retour ; Retour
    ; Contrôle de la date
    ; La date peut etre non renseignée,"immediat","asap" ou jj/mm/yy ou jj/mm/yyyy ou jj/mm/aa ou jj/mm/aaaa
    If (StringRegExp(StringUpper($pDate), "ASAP") _
            Or StringRegExp(StringUpper(StringReplace($pDate, "é", "e")), "IMMEDIAT") _
            Or StringUpper($pDate) = "JJ/MM/YY" _
            Or StringUpper($pDate) = "JJ/MM/YYYY" _
            Or StringUpper($pDate) = "JJ/MM/AA" _
            Or StringUpper($pDate) = "JJ/MM/AAAA" _
            Or _LTRIM($pDate) == "") Then
        $date = _NowCalcDate()
    Else
        ; Format (jj/mm/yy ou jj/mm/yyyy ou jj/mm/aa ou jj/mm/aaaa)
        If (StringLen($pDate) = 8 Or StringLen($pDate) = 10) Then
            If (StringLen($pDate) = 8) Then
                $date = "20" & StringRight($pDate, 2) & "/" & StringMid($pDate, 4, 2) & "/" & StringLeft($pDate, 2)
            Else
                $date = StringRight($pDate, 4) & "/" & StringMid($pDate, 4, 2) & "/" & StringLeft($pDate, 2)
            EndIf
            If (Not _DateIsValid($date)) Then
                SetError(-1)
                Return "Date invalide [jj/mm/yyyy ou jj/mm/yy]"
            EndIf
        Else
            SetError(-1)
            Return "Date invalide [jj/mm/yyyy ou jj/mm/yy]"
        EndIf
    EndIf
    ; Traitement de l'heure
    ; L'heure peut etre non renseignée,"immediat","asap","hh:mm" ou hh:mm ou hh:mm TU,LOC,LO ou autre
    If (StringRegExp(StringUpper($pHeure), "ASAP") _
            Or StringRegExp(StringUpper(StringReplace($pHeure, "é", "e")), "IMMEDIAT") _
            Or StringRegExp(StringUpper($pHeure), "HH:MM") _
            Or _LTRIM($pHeure) == "") Then
        $heure = _NowTime(4);
    Else
        ; Dégrouper l'heure si nécéssaire
        If StringRegExp(StringUpper($pHeure), "TU") Then $tu = True
        $heure = StringLeft($pHeure, 2) & ":" & StringMid($pHeure, 4, 2)
    EndIf
    If (Not _DateIsValid($date & " " & $heure)) Then
        SetError(-1)
        Return "Heure invalide"
    EndIf
    ; L'heure locale/tu
    Local $tag = _Date_Time_EncodeSystemTime(StringMid($date, 6, 2), StringRight($date, 2), StringLeft($date, 4), StringLeft($heure, 2), StringRight($heure, 2))
    ; La date est locale
    If (Not $tu) Then
        $dateLoc = $date & " " & $heure
        $date = _Date_Time_TzSpecificLocalTimeToSystemTime(DllStructGetPtr($tag))
        $date = _Date_Time_SystemTimeToDateTimeStr($date, 1)
    Else
        $dateLoc = _Date_Time_SystemTimeToTzSpecificLocalTime(DllStructGetPtr($tag))
        $dateLoc = _Date_Time_SystemTimeToDateTimeStr($dateLoc, 1)
        $date = $date & " " & $heure
    EndIf
    ; Retour
    $retour = _AutoItObject_Class()
    $retour.Create()
    $retour.AddProperty("dateLocal", $ELSCOPE_PUBLIC, $dateLoc)
    $retour.AddProperty("dateTu", $ELSCOPE_PUBLIC, $date)
    Return $retour.Object
EndFunc   ;==>_SpgmCtrlDate
 
