Identify what packs are installed

Popular in previous forums place your programming snippets here
Post Reply
User avatar
Martin
Global Admin
Posts: 220
Joined: Mon Jan 02, 2023 5:18 pm

Identify what packs are installed

Post by Martin »

As mentioned elsewhere i was looking for a way of detecting which type of pack (if any) was inserted and how much free space there is on it.

After Peter mentioned Jaap's INFO.OPL - which does just that. I've adapted it into the following... It works on a XP and LZ

Code: Select all

PAKINFO:(X%,Y%,T$)
LOCAL B%,B1%,P%,SP
REM Needs globals D%(2),DS%(2),DT$(2,7)

REM Adapted from and acknowledge Jaap Scherphuis INFO.OPL
REM Use to check what packs are inserted in B: & C:
REM Please read PakInfo_ReadMe.TXT

REM D% = 1=B: 2=C:
REM DS%= Drive Free Space 1=B 2=C
REM DT$(P%,7) P%=1 or 2 and "Flash", "Rampak  ","Datapak
REM SP = K Space on pack 

REM Test if Logical D in use
TRAP USE D
IF ERR=0 :DT$(1)="File D" :DT$(2)="In Use" :RETURN :ENDIF

IF T$<>""
 AT X%,Y% :PRINT T$
ENDIF

P%=1
DO
 TRAP OPEN CHR$(P%+65)+":MAIN",D,A$ :REM use logical D in case
 IF ERR=0                           :REM other files are open
  B%=$20D7+P%*10
  B1%=PEEKB(B%)
  SP=(SPACE+(2685 AND P%))/1024
  SP=INT(SP*10+0.5)/10
   IF (B1% AND 66)=2
    D%(P%)=P% :DS%(P%)=SP :DT$(P%)="Flash"
    CONTINUE
   ENDIF
   IF B1% AND 2
    D%(P%)=P% :DS%(P%)=SP :DT$(P%)="Datapak"
   ELSE
    D%(P%)=P% :DS%(P%)=SP :DT$(P%)="Rampak"
   ENDIF
 ENDIF
 TRAP CLOSE
 P%=P%+1
UNTIL P%>=3
RETURN
You can test it with something like this...

Code: Select all

TEST:
GLOBAL D%(2),DS%(2),DT$(2,7)
LOCAL i%,SS%

REM Generate FILE IN USE error
REM Remove the REMs & test for error
REM OPEN "C:MAIN",D,b$ 

SS%=SECOND

REM Check Slots
PakInfo:(1,2,"Looking")

REM Print Results
i%=1
DO
PRINT D%(i%),DT$(i%),NUM$(DS%(i%),3)+"K"
i%=i%+1
UNTIL i%>=3

PRINT "Time ",SECOND-SS%

GET
Please let me know how it works for you..
Martin
You do not have the required permissions to view the files attached to this post.
Post Reply