Author |
Topic: File exists (Read 985 times) |
|
MrStreet
New Member
member is offline


Posts: 8
|
 |
Re: File exists
« Reply #5 on: Jun 7th, 2011, 9:12pm » |
|
Quote:| What is different between the first and second times? |
|
The decision is made in this procedure...
Code: defproc_checkSetup
rem checks that the user has a folder in my documents
DOC$ = fn_specialFolder(5)
if fn_folderExists( DOC$+"\My_"+GAME_NAME$+"_Projects" ) then
rem do nothing
else
rem make projects folder
oscli "MKDIR """+DOC$+"\My_"+GAME_NAME$+"_Projects"+""""
rem inform user
proc_OK("It looks like you are running "+GAME_NAME$+" for the first time on this computer. I have created"\
\+" a new folder:"+LF$+LF$+DOC$+"\My_"+GAME_NAME$+"_Projects"+LF$+LF$+"I will save your embedded video files there.")
endif
endproc
Quote:| Is your colleague running the 64-bit version of Windows 7 or the 32-bit version, and which version are you running? |
|
I am running 64. I think he is using 32 (but could be wrong). He is running on a network drive, mine is a stand-alone C: drive.
Quote:| You might want to create a special 'debug' version of your program |
|
Yes, have been building it with on error local commands in each procedure. Will test it out tomorrow on the networked machines and see what's what. Thanks again for your kind help as ever.
|
|
Logged
|
|
|
|
admin
Administrator
member is offline


Posts: 1145
|
 |
Re: File exists
« Reply #6 on: Jun 7th, 2011, 10:14pm » |
|
on Jun 7th, 2011, 9:12pm, MrStreet wrote: Code:oscli "MKDIR """+DOC$+"\My_"+GAME_NAME$+"_Projects"+"""" |
|
*MKDIR will result in the 'File exists' error if the directory already exists, so given the symptom, and the fact that it happens only on the second run, it suggests to me that FN_folderExists is returning FALSE even though the directory does exist. You might want to check whether GAME_NAME$ contains any illegal characters (i.e. characters that are not allowed in a directory name) because that could cause the observed effect.
Incidentally DOC$ in your code would appear to be identical to the built-in 'system' variable @usr$.
Richard.
|
|
Logged
|
|
|
|
MrStreet
New Member
member is offline


Posts: 8
|
 |
Re: File exists
« Reply #7 on: Jun 8th, 2011, 4:32pm » |
|
Quote:| ...check whether GAME_NAME$ contains any illegal characters... |
|
This shouldn't create an illegal folder name, should it?
Code: GAME_NAME$ = "You Tube Video Cleaner"
I haven't had chance to try the updated (debug) version on the networked machines yet, but deleting the folder created by PROC_checkSetup (my documents\My_You Tube Video Cleaner_Projects) fixes the problem (until you run it again). The program stills works as expected on my stand-alone machine.
I am very confused. The ability to create a folder when the program first runs, and then using it to save files to would be very handy, although I could create a work-around.
|
|
Logged
|
|
|
|
admin
Administrator
member is offline


Posts: 1145
|
 |
Re: File exists
« Reply #8 on: Jun 8th, 2011, 5:39pm » |
|
on Jun 8th, 2011, 4:32pm, MrStreet wrote:| The ability to create a folder when the program first runs, and then using it to save files to would be very handy |
|
You can definitely do that (at the risk of repeating myself, you can do virtually anything that is possible in Windows, since BBC BASIC for Windows is a general purpose programming language).
Even if you cannot get your existing code to work there are straightforward workarounds such as creating the folder using SYS "CreateDirectory", which doesn't fail if it already exists.
But ideally you should find out why the current code isn't working, since that might point to a more fundamental issue with your program.
Quote:| I haven't had chance to try the updated (debug) version on the networked machines yet |
|
Networked machines? Have you mentioned that before? If the folder you're testing for is on a network server running an 'unusual' filing system (e.g. SAMBA), then maybe relying on the file NUL existing in every directory isn't valid.
Richard.
|
|
Logged
|
|
|
|
MrStreet
New Member
member is offline


Posts: 8
|
 |
Re: File exists
« Reply #9 on: Jun 8th, 2011, 5:42pm » |
|
Can't I create the NUL file using the usual OPENOUT and put it into the projects folder when the program creates it the first time?
|
|
Logged
|
|
|
|
admin
Administrator
member is offline


Posts: 1145
|
 |
Re: File exists
« Reply #10 on: Jun 8th, 2011, 8:17pm » |
|
on Jun 8th, 2011, 5:42pm, MrStreet wrote:| Can't I create the NUL file using the usual OPENOUT and put it into the projects folder when the program creates it the first time? |
|
You can't create a NUL file - it's a forbidden file name. But since you are wanting to test for the existence of a directory which you have created yourself, why not simply store a file there specifically for the purpose? Because you know that file will always be there, you can simply test for it being present - you don't actually need to test for the existence of the directory itself!
Richard.
|
|
Logged
|
|
|
|
MrStreet
New Member
member is offline


Posts: 8
|
 |
Re: File exists
« Reply #11 on: Jun 8th, 2011, 8:19pm » |
|
Many thanks again, Richard.
|
|
Logged
|
|
|
|
MrStreet
New Member
member is offline


Posts: 8
|
 |
Re: File exists
« Reply #12 on: Jun 11th, 2011, 11:24am » |
|
I think I have fixed the problem using an on error local statement call to :-
Code:
deffn_setupError
if err=196 then
rem file exists error
= false
else
if fn_FAULT_M(" I am sorry the following error occured during setup: "+LF$+LF$+report$+LF$+LF$+" Do you want to quit?") then
= true
else
=false
endif
endif
|
|
Logged
|
|
|
|
|