home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
AMOS PD CD
/
amospdcd.iso
/
sourcecode
/
various
/
diskutil.amos
/
diskutil.amosSourceCode
Wrap
AMOS Source Code
|
1991-08-01
|
20KB
|
698 lines
Screen Open 0,640,256,8,Hires : Paper 0 : Curs Off : Cls
Palette $0,$222,$444,$666,$888,$AAA,$CCC,$FFF
Reserve Zone 10
Dim DEV$(15),FILE$(100,2),T(2),P(2),TITLE$(2),PATH$(2)
Dim LINE$(5),BUTTON$(5),PAGESTART(100),PAGEEND(100)
Dim MK(100,2),NUM(2)
Global T(),DEV$(),DEVS,FILE$(),P(),WIN,TITLE$(),PATH$(),MK(),NUM()
Global LINE$(),BUTTON$(),TEMP1,TEMP2
Limit Mouse 128,40 To 448,296
Set Dir ,""
SREEN
DEVREAD
DISPCOM
TEMP1=0 : TEMP2=0
NUM(1)=0 : NUM(2)=0
P(1)=1 : P(2)=1
WIN=1
Window 1
Do
Z=Mouse Zone : K=Mouse Click : K1=Mouse Key
XX=X Screen(0,X Mouse) : YY=Y Screen(0,Y Mouse)
WW=1-(Z=8)
If(Z=6 or Z=8) and P(WIN)>1 and WIN=WW and K1=1
Dec P(WIN) : Locate 0,0 : Vscroll 1 : DISPLN[0] : SLIDER : Wait 2
End If
WW=1-(Z=9)
If(Z=7 or Z=9) and P(WIN)+22<T(WIN) and WIN=WW and K1=1
Inc P(WIN) : Locate 0,22 : Vscroll 3 : DISPLN[22] : SLIDER : Wait 2
End If
WW=1-(Z=5)
If(Z=4 or Z=5) and WIN=WW and K1=1
P(WIN)=((YY-24)*(T(WIN)-22)/176.0)+1 : Clw : DISP : SLIDER
End If
If Z>0 and Z<3 and K1=2
FILE=(YY-24)/8
If MK(FILE+P(WIN),WIN)<>-1
Inc NUM(WIN)
MK(FILE+P(WIN),WIN)=-1
End If
Repeat
YY=Y Screen(0,Y Mouse)
FILE=(YY-24)/8
Locate 0,FILE
Inverse On
DISPLN[FILE]
Inverse Off
If MK(FILE+P(WIN),WIN)<>-1
Inc NUM(WIN)
MK(FILE+P(WIN),WIN)=-1
End If
Until Mouse Key=0
End If
If Z>0 and Z<3
FILE=(YY-24)/8+1
If WIN<>Z
WIN=Z
TITLE$(Z)="~S~ "+Mid$(TITLE$(Z),5)
TITLE$(3-Z)="~D~ "+Mid$(TITLE$(3-Z),5)
Window 3-Z : Title Top TITLE$(3-Z)
Window Z : Title Top TITLE$(Z)
Else
If FILE>0 and FILE<T(WIN)+1
Window WIN : Dec FILE
Inverse On : Locate 0,FILE : DISPLN[FILE] : Inverse Off
Repeat
K=Mouse Click
FF=(Y Screen(0,Y Mouse)-24)/8+1
ZZ=Mouse Zone
Until K<>0 or FF<>FILE+1 or ZZ<>Z
If MK(FILE+P(WIN),WIN)=0
Locate 0,FILE : DISPLN[FILE]
End If
If Left$(FILE$(FILE+P(WIN),WIN),1)="*" and K=1
DCLICK : If Param
PATH$(WIN)=PATH$(WIN)+Mid$(FILE$(FILE+P(WIN),WIN),2)-" "+"/"
DDREAD
K=0
End If
End If
If K=1
TEMP=FILE+P(WIN)
If MK(FILE+P(WIN),WIN)<>-1
MK(FILE+P(WIN),WIN)=-1 : Inc NUM(WIN)
Inverse On
Locate 0,FILE
DISPLN[FILE]
Inverse Off
Else
MK(FILE+P(WIN),WIN)=0 : Dec NUM(WIN)
Locate 0,FILE : DISPLN[FILE]
End If
End If
End If
End If
End If
COM=(YY-24)/8+1 : If COM>24 : COM=24 : End If
If Z=3 and OCOM<>COM
Gr Writing 3
Ink 0,7
Bar 288,COM*8+16 To 352,COM*8+23
If OCOM<>0
Bar 288,OCOM*8+16 To 352,OCOM*8+23
End If
Gr Writing 1
OCOM=COM
End If
If Z=3 and K<>0 :
COM=(YY-24)/8+1
If COM<=DEVS
If K=1
PATH$(WIN)=DEV$(COM)
DDREAD
Else
DEVREAD : OCOM=0
DISPCOM
End If
End If
If COM=14
If NUM(WIN)=0
LINE$(0)="You must Select a File to Run"
BUTTON$(0)="Sorry" : ALERT[1,1]
Else
If NUM(WIN)<>1
LINE$(0)="Only 1 File must be selected"
BUTTON$(0)="Sorry" : ALERT[1,1]
Else
J=1 : Do : If MK(J,WIN)=-1 : Exit : End If : Inc J : Loop
CON[FILE$(J,WIN)] : F$=Param$
Run PATH$(WIN)+F$
End If
End If
End If
If COM=11
If NUM(WIN)=0
LINE$(0)="No Files Have Been Selected"
BUTTON$(0)="O.K." : ALERT[1,1]
Else
J=1 : COUNTER=0
Do
Do : If MK(J,WIN)=-1 : Inc COUNTER : Exit : End If : Inc J : Loop
CON[FILE$(J,WIN)] : F$=Param$
If Left$(F$,1)<>"*"
MESSAGE["Reading Picture: "+F$]
Open In 1,PATH$(WIN)+F$ : A$=Input$(1,4)
Pof(1)=12 : B$=Input$(1,6) : Close
If A$="FORM"
Load Iff PATH$(WIN)+F$,1
End If
If B$="Pac.Pi"
Load PATH$(WIN)+F$,6 : Unpack 6 To 1 : Erase 6
End If
If(A$="FORM") or(B$="Pac.Pi")
Screen To Front 1
Hide On
Repeat : K=Mouse Click : Until K<>0
Fade 5 : Wait 5*15
Screen To Front 0 : Screen Close 1
Show On
End If
End If
If K=2 : Exit : End If
Inc J
If COUNTER=NUM(WIN) : Exit : End If
Loop
Window 4 : Clw : Curs On : Window WIN
End If
End If
If COM=12
If NUM(WIN)=0
LINE$(0)="You need to Select a file"
BUTTON$(0)="O.K." : ALERT[1,1]
Else
If NUM(WIN)<>1
LINE$(0)="Please Select only one File"
BUTTON$(0)="O.K." : ALERT[1,1]
Else
J=1 : Do : If MK(J,WIN)=-1 : Exit : End If : Inc J : Loop
CON[FILE$(J,WIN)] : F$=Param$
If Left$(F$,1)<>"*"
Open In 1,PATH$(WIN)+F$ : LE=Lof(1) : Close
Reserve As Data 10,LE
Bload PATH$(WIN)+F$,Start(10)
Paper 0 : Cls : Pen 7
FILE_PROCESS
Do
Do
K$=Inkey$
If K$=Chr$(31) and CURRENT_PAGE<PAGE_NUM-1
Inc CURRENT_PAGE : Exit
End If
If K$=Chr$(30) and CURRENT_PAGE>0
Dec CURRENT_PAGE : Exit
End If
If(K$=Chr$(27)) or(Upper$(K$)="Q")
Exit 2
End If
Loop
PAGE_SHOW[CURRENT_PAGE]
Loop
Erase 10
Cls
SREEN : DISPCOM
WW=WIN : WIN=3-WW : Window WIN : DISP
WIN=WW : Window WIN : DISP
End If
End If
End If
End If
If COM=13
If NUM(WIN)=0
LINE$(0)="You must select a file for this option"
BUTTON$(0)="O.K." : ALERT[1,1]
Else
NU=1 : COUNTER=0
Do
Do : If MK(NU,WIN)=-1 : Inc COUNTER : Exit : End If : Inc NU : Loop
CON[FILE$(NU,WIN)] : F$=Param$
If Left$(F$,1)<>"*"
Open In 1,PATH$(WIN)+F$
A$=Input$(1,12) : A$=Input$(1,6)
Pof(1)=$14 : B$=Input$(1,2)
BE=Asc(Left$(B$,1))*256+Asc(Right$(B$,1))
LE=Lof(1)
Close
If A$="Music "
Load PATH$(WIN)+F$
MESSAGE["Press Any Button to Stop Music"]
Mvolume 63 : Music 1
Repeat : K=Mouse Click : Until K
For N=63 To 0 Step -1 : Mvolume N : Wait Vbl : Next
Music Off
Erase 3
Clw : Curs On : Window WIN
End If
If A$="Sample"
MESSAGE["LEFT BUTTON - Next Sample RIGHT BUTTON - Exit"]
Load PATH$(WIN)+F$
Mvolume 63
J=1
Do
Sam Play J
Repeat : K=Mouse Click : Until K
If K>1 : Exit : End If
Add J,1,1 To BE
Loop
Dec K
Clw : Curs On : Window WIN
Erase 5
End If
If(A$<>"Music ") and(A$<>"Sample")
MESSAGE["Loading Data"]
Reserve As Chip Data 10,LE
Bload PATH$(WIN)+F$,Start(10)
Mvolume 63
EE=8000
Do
Window 4 : Curs On
Clw
Pen 5 : Print "Raw Sample (Enter Playback Speed 501 - 30000): ";Pen$(7);
IPUT[Str$(EE)-" ",6,False] : EE=Val(Param$)
If EE<501 or EE>30000 : Exit : End If
MESSAGE["Playing Sample, Press Mouse Button to Exit"]
Sam Raw 15,Start(10),Length(10),EE
A=Timer
Do
If(Timer-A)>((Length(10))/EE)*50 : Exit : End If
K=Mouse Click : If K<>0 : Exit : End If
Loop
If K<>0 : Exit : End If
Loop
Mvolume 0
Window 4
Clw : Curs On : Window WIN
Erase 10
End If
End If
End If
If K>1 : Exit : End If
Inc NU
If COUNTER=NUM(WIN) : Exit : End If
Loop
End If
If COM=15
LINE$(0)="Do you really want to quit?"
BUTTON$(0)="Yes" : BUTTON$(1)="No" : ALERT[2,1] : If Param=1 : End : End If
End If
If COM=16
FPARENT
If PATH$(WIN)<>"" : DDREAD : End If
End If
If COM=17
Window 4 : Clw : Pen 2 : Print "Enter New Directory: ";
IPUT["",30,False] : ND$=Param$
If Not Exist(PATH$(WIN)+ND$)
Mkdir PATH$(WIN)+ND$
DDREAD
End If
Window 4 : Clw : Curs On : Window WIN
End If
If COM=19
For J=1 To T(WIN)
MK(J,WIN)=-1
Next J
NUM(WIN)=T(WIN)
Clw : DISP
End If
If COM=20
For J=1 To T(WIN)
MK(J,WIN)=0
Next J
NUM(WIN)=0
Clw : DISP
End If
If COM=21
TEMP1=TEMP
If TEMP2>TEMP1
For J=TEMP1 To TEMP2
If MK(J,WIN)<>-1
MK(J,WIN)=-1 : Inc NUM(WIN)
End If
Next J
Clw : DISP
End If
End If
If COM=22
TEMP2=TEMP
If TEMP1<TEMP2
For J=TEMP1 To TEMP2
If MK(J,WIN)<>-1
MK(J,WIN)=-1 : Inc NUM(WIN)
End If
Next J
Clw : DISP
End If
End If
If COM=23
If NUM(WIN)<>0
COUNTER=0 : J=1
Do
Do
If MK(J,WIN)=-1 : Inc COUNTER : Exit : End If : Inc J
Loop
MESSAGE[PATH$(WIN)+F$+" to "+PATH$(3-WIN)+F$]
DCOPY[J]
Inc J
If COUNTER=NUM(WIN) : Exit : End If
Loop
Window 4 : Curs On : Clw : Window WIN
For J=1 To T(WIN) : MK(J,WIN)=0 : Next : NUM(WIN)=0 : Clw : DISP
WIN=3-WIN
Window WIN
DDREAD
WIN=3-WIN
Window WIN
End If
End If
If COM=24
If NUM(WIN)<>0
If NUM(WIN)<>1
LINE$(0)="Please only select 1 file to Rename"
BUTTON$(0)="Opps! Sorry"
ALERT[1,1]
Else
J=1 : Do : If MK(J,WIN)=-1 : Exit : End If : Inc J : Loop
CON[FILE$(J,WIN)] : F$=Param$
IPUT[F$,32,False] : NAME$=Param$
Rename PATH$(WIN)+F$ To PATH$(WIN)+NAME$
DDREAD
End If
End If
End If
If COM=18
If NUM(WIN)<>0
J=1 : COUNTER=0
Do
Do : If MK(J,WIN)=-1 : Inc COUNTER : Exit : End If : Inc J : Loop
DKILL[J]
Inc J
If COUNTER=NUM(WIN) : Exit : End If
Loop
DDREAD
End If
End If
End If
Loop
Procedure DDREAD
For J=1 To T(WIN) : MK(J,WIN)=0 : Next J
NUM(WIN)=0
TITLE$(WIN)="~S~ "+PATH$(WIN)
TITLE$(3-WIN)="~D~ "+Mid$(TITLE$(3-WIN),5)
Window 3-WIN : Title Top TITLE$(3-WIN)
Window WIN : Title Top TITLE$(WIN)
Clw
Pen 3 : Centre "Reading Dir" : Pen 7
P(WIN)=1
FILE$(1,WIN)=Dir First$(PATH$(WIN))
K=2
Do
FILE$(K,WIN)=Dir Next$
If FILE$(K,WIN)="" : Dec K : Exit : End If
Inc K
Loop
T(WIN)=K
Clw
DISP
SLIDER
End Proc
Procedure DISPLN[J]
If MK(J+P(WIN),WIN)=-1 Then Inverse On
Print Left$(FILE$(J+P(WIN),WIN),18)+Right$(FILE$(J+P(WIN),WIN),10);
If J<>22 : Print : End If
Inverse Off
End Proc
Procedure DISP
For J=0 To Min(22,T(WIN)-1)
DISPLN[J]
Next J
If PATH$(WIN)<>""
Dir$=Left$(PATH$(WIN),Instr(PATH$(WIN),":"))
Title Bottom(Str$(Dfree)-" ")+" Bytes Free."
End If
End Proc
Procedure SLIDER
If T(1)<22
Vslider 272,24 To 280,200,176,0,176
Else
Vslider 272,24 To 280,200,T(1),P(1)-1,(T(1)-22/176)
End If
If T(2)<22
Vslider 358,24 To 366,200,176,0,176
Else
Vslider 358,24 To 366,200,T(2),P(2)-1,(T(2)-22/176)
End If
End Proc
Procedure SREEN
Shared OCOM
OCOM=0
Set Slider 4,5,6,1,1,0,2,1
Bar 272,16 To 280,23
Bar 358,16 To 366,23
Bar 272,201 To 280,208
Bar 358,201 To 366,208
Vslider 272,24 To 280,200,176,0,176
Vslider 358,24 To 366,200,176,0,176
Wind Open 1,0,16,32,25,1
Curs Off
Title Top "~S~ "
Border 1,0,7
Wind Open 2,368,16,32,25,1
Curs Off
Title Top "~D~ "
Wind Open 3,288,24,8,24
Curs Off
Wind Open 4,0,220,79,3,1
Set Zone 1,16,16 To 252,206
Set Zone 2,384,16 To 620,206
Set Zone 3,288,24 To 352,224
Set Zone 4,272,24 To 280,200
Set Zone 5,358,24 To 366,200
Set Zone 6,272,16 To 280,23
Set Zone 7,272,201 To 280,208
Set Zone 8,358,16 To 366,23
Set Zone 9,358,201 To 366,208
End Proc
Procedure FPARENT
If PATH$(WIN)="" Then Pop Proc
F$=Flip$(PATH$(WIN))
D=2
Do
If(Mid$(F$,D,1)="/") or(Mid$(F$,D,1)=":") Then Exit
If D>Len(F$) Then Exit
Inc D
Loop
If D>Len(F$) Then Pop Proc
F$=Mid$(F$,D)
PATH$(WIN)=Flip$(F$)
End Proc
Procedure DEVREAD
' could use this but I dont like it!
' DEV$(1)=Dev First$("*")-" "
' K=2
' Do
' DEV$(K)=Dev Next$-" "
' If DEV$(K)="" Then Exit
' Inc K : If K>10 Then Exit
' Loop
' DEVS=K-1
DEV$="Df1Df2Df3Dh0Dh1Di0Di1Ram"
J=2 : DEV$(1)="Df0:"
Do
DE$=Left$(DEV$,3)+":" : DEV$=Mid$(DEV$,4)
If Exist(DE$) : DEV$(J)=DE$ : Inc J : End If
If DEV$="" : Exit : End If
Loop
DEVS=J-1
End Proc
Procedure DISPCOM
Window 3
Clw
Pen 7
For J=1 To DEVS : Print DEV$(J) : Next
Print At(0,10);
Print " VIEW "
Print " READ "
Print " HEAR "
Print " PRUN "
Print " QUIT"
Print " PARENT"
Print " MK-DIR"
Print " DELETE"
Print " SELECT"
Print "DESELECT";
Print " BSTART"
Print " BEND "
Print " COPY "
Print " RENAME";
End Proc
Procedure DKILL[X]
Shared FF$,F$
CON[FILE$(X,WIN)]
F$=Param$
If Left$(F$,1)="*"
LINE$(0)="You Have Sleceted a Directory"
LINE$(1)="I Can't Get Amos to kill a Directory - Sorry"
BUTTON$(0)="O.K." : ALERT[1,2]
F$=""
End If
If F$<>""
LINE$(0)="Do you want to Delete "+F$
LINE$(1)="Remember once deleted you cant retrieve"
BUTTON$(0)="DELETE" : BUTTON$(1)="CANCEL"
ALERT[2,2] : AA=Param
If AA=1 : Kill PATH$(WIN)+F$ : End If
End If
End Proc
Procedure CON[F$]
F$=Left$(F$,30)
F$=F$-" "
End Proc[F$]
Procedure DCOPY[X]
CON[FILE$(X,WIN)]
F$=Param$
Open In 1,PATH$(WIN)+F$
L=Lof(1)
Close
Reserve As Work 10,L
Bload PATH$(WIN)+F$,Start(10)
If Exist(PATH$(3-WIN)+F$)
LINE$(0)="FILE ALREADY EXISTS"
LINE$(1)="OVEWRITE?"
BUTTON$(0)="YES" : BUTTON$(1)="NO"
ALERT[2,2]
If Param=2
Erase 10 : Pop Proc
End If
End If
Bsave PATH$(3-WIN)+F$,Start(10) To Start(10)+Length(10)
Erase 10
End Proc
Procedure ALERT[NB,NL]
Shared LINE$(),BUTTON$()
Screen Open 7,580,64,4,Hires : Flash Off : Palette $0,$F80,$FFF,$3F
Reserve Zone 10
Curs Off : Paper 0 : Cls : Pen 2
Screen Display 7,144,128,560,64
Ink 3 : Bar 0,0 To 560,44
TEMP=0
NL=Min(NL,5)
NB=Min(7,NB)
Ink 2,3
While TEMP<>NL
T=Text Length(LINE$(TEMP)) : Text 280-(T/2),10+TEMP*8,LINE$(TEMP)
Inc TEMP
Wend
Ink 1 : Bar 0,44 To 560,64
WIDTH=560/NB : TEMP=0 : COUNT=0
Ink 2,1
While TEMP<560
Bar TEMP-1,44 To TEMP+1,64
Add TEMP,WIDTH
Set Zone COUNT+1,TEMP-WIDTH,44 To TEMP-1,64 : Inc COUNT
Wend
Draw 0,44 To 560,44
Box 0,0 To 560,63
Ink 0
COUNT=0 : TEMP=0
While TEMP<560
W=Text Length(BUTTON$(COUNT))
W1=(WIDTH/2)-(W/2) : Text W1+TEMP,57,BUTTON$(COUNT)
Inc COUNT : Add TEMP,WIDTH
Wend
Repeat
Repeat : Until Mouse Click and Mouse Key=1
TEMP=Mouse Zone
Until TEMP<>0
Screen Close 7
End Proc[TEMP]
Procedure IPUT[T$,LLEN,CASE]
Window 4 : Pen 6
XX=X Curs : YY=Y Curs : If YY>0 : YY=0 : End If
Print At(XX,YY);T$; : ZZ=Len(T$)
Do
Repeat
A$=Inkey$ : If CASE : A$=Upper$(A$) : End If
SC=Scancode
Until A$<>""
If A$=Chr$(8) and ZZ>0 : T$=Left$(T$,ZZ-1)+Mid$(T$,ZZ+1) : Dec ZZ : End If
If SC=70 : T$=Left$(T$,ZZ)+Mid$(T$,ZZ+2) : End If
If A$=Chr$(28) and ZZ<Len(T$) : Inc ZZ : End If
If A$=Chr$(29) and ZZ>0 : Dec ZZ : End If
If A$=Chr$(27) : T$="" : Exit : End If
If A$=Chr$(13) : Exit : End If
If A$>=" " : T$=Left$(T$,ZZ)+A$+Mid$(T$,ZZ+1) : Inc ZZ : End If
T$=Left$(T$,LLEN)
If ZZ>Len(T$) : ZZ=Len(T$) : End If : If ZZ<0 : ZZ=0 : End If
Print At(XX,YY);Left$(T$+Space$(LLEN),LLEN); : Locate XX+ZZ,0
Loop
Clw
Window WIN
End Proc[T$]
Procedure DCLICK
A=Timer
Do
If Timer-A>12 : Exit : End If
K=Mouse Click
If K : Exit : End If
Loop
End Proc[K]
Procedure MESSAGE[B$]
Window 4 : Clw : Curs Off
Pen 3
Centre B$
End Proc
Procedure NOBUT
Repeat : Until Mouse Click=0
End Proc
Procedure FILE_PROCESS
Shared PAGESTART(),PAGEEND(),PAGE_NUM,CURRENT_PAGE
PAGE_NUM=0
LINES=-1
TEMP=0
COUNT=0
Pen 3 : Centre At(,25)+"Please Wait, Paginating Document"+Pen$(7)
ST=Start(10)
EN=Start(10)+Length(10)
COUNT=ST
Wait 10
Repeat
If PAGE_NUM=0
PAGESTART(PAGE_NUM)=ST
Else
PAGESTART(PAGE_NUM)=COUNT+1
End If
LINES=0
Repeat
Inc LINES
Inc COUNT
TEMP=False
Repeat
A=Hunt(COUNT To EN,Chr$(10))
If(A-COUNT>78) or A=0
Add COUNT,78
TEMP=True
Else
COUNT=A
End If
Until COUNT=>EN or A<>0 or TEMP=True
Until LINES=25 or COUNT=>EN
PAGEEND(PAGE_NUM)=COUNT
Inc PAGE_NUM
Until COUNT=>EN
PAGEEND(PAGE_NUM-1)=EN
PAGE_SHOW[0]
CURRENT_PAGE=0
End Proc
Procedure PAGE_SHOW[NUM]
Shared PAGESTART(),PAGEEND(),PAGE_NUM
Cls
Inverse On
Centre At(,26)+"~~~~~~~~ PAGE:"+Str$(NUM+1)+" ~~~~~~~~"
Inverse Off
Centre At(,28)+Pen$(3)+"Q or ESC - Exit, Cursor Down - Next Page, Cursor Up - Page Up."+Pen$(7)
Home
ST=Start(10)
Z=0 : Print " ";
For LOP=PAGESTART(NUM) To PAGEEND(NUM)
A=Peek(LOP)
Print Chr$(A);
If A=9 : Add Z,3 : End If
If(Z>78) or(A=13) or(A=10)
If A<>13 and A<>10
Print Chr$(13) : Print "~ "; : Z=1
Else
Print Chr$(13); : Print " "; : Z=0
End If
End If
Next LOP
End Proc