Hi,
I want to fill a listbox with filenames from the default directory. The filenames I want to
appear will all start with "6.1"
I don't know how many there will be, so I can't use a loop, and I don't know if there will
be any there at all when I activate the listbox (which is in a dialog at the moment)
Had a search, but didn't find anything. Could do with some help...
Brian
			
			
			
				This should help you get started:
'create your listbox here
'blah...blah
'determine your default directory
'blah blah
istring mydefaultdir="c:\\"
DEF dir:INT
DEF filename:STRING
dir = FINDOPEN(mydefaultdir+"6.1*.*")
IF(dir)
    DO
        filename = FINDNEXT(dir)
        if filename <>""
            ADDSTRING mydlg, mylistbox, filename
       endif
    UNTIL filename = ""
    FINDCLOSE dir
ENDIF
LarryMc
			
			
			
				Larry,
It did get me going - and now I can't go to bed until I finish it!
Thanks,
Brian
			
			
			
				Hi...
Is there a way to load txt file cca 100kB to Listbox on fast way?
I know that listbox need sequential inserting or adding but maybe some
have another solution.
Aurel
			
			
			
				OK..here is what i made .
Program load txt file into Listbox.
window w1
int c
string i$,l$,filename
file file1
OPENWINDOW w1,0,0,790,400,@minbox,0,"Load from file",&main
SETWINDOWCOLOR w1,rgb(220,220,226)
CONTROL w1,@sysbutton,"Load",4,4,80,20,0,1
CONTROL w1,@LISTBOX,"",4,24,776,330,@HSCROLL,2
'SETHORIZEXTENT w1, 2, 100
SETCONTROLCOLOR w1,2,RGB(240,230,0),RGB(0,0,0)
SETFONT w1,"Courier New",9,400,0,2
WAITUNTIL w1=0
END
SUB main
	SELECT @MESSAGE
'***********************************************
		CASE @IDCREATE
			CENTERWINDOW w1
'**********************************************			
		CASE @IDCLOSEWINDOW
			CLOSEWINDOW w1
'**********************************************
		CASE @IDCONTROL
'--------------------------------------------
		IF @controlid=1
			LoadToListbox()
		ENDIF
'--------------------------------------------
'**********************************************
	ENDSELECT
RETURN
ENDSUB
SUB LoadToListbox()
	c=0
	filename="archive.txt"
	OPENFILE(file1,filename,"R")
		WHILE EOF(file1)=0
			Read(file1,i$)
			INSERTSTRING w1,2,c,i$
			c=c+1
		WEND
	CLOSEFILE file1
RETURN
ENDSUB
Hmm
I don't know why horizontal scrollbar is not visible?
			
			
			
				Aurel,
You better make sure your string variable is large enough to hold a full line
Got the horizontal scrollbar working in this example, and added a bit of assembly
in there to speed things up
Brian
			
			
			
				Hi Brian..
Thanks on help.
I made mistake in :
SETHORIZEXTENT w1, 2,100
which is not enough ,that's why i don't see horizontal scrollbar ::)
In my case size of line is not bigger then 255 chars so ordinary string is ok
but your point is good because istring is better option. ;)
Aurel