Consultor Eletrônico



Kbase P19828: How to verify whether or not the diskette is write-protected
Autor   Progress Software Corporation - Progress
Acesso   Público
Publicação   13/03/2003
Status: Unverified

GOAL:

How to verify whether or not the diskette is write-protected from within a Progress 4GL program?

FIX:

DEFINE VARIABLE vcCanSave AS CHARACTER NO-UNDO.
DEFINE VARIABLE vcFileName AS CHARACTER NO-UNDO.

ASSIGN vcFileName = "A:\test.txt":U.
RUN adecomm/_osfrw.p (vcFileName, "_WRITE-TEST":U, OUTPUT vcCanSave).
IF vcCanSave = "":U THEN
DO:
MESSAGE "Cannot save output file.~nFloppy disk may be full or write-protected."
VIEW-AS ALERT-BOX INFO BUTTONS OK.
RETURN.
END.
ELSE
OS-DELETE VALUE(vcFileName).

OUTPUT TO VALUE(vcFileName).
PUT UNFORMATTED "Floppy disk was not write-protected.~n".
PUT UNFORMATTED "The output file could be saved without any problems!".
OUTPUT CLOSE.