home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The Datafile PD-CD 1B
/
DATAFILE_PDCD1B.iso
/
_pocketbk
/
pocketbook
/
004
/
oplexamp_z
/
ATTRIB.OPL
< prev
next >
Wrap
Text File
|
1993-01-12
|
3KB
|
178 lines
/* The following OPL code shows how one might alter the settings
of the file attributes of any file from within an OPL program
It uses the EPOC System Services: FilStatusGet & FilStatusSet
as described on pp. 39 of both the old manual and the new one.
This code written for Support by A.M.
Copyright Psion Plc. 1992
*/
#define FileManager $0087
#define FilStatusGet $0800
#define FilStatusSet $0900
PROC attrib:
LOCAL err%,file$(128)
LOCAL rdo%,mod%,hid%,sys%
LOCAL mask%
LOCAL option%
file$ = "m:\*.*"
dINIT "File attributes"
dFILE file$,"File:",16
dCHOICE option%,"Action","Get,Set"
err% = DIALOG
IF err% = 0
STOP
ENDIF
IF option% = 1
err% = attget%:(file$) /* get the current attributes */
IF err% < 0
showerr:(err%)
ENDIF
CLS
IF err% AND $01
PRINT "Is file read only : No"
ELSE
PRINT "Is file read only : Yes"
ENDIF
IF err% AND $20
PRINT "Is file modified : Yes"
ELSE
PRINT "Is file modified : No"
ENDIF
IF err% AND $02
PRINT "Is file hidden : Yes"
ELSE
PRINT "Is file hidden : No"
ENDIF
IF err% AND $04
PRINT "Is file a system file : Yes"
ELSE
PRINT "Is file a system file : No"
ENDIF
ELSE
dINIT "Set file attributes"
dCHOICE rdo%,"Is file read only","No,Yes"
dCHOICE mod%,"Is file modified","No,Yes"
dCHOICE hid%,"Is file hidden","No,Yes"
dCHOICE sys%,"Is file a system file","No,Yes"
err% = DIALOG
IF err% = 0
STOP
ENDIF
IF rdo% = 1 /* These few lines make up */
mask% = mask% + $01 /* the bit value which is */
ENDIF /* passed in DI when doing */
/* the OS() to FilStatusSet */
IF mod% = 2
mask% = mask% + $20
ENDIF
IF hid% = 2
mask% = mask% + $02
ENDIF
IF sys% = 2
mask% = mask% + $04
ENDIF
err% = attset%:(file$,mask%)
IF err% < 0
showerr:(err%)
ENDIF
PRINT "Attributes set successfully"
ENDIF
PRINT
PRINT "Press any key to stop."
GET
ENDP
PROC attget%:(f$)
LOCAL ax%,bx%,cx%,dx%,si%,di%
LOCAL flags%
LOCAL fname$(25),pfname%
LOCAL buff%(8),pbuff%
fname$ = f$ + CHR$(0) /* Make the name a ZTS */
pfname% = ADDR(fname$) + 1 /* Skip the LCB */
pbuff% = ADDR(buff%())
ax% = FilStatusGet
bx% = pfname%
cx% = pbuff%
flags% = OS(FileManager,ADDR(ax%))
IF flags% AND 1 /* if carry set = error occured */
RETURN ax% OR $ff00 /* so return that error number */
ELSE
RETURN buff%(2) /* Return the value of the bits */
ENDIF
ENDP
PROC attset%:(f$,m%)
LOCAL ax%,bx%,cx%,dx%,si%,di%
LOCAL flags%
LOCAL fname$(128),pfname%
fname$ = f$ + CHR$(0)
pfname% = ADDR(fname$) + 1
ax% = FilStatusSet
bx% = pfname%
cx% = $27 /* mask the read-only, mod, */
di% = m% /* hidden and system bits */
flags% = OS(FileManager,ADDR(ax%))
IF flags% AND 1 /* if carry set = error occured */
RETURN ax% OR $ff00 /* so return that error number */
ELSE
RETURN 0 /* Return success */
ENDIF
ENDP
PROC showerr:(e%)
PRINT "An error has occurred =",e%
PRINT ERR$(e%)
GET
STOP
ENDP