Categories: MSDN / DotNet / Java / Scripts / Linux / PHP Ask - La ask - La Answer

Use diskspace("a:")

I use the function diskspace("A:") to know if a disk is ready or not.
When my colleague uses this function he gets -1 as a result if there is no
disk in the drive.
But when I use this function I always get a messagebox with the message :
there is no disk in the drive. Please insert disk into drive A:
We both use windows 2000. we both use and vfp 7.

I checked the settings in foxpro and they look the same. How can I avoid
this messagebox ?
Why is it showing on my pc and not on another ?
[526 byte] By [Anne-Mie] at [2007-11-10 12:49:35]
# 1 Re: Use diskspace("a:")
"Anne-Mie" <amv@advalvas.be> schrieb im Newsbeitrag
news:3ecccd0a$1@tnews.web.dev-archive.com...
>
> I use the function diskspace("A:") to know if a disk is ready or not.
> When my colleague uses this function he gets -1 as a result if there is no
> disk in the drive.
> But when I use this function I always get a messagebox with the message :
> there is no disk in the drive. Please insert disk into drive A:
> We both use windows 2000. we both use and vfp 7.
>
> I checked the settings in foxpro and they look the same. How can I avoid
> this messagebox ?

Try SetErrorMode(), for example
Declare integer SetErrorMode in Win32API integer lnMode
nPrevious = SetErrorMode(1)
nRetVal = DISKSPACE("A:") && no messagebox
SetErrorMode(m.nPrevious) && restore previous
Return m.nRetVal

> Why is it showing on my pc and not on another ?

I'd like to know that, too. For me the messagebox always
appears (as long as SetErrorMode=0, tested on various PCs
with W2k and WinXP, English and German versions) while
other people reported the opposite.
Just a wild guess, do you have MS Office installed on one
and not on the other box?

hth
-Stefan
Stefan Wuebbe at 2007-11-11 23:50:52 >
# 2 Re: Use diskspace("a:")
Hello, Stefan!
You wrote on Fri, 23 May 2003 09:25:25 +0200:

I remember a discussion on this same subject we had in Feb 2003. I still
have not found an answer to the question why some people get the OS
errormessage. Anyway, Roger Ansell posted this code:

oFSO=CREATEOBJECT("Scripting.Filesystemobject")
oDrive=oFSO.GetDrive("A")
IF oDrive.Isready
* drive has a disk
ELSE
* drive does not have a disk
ENDIF

Maybe somebody else can use it if the DISKSPACE() and SetErrorMode don't
work. (duh not even sure the FileSystemObject displays this dialog too).
--
Eric den Doop
www.foxite.com - The Home Of The Visual FoxPro Experts - Powered By VFP8
Eric den Doop at 2007-11-11 23:51:57 >
# 3 Re: Use diskspace("a:")
Hi Eric

"Eric den Doop" <ericdendoop@xspamblockxfoxite.com> schrieb im Newsbeitrag
news:3ecdcf6d@tnews.web.dev-archive.com...
....
> I remember a discussion on this same subject we had in Feb 2003. I still
> have not found an answer to the question why some people get the OS
> errormessage. Anyway, Roger Ansell posted this code:
> oFSO=CREATEOBJECT("Scripting.Filesystemobject")
> oDrive=oFSO.GetDrive("A")
> IF oDrive.Isready
> * drive has a disk
> ELSE
> * drive does not have a disk
> ENDIF
> Maybe somebody else can use it if the DISKSPACE() and SetErrorMode don't
> work. (duh not even sure the FileSystemObject displays this dialog too).

No, it does not (at least for me and that I've heard).
Still curious though, especially as WSH might not be an option
on every customer's machine...

BTW, Roger also never gets a messagebox with diskspace(),
just like Fred and you.
I'll try the MSOffice SWAG later today.

-Stefan
Stefan Wuebbe at 2007-11-11 23:52:56 >
# 4 Re: Use diskspace("a:")
Windows registry seems to be it
HKLM\System\CurrentControlSet\Control\Windows\ErrorMode

0x0 is 'on' (default)
gives a messagebox for Diskspace('a') or when typing "a:"
at the command prompt for example.

0x2 is messagebox-off
So one can set it manually, e.g. via Start / Run / regedit
or programatically. e.g. using Home()+'registry.prg'
to get a persistent setting.
Or via SetErrorMode() as described above to change it locally
for the current process.

Could not reproduce any unintended changes though
during a setup from scratch: WinXP, chipset + video drivers,
Vfp7, SP1, Visual Studio .Net, SP1 for XP, MSOffice10 + SPs,
Vfp8

-Stefan
Stefan Wuebbe at 2007-11-11 23:53:55 >
# 5 Re: Use diskspace("a:")
Hello, Stefan!
You wrote on Sat, 24 May 2003 19:49:14 +0200:

SW> 0x0 is 'on' (default)
SW> gives a messagebox for Diskspace('a') or when typing "a:"
SW> at the command prompt for example.

SW> 0x2 is messagebox-off
SW> So one can set it manually, e.g. via Start / Run / regedit
SW> or programatically. e.g. using Home()+'registry.prg'
SW> to get a persistent setting.
SW> Or via SetErrorMode() as described above to change it locally
SW> for the current process.

SW> Could not reproduce any unintended changes though
SW> during a setup from scratch: WinXP, chipset + video drivers,
SW> Vfp7, SP1, Visual Studio .Net, SP1 for XP, MSOffice10 + SPs,
SW> Vfp8

Hey thanks Stefan. Any idea where this option can be set in Windows?
--
Eric den Doop
www.foxite.com - The Home Of The Visual FoxPro Experts - Powered By VFP8
Eric den Doop at 2007-11-11 23:54:59 >
# 6 Re: Use diskspace("a:")
Hi Eric,

> Any idea where this option can be set in Windows?

Found MSKB Q124873 and Q128642 Meanwhile -
sounds to me as if there is no user interface except Regedit
for ErrorMode.

Regards
-Stefan
Stefan Wuebbe at 2007-11-11 23:55:55 >