Bonjour,
Faudrait donner un peu plus de détail :
Primo : "1,2,Ch parents,Ch Bureau"
Le "1" veut dire quoi ? Un guess, c'est le numéro d'index, il commence toujours à "1" ?
Le "2" veut dire quoi ? Un guess, c'est le nombre de commentaire (le maximum est connu ? il varie entre 0, 1 et 2 ? ...)
Le "Ch parents" c'est une chaîne de caractères ?
Le "Ch Bureau" c'est une chaîne de caractères ?
Deusio : "254,1, Temp Ch Parent"
Le "254" c'est le dernier élément dans le fichier ? La liste continu au-delà de 254 ?
Tersio : Le premier numéro de chaque ligne (Guess que c'est le numéro d'index) est toujours dans l'ordre. On ne risque pas d'avoir le "1" suivit du "30" suivit du "2" suivit du "80" ?
-------------------------------------------------------------------------------------------------------------------------
On met l'hypothèse que le fichier texte est comme ceci :
adresse;nombre;comment1;comment2.... comment'nombre'
1,2,Ch parents,Ch Bureau
2,2,Ch A,Ch B
3,2,Salon, Cuisine
4,1,Lampe Salon
5,1,Temp Cuisine
Le code pour le charger dans une liste donne un truc du genre :
Code : Tout sélectionner
; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
; CODE GÉNÉRÉ AUTOMATIQUEMENT, NE PAS MODIFIER À
; MOINS D'AVOIR UNE RAISON TRÈS TRÈS VALABLE !!!
; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
; Code généré par : Dev-Type V3.88.467
; Nom du projet : Le nom du projet ici
; Nom du fichier : Nom du fichier
; Version du fichier : 0.0.0
; Programmation : À vérifier
; Programmé par : Guimauve
; Date : 27-11-2011
; Mise à jour : 27-11-2011
; Codé pour PureBasic V4.60
; Plateforme : Windows, Linux, MacOS X
; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
; <<<<< Déclaration de la Structure <<<<<
Structure Comment
List Liste.s()
EndStructure
; <<<<<<<<<<<<<<<<<<<<<<<<<<<<
; <<<<< Les observateurs <<<<<
Macro GetCommentListe(CommentA)
CommentA\Liste()
EndMacro
; <<<<<<<<<<<<<<<<<<<<<<<<<
; <<<<< Les mutateurs <<<<<
Macro SetCommentListe(CommentA, P_Liste)
GetCommentListe(CommentA) = P_Liste
EndMacro
; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
; <<<<< Les macros complémentaires pour les Listes chaînées <<<<<
Macro AddCommentListeElement(CommentA)
AddElement(GetCommentListe(CommentA))
EndMacro
Macro AddCommentListeElementEx(CommentA, P_Element)
AddElement(GetCommentListe(CommentA))
SetCommentListe(CommentA, P_Element)
EndMacro
Macro InsertCommentListeElement(CommentA)
InsertElement(GetCommentListe(CommentA))
EndMacro
Macro InsertCommentListeElementEx(CommentA, P_Element)
InsertElement(GetCommentListe(CommentA))
SetCommentListe(CommentA, P_Element)
EndMacro
Macro SelectCommentListeElement(CommentA, Position)
SelectElement(GetCommentListe(CommentA), Position)
EndMacro
Macro PreviousCommentListeElement(CommentA)
PreviousElement(GetCommentListe(CommentA))
EndMacro
Macro NextCommentListeElement(CommentA)
NextElement(GetCommentListe(CommentA))
EndMacro
Macro FirstCommentListeElement(CommentA)
FirstElement(GetCommentListe(CommentA))
EndMacro
Macro LastCommentListeElement(CommentA)
LastElement(GetCommentListe(CommentA))
EndMacro
Macro PopListCommentListePosition(CommentA)
PopListPosition(GetCommentListe(CommentA))
EndMacro
Macro PushListCommentListePosition(CommentA)
PushListPosition(GetCommentListe(CommentA))
EndMacro
Macro DeleteCommentListeElement(CommentA, Flag = 0)
DeleteElement(GetCommentListe(CommentA), Flag)
EndMacro
Macro ListCommentListeSize(CommentA)
ListSize(GetCommentListe(CommentA))
EndMacro
Macro ResetCommentListe(CommentA)
ResetList(GetCommentListe(CommentA))
EndMacro
Macro ListCommentListeIndex(CommentA)
ListIndex(GetCommentListe(CommentA))
EndMacro
Macro ClearCommentListe(CommentA)
ClearList(GetCommentListe(CommentA))
EndMacro
; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
; <<<<< Macro de déboguage <<<<<
Macro DebugComment(CommentA)
ForEach GetCommentListe(CommentA)
Debug "Liste : " + GetCommentListe(CommentA)
Next
EndMacro
; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
; <<<<< Code généré en : 00.002 secondes (78500.00 lignes/seconde) <<<<<
; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
; <<<<< L'opérateur de chargement <<<<<
Procedure ReadCommentListe(FileName.s, List CommentA.Comment())
If ReadFile(0, FileName)
While Eof(0) = 0
Line.s = Trim(ReadString(0))
If Val(StringField(Line, 1, ",")) <> 0
AddElement(CommentA())
CommentCount = 2 + Val(StringField(Line, 2, ","))
For CommentID = 3 To CommentCount
AddCommentListeElementEx(CommentA(), Trim(StringField(Line, CommentID, ",")))
Next
EndIf
Wend
CloseFile(0)
Else
MessageRequester("Information","Impossible d'ouvrir le fichier!")
EndIf
EndProcedure
; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
; <<<<< !!! WARNING - YOU ARE NOW IN A TESTING ZONE - WARNING !!! <<<<<
; <<<<< !!! WARNING - THIS CODE SHOULD BE COMMENTED - WARNING !!! <<<<<
; <<<<< !!! WARNING - BEFORE THE FINAL COMPILATION. - WARNING !!! <<<<<
; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
NewList Adresse.Comment()
ReadCommentListe("fichier", Adresse())
ForEach Adresse()
DebugComment(Adresse())
Debug ""
Next
; <<<<<<<<<<<<<<<<<<<<<<<<<<
; <<<<< FIN DU FICHIER <<<<<
; <<<<<<<<<<<<<<<<<<<<<<<<<<
Débogueur a écrit :Liste : Ch parents
Liste : Ch Bureau
Liste : Ch A
Liste : Ch B
Liste : Salon
Liste : Cuisine
Liste : Lampe Salon
Liste : Temp Cuisine
A+
Guimauve