Text Duplicates of the Item in a List Box or Dropdown List - Forum

Forum Navigation
You need to log in to create posts and topics.

Text Duplicates of the Item in a List Box or Dropdown List

Help, les Amis

After merging two .Txt files
file 1 and file 2 in a single file named 3 it is then transmitted to a List Box or a Drop-down List,
No problem, all the info in file 1 and file 2 can be found in file 3 in .Txt format
However, there may be duplicates. For example apple from file 1 and apple from file 2
We have 2 times apple in the Txt 3 file and therefore in the List Box or the Dropdown List. How to keep only one of the two duplicates in the 3.Txt file and in the List Box or the Dropdown List?
keep only once apple instead of apple apple.
Thank you for any directions or ideas ... I block

Claude GUYOT
NeoBook in French Version: 5.8.7

Doublons Text de l'Item dans une Zone de Liste ou Liste Déroulante

 

Help, Les Amis

Après avoir fusionné deux fichiers .Txt
le fichier 1 et le fichier 2 en un seul nommé 3 il est ensuite transmis dans une Zone de Liste ou une Liste Déroulante,
Pas de problème, toutes les infos du fichier 1 et du fichier 2 se retrouvent dans le fichier 3 au format .Txt
Par contre il peut y avoir des doublons. Par exemple pomme du fichier 1 et pomme du fichier 2
Nous avons 2 fois pomme dans le fichier Txt 3 et par conséquent dans la Zone de Liste ou la Liste Déroulante. Comment ne garder que un des deux doublons dans le fichier 3.Txt et dans la Zone de Liste ou la Liste Déroulante?
ne garder qu'une fois pomme au lieu de pomme pomme.
Merci pour toutes orientations ou idées ... Je bloque

@proforma-guyot

1) Load 1.txt into ListBox1

2) Load 2.txt into ListBox2

3) Try this ...

ListBoxSize "ListBox1" "[List1Size1]"

Loop 1 "[List1Size1]" "[thisItemNumber]"
   ...get text of currently examined item
   ListBoxGetItem "ListBox1" "[thisItemNumber]" "[thisItemText]"

   ... check for duplicate in ListBox2
   ListBoxFindItem "ListBox2" "[thisItemText]" "[matchingNumber]"
   If "[matchingNumber]" "<" "1"
      ... no match ; add to ListBox2
      ListBoxAddItem "ListBox2" "0" "[thisItemText]"
   EndIf
EndLoop

4) Now ListBox2 contains non-duplicated merge of two sets of lines ... you can create 3.txt like this ...

... empty file
FileWrite "3.txt" "1" ""

ListBoxSize "ListBox2" "[List2Size]"
Loop 1 "[List2Size]" "[thisItemNumber]"
   ...get text of currently examined item
   ListBoxGetItem "ListBox2" "[thisItemNumber]" "[thisItemText]"
   ... append to file
   FileWrite "3.txt" "0" "[thisItemText]"
EndLoop

Note: I have not verified this code ... may contain typo errors.

proforma.guyot has reacted to this post.
proforma.guyot

Good evening Gaev, CN_Iceman,
Good evening Members of the forum.

Thank you Gaev, it works very well.
Perfect answer and solution.

I went on another track, after merging the two files I accumulated duplicates ...

FileToVar "[PubDir]1.txt" "[ListBox1]"
FileWrite "[PubDir]3.txt" "All" "[ListBox1]"
FileToVar "[PubDir]2.txt" "[ListBox2]"
FileWrite "[PubDir]3.txt" "Append" "[ListBox2]"
.recover the contents of files 1 and 2 in 3
FileToVar "[PubDir]3.txt" "[ListBox3]"
... I couldn't keep one of the duplicates and delete the others
EndIf

Thank you CN_Iceman for your response to the thread.

Thank you for all of your help.
Looking forward to coming back to you.

Claude GUYOT
NeoBook in French Version: 5.8.7

CN_Iceman has reacted to this post.
CN_Iceman