|
Post by angelo2449 on Feb 18, 2019 23:50:48 GMT -5
OK now it works correctly even with double sizing (info $ - Info $). Later I try to enter the code in the biggest program, hopefully! I'll let you know.
|
|
|
Post by angelo2449 on Feb 19, 2019 0:10:28 GMT -5
Hi, It's crazy! In the program > Minimo.bas < works, in the larger one > Trasformer.bas < does not work, yet the two programs are similar! I would like to send you the program> Trasformer.bas <but it is too big to post.
|
|
|
Post by Rod on Feb 19, 2019 3:01:50 GMT -5
I would be pretty sure the problem is one of scope. Inside the function you must check all of the variables. You must also check that the global variables exist and carry the value you expect.. so stop the program inside the function and make sure the variables are all present and correctly set.
|
|
|
Post by angelo2449 on Feb 19, 2019 11:21:30 GMT -5
I tried everything! I also replaced the Info$ variable with InformazioneX$ thinking that frequent repetition of the words > Info < in the program could be harmful. As before, the result is always> 0 <. It can not be a memory problem, the PC (Intel i7) has 16 GB of RAM and a 1 TB SSd. The variables are set correctly. I know it's absurd but I think I'll have to change the logic of this verification.
|
|
|
Post by Rod on Feb 19, 2019 11:31:39 GMT -5
Look for the "obvious" stop thinking it is something exotic. The function has been proved to work in various guises by several contributors. So the function can work if called correctly with the correct information passed. The directory system does not change in between times. So your main program is either not calling the function, passing it wrong info, or not showing you the true result.
|
|
|
Post by Chris Iverson on Feb 19, 2019 11:43:09 GMT -5
Errors like this are often something very simple, but they're also often impossible for the original author to find, because you don't see what's actually there; you see what you expect to see. Every coder ever has run into this. You can often get better results letting someone else look over your code.
If your code is too big to paste here, try uploading it somewhere like Pastebin or Github and posting the link.
|
|
|
Post by angelo2449 on Feb 19, 2019 13:11:43 GMT -5
I solve the problem like this: The folder must contain a specific number of folders, so check this number. I have already tried and works correctly It's not exactly what I would like but that's okay too!
[LavoroEsistente]
files "D:\AltProvvisori\Angelo\", info$()
#main.test, "ris >>>>>> "; val(info$(0,1))
wait
|
|
|
Post by angelo2449 on Feb 19, 2019 13:31:00 GMT -5
This is the resolution of the problem. So I would say it's perfect, check the number of folders (8) and list the right ones!
[LavoroEsistente]
Cartella$ = "D:\AltProvvisori\Angelo\"
files Cartella$, info$()
if val(info$(0,1)) <> 9 then Notice "Attenzione" + chr$(13) + "Il numero delle Cartelle presenti in " + Cartella$ + " non è corretto." + chr$(13) +_ "Deve essere 8!" + chr$(13) +_ "Contatori" + chr$(13) +_ "DWG" + chr$(13) +_ "DXF" + chr$(13) +_ "GPS" + chr$(13) +_ "Libretti" + chr$(13) +_ "Immagini" + chr$(13) +_ "PF" + chr$(13) +_ "Varie" wait end if
|
|
|
Post by Rod on Feb 19, 2019 14:23:18 GMT -5
That went straight over the top of my head. Can you try explaining it again.
|
|
|
Post by angelo2449 on Feb 19, 2019 14:49:18 GMT -5
The purpose to check the existence of a folder (actually there are 8) inside a specific folder is precisely to make sure that the folders are all 8 present. With the last code I posted, I check that the folders are 8 and I propose a list of the 8 folders that must exist. It's more than enough!
|
|
|
Post by Rod on Feb 19, 2019 15:09:45 GMT -5
It is entirely possible to check for the existence of one specific folder. That’s what this discussion started with. So why can’t we do that?
|
|
|
Post by angelo2449 on Feb 19, 2019 18:23:58 GMT -5
The verification of a specific folder does not work! At least from me.
|
|
|
Post by Rod on Feb 20, 2019 3:58:58 GMT -5
Can you incorporate this function in your problematic program. It uses only info$() which needs dimmed at the very start of the program, we don't need the dirExists=0 as it is created=0 each time you enter the function. Can you post back here what it prints. Run it stand alone first to prove it works as is.
dim info$(10, 10) button #main.prova, "Esiste", [Esiste], UL, 20, 30, 100, 30 open "Prova" for window as #main #main, "trapclose [quit.Main]" wait
[Esiste] if dirExists("C:\basic", "bak") then Notice "Info" + chr$(13) + "Esiste!" end if wait
[quit.Main] close #main end
function dirExists(path$, dirname$)
files path$, chr$(0), info$() 'file name is invalid by design, so we get only folders print "Number of directories found =";info$(0,1)
If Val(info$(0,1)) > 0 Then For i = 1 To Val(info$(0,1)) print "seeking ";dirname$;" found directory ";str$(i);" ";info$(i,1) If info$(i, 1) = dirname$ Then dirExists = 1 Exit Function End If next end if
end function
Here is a run from my machine searching for directory "Bak", notice that it failed to find "Bak" but you had that covered in one of the examples you posted by forcing both to lower$().
Number of directories found =87
seeking Bak found directory 1 Adventure
seeking Bak found directory 2 AnalogLogger
seeking Bak found directory 3 AppEngineSkin
seeking Bak found directory 4 bak
seeking Bak found directory 5 Bass
seeking Bak found directory 6 BettyBoop
seeking Bak found directory 7 Bubbles
seeking Bak found directory 8 Camera
seeking Bak found directory 9 CarRace
seeking Bak found directory 10 Cheetah
seeking Bak found directory 11 Chess
seeking Bak found directory 12 ComplexGUI
seeking Bak found directory 13 Contests
seeking Bak found directory 14 Dance
seeking Bak found directory 15 DanTeal
seeking Bak found directory 16 Database
seeking Bak found directory 17 DennisActiveX
seeking Bak found directory 18 Doom
|
|
|
Post by angelo2449 on Feb 22, 2019 3:28:24 GMT -5
OK, this routine works! Grazie Rod. I have another problem, I hope you can give me good advice. Always with the same program, which works very well, when I go out, the last window is closed regularly but the LB editor freezes! Asking to provide the error I get Err $ = '' Err = 0, no error. I repeat the program works! Thank You.
|
|
|
Post by Rod on Feb 22, 2019 7:40:06 GMT -5
Your program isn't really closing its hanging, crashed. Check the error.log look carefully at the time to be sure you are looking at the correct entry. You must close all the resources that you opened prior to exiting. So if you opened any .dlls close them, close all windows. Also switch off the timer. Oh and you did end the program with END
|
|