home *** CD-ROM | disk | FTP | other *** search
/ PDA Software Library / pdasoftwarelib.iso / PSION / UTILS / SHELL3A / SRC.ZIP / OPL / VIEW.OPL < prev    next >
Encoding:
Text File  |  1996-09-03  |  2.2 KB  |  108 lines

  1. Rem ****************************************
  2. Rem * Shell3a external command - view.opl
  3. Rem * ╕ Nick Murray May 1996
  4. Rem *
  5. Rem * view - Display .PIC files
  6. Rem ****************************************
  7. PROC view%:(n%)
  8.     LOCAL src$(128),ret%,id1%,id2%,disp%,h%,w%,x%,y%,c%,planes%,i%
  9.     ONERR ErrTrap::
  10.     IF n% < 2
  11.         PRINT "Usage: view <file> <file> ..."
  12.         RETURN
  13.     ENDIF
  14.     i%=2
  15.     PRINT "Press [ESC] to exit";
  16.     IF n%>2    Rem multiple files
  17.         PRINT ", [SPACE] for next picture..."
  18.     ELSE
  19.         PRINT
  20.     ENDIF
  21.     DO
  22.         ret%=Fparse%:(ADDR(src$),PEEK$(argv%(i%)))
  23.         IF ret%<0
  24.             ShErr:(i%,ret%)
  25.             GOTO Next::
  26.         ENDIF
  27.         id1%=gLOADBIT(src$,0)    Rem no-write
  28.         ONERR ErrGrey::    Rem trap errors with grey plane
  29.         id2%=gLOADBIT(src$,0,1)    Rem grey plane (if it exists)
  30.         planes%=1    Rem only gets here if there's a grey plane
  31. Restart::
  32.         ONERR ErrTrap::
  33.         h%=gHEIGHT
  34.         w%=gWIDTH
  35.         x%=(ScrInfo%(3)*ScrInfo%(7)-w%-10)/2
  36.         y%=(ScrInfo%(4)*ScrInfo%(8)-h%-10)/2
  37.         IF x%<0 OR y%<0
  38.             giPRINT "Use the cursor key to scroll the image"
  39.             ENDIF
  40.         PRINT "Viewing: "+PrPath$:(src$)
  41.         disp%=gCREATE(x%,y%,w%+10,h%+10,1,planes%)
  42.         gBORDER 1
  43.         gAT 5,5
  44.         gCOPY id1%,0,0,w%,h%,0
  45.         gCLOSE(id1%)
  46.         id1%=0
  47.         IF planes%    Rem grey plane exists
  48.             gGREY 1    
  49.             gCOPY id2%,0,0,w%,h%,0
  50.             gCLOSE(id2%)
  51.             id2%=0
  52.         ENDIF
  53.         DO
  54.             c%=GET
  55.             IF c%=260    Rem PSION up
  56.                 y%=y%+10
  57.                 GOTO shift::
  58.             ELSEIF c%=261    Rem PSION down
  59.                 y%=y%-10
  60.                 GOTO shift::
  61.             ELSEIF c%=262    Rem PSION left
  62.                 x%=x%+10
  63.                 GOTO shift::
  64.             ELSEIF c%=263    Rem PSION right
  65.             x%=x%-10
  66.             GOTO shift::
  67.             ELSEIF c%=256    Rem up
  68.                 y%=y%+1
  69.                 GOTO shift::
  70.             ELSEIF c%=257    Rem down
  71.                 y%=y%-1
  72.                 GOTO shift::
  73.             ELSEIF c%=258    Rem right
  74.                 x%=x%-1
  75.                 GOTO shift::
  76.             ELSEIF c%=259    Rem left
  77.                 x%=x%+1
  78. shift::        gSETWIN x%,y%
  79.             ELSEIF c%=27    Rem ESC
  80.                 GOTO Cleanup::
  81.             ENDIF
  82.         UNTIL c%=32    Rem SPACE
  83.         gCLOSE(disp%)
  84. Next::
  85.         i%=i%+1
  86.     UNTIL i%>n%
  87.     BUSY off
  88.     RETURN
  89. ErrGrey::
  90.     IF ERR=-36    Rem end of file, ie. no grey plane
  91.         GOTO Restart
  92.     ENDIF
  93. ErrTrap::
  94.     ONERR off
  95.     PRINT err$:(ERR)
  96. Cleanup::
  97.     BUSY off
  98.     IF id1%
  99.         gCLOSE(id1%)
  100.     ENDIF
  101.     IF id2%
  102.         gCLOSE(id2%)
  103.     ENDIF
  104.     IF disp%
  105.         gCLOSE(disp%)
  106.     ENDIF
  107. ENDP
  108.