home *** CD-ROM | disk | FTP | other *** search
- Rem ****************************************
- Rem * Shell3a external command - view.opl
- Rem * ╕ Nick Murray May 1996
- Rem *
- Rem * view - Display .PIC files
- Rem ****************************************
- PROC view%:(n%)
- LOCAL src$(128),ret%,id1%,id2%,disp%,h%,w%,x%,y%,c%,planes%,i%
- ONERR ErrTrap::
- IF n% < 2
- PRINT "Usage: view <file> <file> ..."
- RETURN
- ENDIF
- i%=2
- PRINT "Press [ESC] to exit";
- IF n%>2 Rem multiple files
- PRINT ", [SPACE] for next picture..."
- ELSE
- PRINT
- ENDIF
- DO
- ret%=Fparse%:(ADDR(src$),PEEK$(argv%(i%)))
- IF ret%<0
- ShErr:(i%,ret%)
- GOTO Next::
- ENDIF
- id1%=gLOADBIT(src$,0) Rem no-write
- ONERR ErrGrey:: Rem trap errors with grey plane
- id2%=gLOADBIT(src$,0,1) Rem grey plane (if it exists)
- planes%=1 Rem only gets here if there's a grey plane
- Restart::
- ONERR ErrTrap::
- h%=gHEIGHT
- w%=gWIDTH
- x%=(ScrInfo%(3)*ScrInfo%(7)-w%-10)/2
- y%=(ScrInfo%(4)*ScrInfo%(8)-h%-10)/2
- IF x%<0 OR y%<0
- giPRINT "Use the cursor key to scroll the image"
- ENDIF
- PRINT "Viewing: "+PrPath$:(src$)
- disp%=gCREATE(x%,y%,w%+10,h%+10,1,planes%)
- gBORDER 1
- gAT 5,5
- gCOPY id1%,0,0,w%,h%,0
- gCLOSE(id1%)
- id1%=0
- IF planes% Rem grey plane exists
- gGREY 1
- gCOPY id2%,0,0,w%,h%,0
- gCLOSE(id2%)
- id2%=0
- ENDIF
- DO
- c%=GET
- IF c%=260 Rem PSION up
- y%=y%+10
- GOTO shift::
- ELSEIF c%=261 Rem PSION down
- y%=y%-10
- GOTO shift::
- ELSEIF c%=262 Rem PSION left
- x%=x%+10
- GOTO shift::
- ELSEIF c%=263 Rem PSION right
- x%=x%-10
- GOTO shift::
- ELSEIF c%=256 Rem up
- y%=y%+1
- GOTO shift::
- ELSEIF c%=257 Rem down
- y%=y%-1
- GOTO shift::
- ELSEIF c%=258 Rem right
- x%=x%-1
- GOTO shift::
- ELSEIF c%=259 Rem left
- x%=x%+1
- shift:: gSETWIN x%,y%
- ELSEIF c%=27 Rem ESC
- GOTO Cleanup::
- ENDIF
- UNTIL c%=32 Rem SPACE
- gCLOSE(disp%)
- Next::
- i%=i%+1
- UNTIL i%>n%
- BUSY off
- RETURN
- ErrGrey::
- IF ERR=-36 Rem end of file, ie. no grey plane
- GOTO Restart
- ENDIF
- ErrTrap::
- ONERR off
- PRINT err$:(ERR)
- Cleanup::
- BUSY off
- IF id1%
- gCLOSE(id1%)
- ENDIF
- IF id2%
- gCLOSE(id2%)
- ENDIF
- IF disp%
- gCLOSE(disp%)
- ENDIF
- ENDP
-