PDA

View Full Version : to keep several items from listbox to txt


Solmos
01-05-2007, 09:22 AM
hello,

pardon by my ingles

I have listbox, with I number indefinit of items, each beginning can be I number different (perhaps 8 items and following the 20 items... etc)

And gustaria me to include a button that has scrip to keep the list from items (the text) in txt.

Example:

My listbox

a
b
c
d
etc...

and that to keep it in txt.

some suggestion?

thank you very much to all

Solmos
01-05-2007, 11:26 AM
please help!

Eliminator
01-05-2007, 12:03 PM
Try this, but it is very basic

TextToWrite = ""
nbOfLines = ListBox.GetCount("ListBox1");
-- A repeat ... until loop
numLoopCount = 1;
repeat
-- Do something here
Text = ListBox.GetItemText("ListBox1", numLoopCount);
if TextToWrite ~= "" then
TextToWrite = TextToWrite .. "\r\n" .. Text
else
TextToWrite = Text
end
numLoopCount = numLoopCount + 1;
until numLoopCount == nbOfLines + 1;
TextFile.WriteFromString("C:\\MyFile.txt", TextToWrite, false);

Good luck,
Eliminator

azmanar
01-05-2007, 01:14 PM
Hi SOlmos,

Ejemplos adentro aquí (http://azman.info/ams).

Búsqueda para:

>>> AMS 6 [ TEXT FILE ] Examples.
* LIST BOX to TEXT FILE
- Import ListBox Data to Text File
- View Text File

Solmos
01-05-2007, 09:38 PM
thank you very much Eliminator it works very well

thanks azmanar for the examples, very utiles, you are the best ones!

another question

I like now to know to do operation inverse, that is to say, to look for file txt in system and what contains that is in the ListBox, of this form:

content of txt:
a
b
c
etc...

Content shown in listbox:

a
b
c
etc..

and by I complete, to compare the two text of listbox, considering that can be the same one in I do not number of items, asi then, if an item not this present, that is a message.

pardon therefore to bother, I thank for much thank you very much to you the aid!

Solmos
01-07-2007, 09:42 AM
thank you very much Eliminator it works very well

thanks azmanar for the examples, very utiles, you are the best ones!

another question

I like now to know to do operation inverse, that is to say, to look for file txt in system and what contains that is in the ListBox, of this form:

content of txt:
a
b
c
etc...

Content shown in listbox:

a
b
c
etc..

and by I complete, to compare the two text of listbox, considering that can be the same one in I do not number of items, asi then, if an item not this present, that is a message.

pardon therefore to bother, I thank for much thank you very much to you the aid!

Help please!

Solmos
01-08-2007, 09:56 AM
some suggestion please?

azmanar
01-08-2007, 10:39 AM
Hi Solmos,

I assume you want to check whether an item in LISTBOX has the same item in the TEXT FILE.

It depends on how you Grab the txt file. It can be into a STRING VARIABLE or TABLE.

Say you grab the text file contents into a STRING VARIABLE. You use TextFile.ReadToString . Say, you name this variable as sText.

Then you need to read each item in the ListBox using the loop FOR..DO. Everytime you read the item in the ListBox, you make into a STRING VARIABLE. Say, you name this item as sLB_Text. In the FOR..DO, use sLB_Text= ListBox.GetItemText("ListBox1", sLBitem );

Within the same step ( in the loop ), you check sLB_Text in the string sText by using nFound = String.Find(sText, sLB_Text, 1, false).

then use the IF...THEN.

if nFound~=-1 then
Dialog.Message("FOUND!", "There is an item found in the text file", MB_RETRYCANCEL);
else
Dialog.Message("NOT FOUND!", "No item in the text file", MB_RETRYCANCEL);
end

Actually it is very flexible on how you want to it to happen, even to the collect the items found in the listbox into another listbox or do many other things in the FOR...DO loop.

Try do it. If after many tries you cannot do it, message me.

Solmos
01-09-2007, 02:22 AM
azmanar please, one example complete of the scrip, please!!

the text document has east format:

text:
aaaa
bbbb
cccc

and in listbox for example:

aaaa
kkkk
bbbb

desire to verify if the data of the text document estan present in listbox and that it says to me if each one of them exists or no. muchasa thanks!

thx!!

Solmos
01-09-2007, 02:40 AM
azmanar please, one example complete of the scrip, please!!

the text document has east format:

text:
aaaa
bbbb
cccc

and in listbox for example:

aaaa
kkkk
bbbb

desire to verify if the data of the text document estan present in listbox and that it says to me if each one of them exists or no. muchasa thanks!

this is my scrip:

aa = Dialog.FileBrowse(true, "select document", _DesktopFolder, "document .txt (*.txt)|*.txt|", "", "txt", false, false);
error = Application.GetLastError();

if error ~= 0 then
Dialog.Message("Error",_tblErrorMessages[error]);
else
if (aa == nil) then
Dialog.TimedMessage("Error", "NONE", 3000, MB_ICONINFORMATION);
else

for index, sLBitem in aa do
sText = TextFile.ReadToTable(path);
sLB_Text = ListBox.GetItemText("ListBox2", sLBitem);
nFound = String.Find(sText, sLB_Text, 1, false)
if nFound~=-1 then
Dialog.Message("FOUND!", "There is an item found in the text file", MB_RETRYCANCEL);
else
Dialog.Message("NOT FOUND!", "No item in the text file", MB_RETRYCANCEL);
end

end
end
end

I need that it says when verifying the text to me in txt all the archives that exist and all those that do not exist

Solmos
01-11-2007, 05:39 PM
please help!