CONST KImageCounterOffset&=&00000010
PROC GetNoOfImagesInMbmFile&:(aMbmFileName$)
LOCAL IOstatus%,hMbm%,IOmode%,Offset&,NoOfImages&
REM --- open the image file
IOmode%=KIOModeOpen% OR KIOFormatBinary% OR KIOAccessRandom% OR KIOAccessShare%
IOstatus%=IOOPEN(hMbm%,aMbmFileName$,IOmode%)
IF IOstatus%<0
RAISE KErrNotExists%
ENDIF
REM --- move to the position of the offset address of the image counter
Offset&=KImageCounterOffset&
IOSEEK(hMbm%,1,Offset&)
REM --- read the position of the image counter
IOREAD(hMbm%,ADDR(Offset&),4)
REM --- move to the position of the image counter
IOSEEK(hMbm%,1,Offset&)
REM --- read the image counter
IOREAD(hMbm%,ADDR(NoOfImages&),4)
REM --- close the image file
IOCLOSE(hMbm%)
REM --- return number of images in file
RETURN NoOfImages&
ENDP
|