About Listbox - Forum

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

About Listbox

Hello to the community,

I have a listbox that is having 4 list items. And I try to save it all the list items to a file as a variable and then everytime I want to read the file and all items list it to the list box with the Loadvariable function.

I must say that in file is having and others variable so it is not possible to have only the listbox items.

Best regards

@sakismor

It is not clear what you are trying to do ... perhaps you can post the various pieces of your code here.

 

 

 

I

Please check the code that is having a button. I just pick some variables and I am write it to a file. And from the Listbox try to get all the data with a loop and I put the special character [#13] to change the line.

 

FileWrite "[PubDir]data\[PICKYEAR]-[PICKMONTH]-[PICKDAY].cal" "All" ""

FileWrite "[PubDir]data\[PICKYEAR]-[PICKMONTH]-[PICKDAY].cal" "Append" "K30Car=[K30Car]"
FileWrite "[PubDir]data\[PICKYEAR]-[PICKMONTH]-[PICKDAY].cal" "Append" "K30TimeIn=[K30TimeIn]"
FileWrite "[PubDir]data\[PICKYEAR]-[PICKMONTH]-[PICKDAY].cal" "Append" "K30TimeOut=[K30TimeOut]"
FileWrite "[PubDir]data\[PICKYEAR]-[PICKMONTH]-[PICKDAY].cal" "Append" "K30YesNo=[K30YesNo]"
ListBoxSize "K30ListBox" "[ListBoxNum]"
Loop "1" "[ListBoxNum]" "[ListBoxNumlock]"
ListBoxGetItem "K30ListBox" "[ListBoxNumlock]" "[ListBoxGet]"
SetVar "[YPALLHLOI]" "[YPALLHLOI][ListBoxGet][#13]"
endloop
FileWrite "[PubDir]data\[PICKYEAR]-[PICKMONTH]-[PICKDAY].cal" "Append" "K30YPALLHLOI=[YPALLHLOI]"
SetVar "[YPALLHLOI]" ""

But the file that I make the listbox items is all together without the special character to split them. Please check the file that made it.

K30Car=ΠΣ1332 ( 2.5 TN)
K30TimeIn=21:30
K30TimeOut=08:00
K30YesNo=ΝΑΙ
K30YPALLHLOI=ΟΔΗΓΟΣ  ΠΥΡΓΟΣ (12863) ΑΔΑΜΟΥ ΧΡΥΣΟΥΛΑ ΤΗΛ 6947273787
ΟΔΗΓΟΣ  ΠΥΡΓΟΣ (12863) ΑΔΑΜΟΥ ΧΡΥΣΟΥΛΑ ΤΗΛ 6947273787
ΟΔΗΓΟΣ  ΠΥΡΓΟΣ (12863) ΑΔΑΜΟΥ ΧΡΥΣΟΥΛΑ ΤΗΛ 6947273787

 

@sakismor

The problem here appears to be line 10 ... in Windows text files, a new line is represented by a carriage return ([#13]) and a line feed ([#10]) ... so try this ...

SetVar "[YPALLHLOI]" "[YPALLHLOI][ListBoxGet][#13][#10]"

Alternatively, if the ListBox does not have hundreds of items you can just do a FileWrite (Append) of each item in the ListBox ... do this before the loop ...

FileWrite "[PubDir]data\[PICKYEAR]-[PICKMONTH]-[PICKDAY].cal" "Append" "K30YPALLHLOI=[#13][#10]"

... replace line 10 with ...

FileWrite "[PubDir]data\[PICKYEAR]-[PICKMONTH]-[PICKDAY].cal" "Append" "[ListBoxGet]"

... and of course, remove line 12.

Download Pub at http://www.bgmstudio.co.za

Greetings