dkl
Full Member
Posts: 234
|
Post by dkl on Aug 15, 2020 8:26:51 GMT -5
I would like to open a directory and load into an array$ (or simply display/print out) the names of the files. Is that possible? I have fiddled with files(), DefaultDir$ etc, but they don't seem to do what I want, although I was able to use files() to check for existing files Also, I am using Liberty4Help.pdf. Is there a more up to date Help file for LB 4.5.1? The new info about LB5 doesn't seem to help and none of my programs seem to work on LB5 in any case! ( Thank you for all the last queries that you responded to, it's much appreciated Regards
|
|
|
Post by alincon on Aug 15, 2020 11:11:11 GMT -5
This example handles three levels of directories
dim info$(10,10), info2$(10,10), info3$(10,10) path$ = "C:\libbas\_mylibbas\personnel\Departments"
files path$, info$( dfc = val(info$(0, 1)) ' dept folder count for cf = 1 to dfc foldName$ = info$(cf, 0) : print foldName$ files foldName$, info2$( sfc = val(info2$(0,1)) 'section folder count for cf2 = 1 to sfc fold2Name$ = info2$(cf2,0) : print fold2Name$ files fold2Name$, info3$( efc = val(info3$(0,0)) 'employee file count for cf3 = 1 to efc fileNameOld$ = fold2Name$ + "\" + info3$(cf3,0) next next next wait
|
|
dkl
Full Member
Posts: 234
|
Post by dkl on Aug 15, 2020 18:46:29 GMT -5
Many thanks for your assistance and the code enclosed.
I'm not quite sure what to expect on the running of this code. I have changed the path$ to reflect the drive/folder I wish to access. However, I receive limited info back when the programme is executed. I receive a couple of files from each directory
F:\_FILMS\Foreign\Foreign BMPs For example with this path$ I receive 0 files printed (There are 170 files and 0 Folders)
F:\_FILMS\Foreign Here I receive 1 file printed (There are 206 files and 1 Folder)
F:\_FILMS Here I receive 2 files printed (There are 725 files and 2 Folders)
F:\ Here I receive 7 files printed and '.dropbox.device'(?) (There are 30 files and 6 Folders)
I am assuming that the variables dfc,sfc,efc hold the clue, but I don't seem to receive the desired info. Perhaps you could enlighten me as to where I'm going wrong and what I am misunderstanding.
I did find that changing the value of dfc in the for/next loop printed out more files from F:\_FILMS\Foreign If I change dfc to 20 I got 20 files printed, but I don't think that's how its supposed to work is it?
I assume the code: dfc = val(info$(0, 1)) ' dept folder count is supposed to read the no, of files in the Directory - Am I correct? Changing sfc or efc didn't affect anything and reduced to 20 counted files to 1!
I assume we are both using LB 4.5.1?
I will read up on this more, but if you could throw a bit more light on this I would much appreciate it. Thanks
|
|
|
Post by alincon on Aug 15, 2020 20:17:54 GMT -5
Try changing fileNameOld$ = fold2Name$ + "\" + info3$(cf3,0)
to fileName$ = info3$(cf3,0) 'print fileName$
I may not have it exactly right myself Nested files statements are tricky
Also, your file structure may be different from mine - that may be why it is not working
r.m.
|
|
dkl
Full Member
Posts: 234
|
Post by dkl on Aug 15, 2020 23:20:02 GMT -5
Hmm... gave that a go, but didn't get any joy. Not sure I understand what you mean by 'your file structure may be different from mine'? Mine is only 3 deep, where as yours is 4. Anyhow I can see the commands you have used, so will play around with it.
Thanks for your help:)
|
|
|
Post by Rod on Aug 16, 2020 8:36:14 GMT -5
|
|
dkl
Full Member
Posts: 234
|
Post by dkl on Aug 21, 2020 0:21:09 GMT -5
Thank you for the above advice - I always forget about Alyce's website! It's packed with so much help and excellent tutorials!
Could someone kindly explain how can I wordwrap txt in a Textbox or listbox? i.e make a long sentence go to a new line rather than continue off the screen. Can I do this? I have seen how to restrict the no. of characters in a 'field', but couldn't find anything about Textboxes/Listboxes.
|
|
|
Post by metro on Aug 21, 2020 1:16:53 GMT -5
Thank you for the above advice - I always forget about Alyce's website! It's packed with so much help and excellent tutorials! Could someone kindly explain how can I wordwrap txt in a Textbox or listbox? i.e make a long sentence go to a new line rather than continue off the screen. Can I do this? I have seen how to restrict the no. of characters in a 'field', but couldn't find anything about Textboxes/Listboxes.
There maybe something useful in those
|
|
dkl
Full Member
Posts: 234
|
Post by dkl on Aug 21, 2020 5:52:59 GMT -5
Since writing the above message I have found info on the use of stylebits at Alyces Reataurant I tried the statement below but it doesn't seem to work for me. I tried using it in a 'window' and a 'dialog' I also found this libertybasiccom.proboards.com/thread/574/word-wrap-text-editor-control, but didn't seem to help either stylebits #main3.textbox.Syn, _ES_MULTILINE, 0, 0, 0 textbox #main3.textboxSyn, 10, 10, 350, 50 Some help would be appreciated, please:)
|
|
|
Post by Brandon Parker on Aug 21, 2020 8:21:48 GMT -5
When you have new questions please feel free to create a new thread that way people searching for specific answers and find solutions easier.
It looks like you have an extra period in your TextBox handle name.
You have this ...
stylebits #main3.textbox.Syn, _ES_MULTILINE, 0, 0, 0 textbox #main3.textboxSyn, 10, 10, 350, 50
Is it supposed to be this ... ?
stylebits #main3.textboxSyn, _ES_MULTILINE, 0, 0, 0 textbox #main3.textboxSyn, 10, 10, 350, 50 The handle name that is provided to create the control is the exact one you want to use to specify its StyleBits.
{:0)
Brandon Parker
|
|
dkl
Full Member
Posts: 234
|
Post by dkl on Aug 21, 2020 18:38:05 GMT -5
Thank you for your help. Yes I will start a new post in future. The change in the textbox name didn't help unfortunately. Below is and example of what I have at the moment. It runs perfectly ok, but no word wrap. Of course, I could in this instance split up the 'Synopsis' in the programming, but that won't help within the main prgramme.
Dim Synopsis$(10) Synopsis$(0)="A naive young man assumes a dead man's identity and finds himself embroiled in an underground world of power, violence, and chance where men gamble behind closed doors on the lives of other... See more '" index=0 Nomainwin WindowWidth = 450 WindowHeight = 200 UpperLeftX=int((DisplayWidth-WindowWidth)/2) UpperLeftY=int((DisplayHeight-WindowHeight)/2)
stylebits #main3.textboxSyn, _ES_MULTILINE, 0, 0, 0 textbox #main3.textboxSyn, 10, 10, 410, 75
button #main3.ok, "Close", [quit.main],LL, 10, 10, 50,50
open "Synopsis" for window as #main3 print #main3, "font ms_sans_serif 10 Bold" print #main3, "trapclose [quit.main]"
print #main3.textboxSyn,Synopsis$(index)', 13, ";")'Synopsis$(1)'FNData$(fd) wait
[quit.main] close #main3 end
Any suggestions? Thanks
|
|
dkl
Full Member
Posts: 234
|
Post by dkl on Aug 21, 2020 18:40:13 GMT -5
please ignore this bit ', 13, ";")'Synopsis$(1)'FNData$(fd) it's REMmed out!
|
|
|
Post by Brandon Parker on Aug 21, 2020 20:23:50 GMT -5
The ES_MULTILINE style for an Edit Control does not automatically force the text to word-wrap if the text is longer than the length of the control, it simply allows the Edit Control to accept more than one line of text since the Edit Controls only allow single-line text by default. You would need to insert the CR/LF pair (... chr$(13) + chr$(10) ...) to cause the text to start a new line.
Dim Synopsis$(10)
Global CRLF$ : CRLF$ = chr$(13);chr$(10) Synopsis$(0)= "A naive young man assumes a dead man's identity and ";CRLF$; _ "finds himself embroiled in an underground world of power, ";CRLF$; _ "violence, and chance where men gamble behind closed ";CRLF$; _ "doors on the lives of other... See more '" index = 0 NoMainWin WindowWidth = 450 WindowHeight = 200 UpperLeftX = Int((DisplayWidth - WindowWidth)/ 2) UpperLeftY = Int((DisplayHeight - WindowHeight)/ 2)
StyleBits #main3.textboxSyn, _ES_MULTILINE, 0, 0, 0 TextBox #main3.textboxSyn, 10, 10, 410, 75 Button #main3.ok, "Close", [quit.main], LL, 10, 10, 50,50
Open "Synopsis" For Window As #main3 #main3 "Font MS_Sans_Serif 10 Bold" #main3 "TrapClose [quit.main]"
#main3.textboxSyn, Synopsis$(index) Wait
[quit.main] Close #main3 End
{:0)
Brandon Parker
|
|
dkl
Full Member
Posts: 234
|
Post by dkl on Aug 24, 2020 17:45:01 GMT -5
Thanks Metro - That article from an old newsletter was very useful!
|
|
dkl
Full Member
Posts: 234
|
Post by dkl on Aug 27, 2020 8:03:18 GMT -5
tsh73 - you sent me that really nice code to show me how to grab the handler$ info for a button, but I have to admit I am still confused about it so is there a way I can click the button and retrieve the info WITHOUT out using /call/sub routine? I just want to Click a button get the info and continue onto the Search part of the routine.
Click > Get info > search based on info....Done! click button A > goto or gosub [info] > put info into array$ > goto search " find info based on A
I don't know why but it doesn't seem to work for me as a call/sub. When I leave the call/sub i lose the info and if I name the array$ as a Global it doesn't work either!
|
|