#cs ---------------------------------------------------------------------------- AutoIt Version : 3.3.8.1 Auteur: Zouzaka Fonctions du Script : _Hash_Creat _Hash_Add _Hash_Delete _Hash_Find _Hash_GetSize _Hash_FindbyValue _Hash_Verify #ce ---------------------------------------------------------------------------- #include #include #cs ---------------------------------------------------------------------------- Fonction : _Hash_Creat($hash) $hash => Variable Description : Permet de créer une hash Renvoi : (Non) SetError: (Non) #ce ---------------------------------------------------------------------------- Func _Hash_Creat(ByRef $hash) $hash = "{}" EndFunc ;==>_Hash_Creat #cs ---------------------------------------------------------------------------- Fonction : _Hash_Add($hash, $symbol, $value) $hash => Variable qui refere a la hash $symbol => Index (String) $value => Valeur a stocker (Any) Description : Ajoute un item a la hash dans le quelle sera stocké une valeur $value Renvoi : (Non) SetError: 1 => La Variable fournise n'est une hash #ce ---------------------------------------------------------------------------- Func _Hash_Add(ByRef $hash, $symbol, $value) If _Hash_Verify($hash) Then $hash = _StringInsert($hash, $symbol & " => " & $value & ",", -1) Else SetError(1) EndIf EndFunc ;==>_Hash_Add #cs ---------------------------------------------------------------------------- Fonction : _Hash_AddItem($hash, $symbol) $hash => Variable qui refere a la hash $symbol => Index (String) Description : Supprime un item a la hash Renvoi : (Non) SetError: 1 => La Variable fournise n'est une hash 2 => Item Introuvable #ce ---------------------------------------------------------------------------- Func _Hash_Delete(ByRef $hash, $symbol) If _Hash_Verify($hash) Then Local $shash = StringSplit($hash, ",") _ArrayDelete($shash, 0) Local $ahash = _ArraySearch($shash, $symbol, 0, 0, 0, 1) If Not @error == 6 Then _ArrayDelete($shash, $ahash) Local $rhash = "" For $mhash In $shash $rhash &= $mhash Next $hash = "{" & $rhash Else SetError(2) EndIf Else SetError(1) EndIf EndFunc ;==>_Hash_Delete #cs ---------------------------------------------------------------------------- Fonction : _Hash_Find($hash, $symbol) $hash => Variable qui refere a la hash $symbol => Index (String) Description : Trouve un item dans la hash grace a son index Renvoi : (Oui) SetError: 1 => La Variable fournise n'est une hash 2 => Item Introuvable #ce ---------------------------------------------------------------------------- Func _Hash_Find(ByRef $hash, $symbol) If _Hash_Verify($hash) Then Local $sResu = StringRegExp($hash, $symbol & "\s=>\s(.*?),", 1) If @error == 0 Then Return StringReplace($sResu[0], "'", "") Else SetError(2) EndIf Else SetError(1) EndIf EndFunc ;==>_Hash_Find #cs ---------------------------------------------------------------------------- Fonction : _Hash_GetSize($hash) $hash => Variable qui refere a la hash Description : Renvoi la taille de la hash Renvoi : (0ui) SetError: 1 => La Variable fournise n'est une hash #ce ---------------------------------------------------------------------------- Func _Hash_GetSize(ByRef $hash) If _Hash_Verify($hash) Then Return UBound(StringSplit($hash, ",")) - 2 Else SetError(1) EndIf EndFunc ;==>_Hash_GetSize #cs ---------------------------------------------------------------------------- Fonction : _Hash_FindbyValue($hash, $value) $hash => Variable qui refere a la hash $value => Valeur (any) Description : Trouve un item dans la hash grace a sa valeur Renvoi : (Oui) SetError: 1 => La Variable fournise n'est une hash 2 => Item Introuvable #ce ---------------------------------------------------------------------------- Func _Hash_FindbyValue(ByRef $hash, $value) If _Hash_Verify($hash) Then Local $shash = StringSplit($hash, ",") _ArrayDelete($shash, 0) Local $ahash = _ArraySearch($shash, $value, 0, 0, 0, 1) If @error == 0 Then Local $sResu = StringRegExp($shash[$ahash], "(.*?)\s(=>)\s(" & $value & ")", 1) Return StringReplace(StringReplace($sResu[0], "'", ""), "{", "") Else SetError(2) EndIf Else SetError(1) EndIf EndFunc ;==>_Hash_FindbyValue #cs ---------------------------------------------------------------------------- Fonction : _Hash_Verify($hash) $hash => Variable Description : Verifi que la variable fournise est une hash Renvoi : True => La Variable est une hash False => La Variable n'est pas une hash SetError: (Non) #ce ---------------------------------------------------------------------------- Func _Hash_Verify(ByRef $hash) If StringLeft($hash, 1) == "{" And StringRight($hash, 1) == "}" Then Return True Else Return False EndIf EndFunc ;==>_Hash_Verify