home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
AMOS PD CD
/
amospdcd.iso
/
401-425
/
apd410
/
director.amos
/
director.amosSourceCode
Wrap
AMOS Source Code
|
1992-05-17
|
17KB
|
735 lines
'
' First AUTHOR EJBER OZKAN
' PROJECT STARTED 1/5/91
'
' director V1.2
'
' THE DIRECTORY HELPER....1991-92
'
' i hope someone can improve this for a new version....
' How about a workbench 2 look and feel?!!...
' Or a complete rewrite....
' When adding commands try to keep the commands in its own
' separte PROCEDURE for other people to be able to use it, and for
' next PIX n MIX
' There are loads of REMS in the code so check it out!...
' HAVE FUN...
' Read Director Docs for more info...
'
'STOP PRESS
'found late bug in compiled version! when loading iff files if an error
'occurs instead of showing error it ooesnt!, wierd???
'
' /\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
'
' SETUP VARIABLES FOR USE IN ALL PROCEDURES
Screen Open 0,640,256,16,Hires
Cls 0 : Pen 2 : Paper 0 : Ink 2
Curs Off
Colour 1,$0
Screen Display 0,140,40,640,256
Global AX,DISKFREE,COUNT,FLAGUP,DRIV,TREE,EXNOT,Z
AX=1 : DISKFREE=0 : COUNT=0 : URE=0 : FLAGUP=0 : TREE=0
Dim F$(200),FILE$(200),CURDR$(10),SUB$(200),WE$(30),WE1$(30),WE2$(30)
Dim WEA$(30),WE3$(30),WE4$(30),WE5$(30),WE6$(30),PAT$(30)
Shared F$(),FILE$(),CURDR$(),SUB$(),PAT$()
'
SETUP
GATOPT
End
Procedure SETUP
' SHOW MOUSE POINTER AND SET MAIN DIRECTORY
'
Set Dir 30
Limit Mouse 130,40 To 430,270
Dir$="df0:"
'
' OPENS MAIN MENU SCREEN
'
' Screen Open 0,640,256,16,Hires
' Cls 0 : Pen 2 : Paper 0 : Ink 2
' Curs Off
' Colour 1,$0
' Screen Display 0,140,40,640,256
'
' OPENS MESSAGE SCREEN FOR OUTPUT
'
Screen Open 1,640,10,8,Hires
Cls 0 : Pen 2 : Paper 0 : Ink 2
Curs Off
Colour 1,$0
Screen Display 1,140,285,640,10
Cls 0 : Locate 0,0 : Print "The AMOS DIRECTORY HELPER -DIRECTOR- V1.2";
Screen 0
'
' LIST COMMANDS AND DRAW BOXS AROUND THEM FOR NEATNESS...
'
Locate 5,5 : Print "COPY "
Locate 5,7 : Print "DELETE"
Locate 5,9 : Print "RENAME"
Locate 5,11 : Print "MAKEDIR"
Locate 5,13 : Print "SHOW ASCII"
Locate 5,15 : Print "SHOW IFF"
Locate 5,17 : Print "PARENT"
Locate 5,19 : Print "DF0:"
Locate 5,25 : Print "QUIT"
Box 36,38 To 98,48
Box 36,54 To 98,64
Box 36,70 To 108,80
Box 36,86 To 108,96
Box 36,102 To 120,112
Box 36,118 To 108,128
Box 36,134 To 98,144
Box 36,150 To 98,160
Box 36,166 To 98,176
Box 36,182 To 98,192
Box 36,198 To 98,208
'
' CHECK IF SECOND DRIVE OR DRIVES EXISTS!
'
If Exist("df1:") Then Locate 5,21 : Print "DF1:" : EXNOT=1 : Else EXNOT=0
Locate 5,23 : Print "PATH:"
'
' OPEN WINDOWS FOR PRINTING TEXT ABOUT DRIVES ON!
' AND SETUP REQUIRED ZONES ON SCREEN FOR INPUT!
'
Reserve Zone 15
Set Zone 1,36,38 To 98,48
Set Zone 2,36,54 To 98,64
Set Zone 3,36,70 To 108,80
Set Zone 4,36,86 To 108,96
Set Zone 5,36,102 To 120,112
Set Zone 6,36,118 To 108,128
Set Zone 7,36,134 To 98,144
Set Zone 8,36,150 To 98,160
Set Zone 9,36,166 To 98,176
Set Zone 10,36,182 To 98,192
Set Zone 11,133,5 To 600,120
Set Zone 12,133,125 To 600,230
Set Zone 13,36,198 To 98,209
Screen 0
Locate 5,1 : Print Border$(Zone$("UP",14),1)
Locate 9,1 : Print Border$(Zone$("DOWN",15),1)
Locate 5,28 : Print Border$("STORM 1992",1)
Wind Open 1,130,5,59,15,1
Wind Open 2,130,125,59,15,1
Window AX
Clw
Curs Off
End Proc
Procedure GATOPT
'
' If an error occurs then switch error detection
' To the program so the program can deal with it.
'
On Error Goto CERROR
BEGIN:
'
' The Main Loop
'
Do
'
' CHECKS TO SEE IF THE POINTER HAS ENTERED A DEFINED ZONE ON SCREEN!
' IF IT HAS AND THE LEFT MOUSE BUTTON IS PRESSED THEN EXECUTE COMMAND!
'
QED=Mouse Zone
If QED=1 and Mouse Key=1 Then C0PYFILES : Screen 0
If QED=2 and Mouse Key=1 Then DELETE : Screen 0
If QED=3 and Mouse Key=1 Then AMOSRENAME : Screen 0
If QED=4 and Mouse Key=1 Then MAKDIR : Screen 0
If QED=5 and Mouse Key=1 Then TXTPRINT : Screen 0
If QED=6 and Mouse Key=1 Then PICT : Screen 0
If QED=7 and Mouse Key=1 Then GUARDIAN : Screen 0
If QED=8 and Mouse Key=1 Then SDIRDF0 : Screen 0
If QED=9 and Mouse Key=1 and EXNOT=1 Then SDIRDF1 : Screen 0
If QED=9 and Mouse Key=1 and EXNOT=0 Then Screen 0
If QED=10 and Mouse Key=1 Then SDIRPATH : Screen 0
If QED=11 and Mouse Key=1 Then Window 1 : AX=1 : Screen 0
If QED=12 and Mouse Key=1 Then Window 2 : AX=2 : Screen 0
If QED=13 and Mouse Key=1 Then QUIT : Screen 0
If QED=14 and Mouse Key=1 Then Gosub SCR0LLUP
If QED=15 and Mouse Key=1 Then Gosub SCR0LLDOWN
If Key State(76)=True Then Gosub SCR0LLUP
If Key State(77)=True Then Gosub SCR0LLDOWN
If Key State(78)=True Then Bell 63
If Key State(79)=True Then Bell 63
SW1=COUNT
Loop
'
' If available move up through the list of filenames
' In memory
'
SCR0LLUP:
If AX=1 Then Window 2
If AX=2 Then Window 1
Clw
Home : Curs Off
If FLAGUP=<0 Then Return
FLAGUP=FLAGUP-1
Print F$(FLAGUP);"<< - CURRENT FILE!"
Return
'
' If available move down through the list of filenames
' In memory
'
SCR0LLDOWN:
If AX=1 Then Window 2
If AX=2 Then Window 1
Clw
Home : Curs Off
If FLAGUP=>COUNT Then Return
FLAGUP=FLAGUP+1
Print F$(FLAGUP);"<< - CURRENT FILE!"
Return
'
' If an error does occur then zoom to the procedure
' For Error Reports!
'
CERROR:
DISKERROR
Goto BEGIN
End Proc
Procedure SDIRDF0
'
' Clears windows and sets up dir
'
Clw
Screen 1 : Pen 2 : Cls 0
Cls 0 : Locate 0,0 : Print "Listing The Directory!";
Screen 0 : Pen 2
Window AX
CURDR$="df0:" : DRIV=0
PAT$=Dir$
'
' check if user has ejected a disk from the drive!
'
If Exist(PAT$)=False Then ERRO1 : Pop Proc
'
' Fetch the first dir using basic
'
FILE$=Dir First$(CURDR$)
COUNT=-1
'
' Fetch the next until no more filenames are
' received from the disk
'
While FILE$<>""
Add COUNT,1
'
' put filename into a safe memory area
'
F$(COUNT)=FILE$
'
' fetch next filename
'
FILE$=Dir Next$
Wend
'
' Retrieve And List from memory all dirsand filenames
'
For WEARE=0 To COUNT
Print F$(WEARE)
Next WEARE
Screen 1 : Pen 2
Dir$=CURDR$
'
' Get current space left on drive from basic
'
DISKFREE=Dfree
Locate 0,0 : Print "SPACE LEFT ON DRIVE 0 is ";DISKFREE;
Screen 0
End Proc
Procedure SDIRDF1
'
' This Procedure Does the Same "thing"
' As "SDIRDF0" Execpt that it works with the second
' disk drive.
'
Clw
Screen 1 : Pen 2
Cls 0 : Locate 0,0 : Print "Listing The Directory! ";
Screen 0 : Pen 2
Window AX
PAT$=Dir$
If Exist(PAT$)=False Then ERRO1 : Pop Proc
CURDR$="df1:" : DRIV=1
FILE$=Dir First$(CURDR$)
COUNT=-1
While FILE$<>""
Add COUNT,1
F$(COUNT)=FILE$
FILE$=Dir Next$
Wend
For WEARE=0 To COUNT
Print F$(WEARE)
Next WEARE
Screen 1 : Pen 2
Dir$=CURDR$
DISKFREE=Dfree
Locate 0,0 : Print "SPACE LEFT ON DRIVE 1 is ";DISKFREE;
Screen 0
End Proc
Procedure SDIRPATH
'
' AMOS LOADS MEMORY WITH THE NAME OF ALL THE FILES ON A DISK
' BUT STORES THEM ON MEMORY WITH LOTS OF SPACES AND '*' ABOUT
' THESE HAVE TO BE "TAKEN OUT" IN ORDER FOR AMOS TO READ THE FILE!
'
' Check fif disk is still there!
'
If Exist(Dir$)=False Then ERRO1 : Pop Proc
PAT$=Dir$
'
' LOADS WE$ WITH THE CURRENT FILE NAME IN FULL
'
WE$=F$(FLAGUP)
'
' IDENTIFIES IF ITS A DIRECTORY OR A FILE!
' AMOS PUTS AN '*' IN FRONT OF EVERY DIRECTORY
'
WERROR$=Mid$(WE$,1,1)
If WERROR$<>"*" Then ERRO1 : Pop Proc : Screen 0
'
' GETS THE POSITION IN THE STRING WE$ WHERE A SPACE OCCURS!
' AND GETS RID OF SPACES TO MAKE A NEW STRING CALLED WE3$
'
P=Instr(WE$," ")
WE3$=Mid$(WE$,2,P-2)
'
' PATCHES THE CURRENT DRIVE STRING AND THE FILE "TOGETHER"
' AND CALLS IT WE5$
'
WE5$=PAT$+WE3$
If Exist(WE5$)=False Then ERRO1 : Pop Proc
Dir$=WE5$
FILE$=Dir First$(WE5$)
COUNT=-1
'
' Clean previous directory From memory
'
For ERSE=0 To 200 : F$(ERSE)="" : Next ERSE
While FILE$<>""
Add COUNT,1
F$(COUNT)=FILE$
FILE$=Dir Next$
Wend
For WEARE=0 To COUNT
Print F$(WEARE)
Next WEARE
End Proc
Procedure GUARDIAN
'
' An unused Procedure fore later development!
'
Parent
Clw
If DRIV=0 Then SDIRDF0
If DRIV=1 Then SDIRDF1
End Proc
Procedure DELETE
'
' Use the same teqnique to retreieve the filename
' from main memory
'
If DRIV=0 Then CURDR$="df0:"
If DRIV=1 Then CURDR$="df1:"
WE$=F$(FLAGUP)
WERROR$=Mid$(WE$,1,1)
If WERROR$<>" " Then ERRO1 : Pop Proc : Screen 0
P=Instr(WE$," ",2)
WE3$=Mid$(WE$,2,P-2)
WE5$=PAT$+WE3$
Paper 1 : Print WE5$ : Paper 1
'
' get input using requestor procedure
'
REQ[" ARE YOU SURE ? "," DELETE "+WE5$+"","CONTINUE","CANCEL"]
'
' if the user select cancel then return (POP PROC) else continue
'
If Z=2 Then Pop Proc
'
' KILL CHOOSEN FILE
'
DELETEIT:
'
' EASY COMMAD COMING HERE!
'
If Exist(WE5$)=False Then ERRO1 : Pop Proc
'
' just make sure the file is there and then delete it.
'
Kill WE5$
Screen 1
Locate 0,0
Print "File is deleted!...Check directory to be sure!?";
End Proc
Procedure ERRO1
'
' Error check type one
'
REQ[" ERROR ERROR ERROR ERROR!"," YOU CANT DO THAT!","CONTINUE",""]
End Proc
Procedure ERRO2
'
' Error Check Type two
'
Auto View On
REQ[" ERROR FORMAT OF FILE IS "," NOT OF REQUIRED TYPE!","CONTINUE",""]
End Proc
Procedure C0PYFILES
'
' GET ACTUAL NAME OF FILE AGAIN
'
PAT$=Dir$
If DRIV=0 Then CURDR$="df0:"
If DRIV=1 Then CURDR$="df1:"
WE$=F$(FLAGUP)
WERROR$=Mid$(WE$,1,1)
If WERROR$<>" " Then ERRO1 : Pop Proc : Screen 0
P=Instr(WE$," ",2)
WE3$=Mid$(WE$,2,P-2)
WE5$=PAT$+WE3$
'
REQ[" OKAY TO COPY?",WE5$,"CONTINUE"," CANCEL"]
'
' Check If 2 IS return FROM THE REQ Proc Then End
'
If Z=2 Then Pop Proc
Wait 30
Screen 1
Cls 0
Locate 0,0 : Curs Off
'
' now get form the user which drive to copy to...
'
REQ[" COPYFILE TO TARGET DRIVE",WE5$," DF0:"," DF1:"]
'
If Z=1 Then PAT$="DF0:" : AN$=PAT$+WE3$
If Z=2 Then PAT$="DF1:" : AN$=PAT$+WE3$
'
' COPY THAT FILE MAN!
'
FLEM:
Screen 1 : Cls 0 : Locate 0,0
Print "Enter path ";PAT$; : Input PAN$
'
'
'
AN$=PAT$+PAN$+WE3$
If Exist(WE5$) Then Screen 1 : Cls 0 : Locate 0,0 : Print "Copying ";WE5$;" To ";CURDR$;
'
' Open the file, get its length(size),close the file
' Erase memory bank 5 and then create bank five of required size
'
Open In 1,WE5$ : L=Lof(1) : Close 1 : Erase 5 : Reserve As Work 5,L
'
' Binary Load the file in to Memory bank 5
'
Bload WE5$,Start(5)
'
' Binary Save from memory bank 5 to the new filename
'
Bsave AN$,Start(5) To Start(5)+L : Erase 5
Screen 1 : Cls 0 : Locate 0,0 : Print "Finished Copying....";
End Proc
Procedure AMOSRENAME
'
' GET ACTUAL NAME OF FILE AGAIN
'
PAT$=Dir$
If DRIV=0 Then CURDR$="df0:"
If DRIV=1 Then CURDR$="df1:"
WE$=F$(FLAGUP)
WERROR$=Mid$(WE$,1,1)
If WERROR$<>" " Then ERRO1 : Pop Proc : Screen 0
P=Instr(WE$," ",2)
WE3$=Mid$(WE$,2,P-2)
WE5$=WE3$
Print PAT$+WE5$;" <<- File choosen!"
Screen 1
Curs Off
Cls 0
Locate 0,0
Line Input "ENTER NEW NAME OF CURRENT FILE (exact please!)-";AN$
'
' Check file and rename to new then exit procedure
'
If Exist(PAT$+WE5$) Then Rename PAT$+WE5$ To PAT$+AN$ : Pop Proc
'
' If procedure is not exited then call error proc 1
'
ERRO1
End Proc
Procedure MAKDIR
PAT$=Dir$
Screen 1
Curs Off
Cls 0
Locate 0,0
'
' Get name for new directory
'
Line Input "Name of new directory -";AN$
'
' does it already exist? then POP proc else continue
'
If Exist(PAT$+AN$)=True Then Cls 0 : Locate 0,0 : Print "ALREADY ON THE DISK!" : Pop Proc
'
' Call Mkdir from basic
'
Mkdir PAT$+AN$
Cls 0
Locate 0,0
Print "DONE !!!...";
End Proc
Procedure PICT
PAT$=Dir$
If DRIV=0 Then CURDR$="df0:"
If DRIV=1 Then CURDR$="df1:"
WE$=F$(FLAGUP)
WERROR$=Mid$(WE$,1,1)
If WERROR$<>" " Then ERRO1 : Pop Proc : Screen 0
P=Instr(WE$," ",2)
WE3$=Mid$(WE$,2,P-2)
WE5$=WE3$
Print PAT$+WE5$;" <<- File choosen!"
If Exist(PAT$+WE5$)=False Then Pop Proc
'
' turns Off amoses automatic viewing for reasons of
' tideness
'
Auto View Off
'
' load and create screen 2 for picture file
'
Load Iff PAT$+WE5$,2
'
' get registors if any for resolution and X,Y of file
'
A=Screen Base+72
SCX=Deek(A+4)
SCY=Deek(A+6)
REZ=1
If Btst(Deek(A),15)
REZ=2
End If
' get current screen it SHOULD be screen 2 if it is not
' then report error otherwise show screen
' sorry for natty little goto!(structured programs hurrah!)
' the program falls over if i dont do this! wierd!
S=Screen
If S=0 Then Screen Hide S : ERRO2 : Pop Proc
If S=1 Then Screen Hide S : ERRO2 : Pop Proc
If S=2 Then Goto VEW
VEW:
Screen To Front 2
Auto View On
View
'
' wait until users had enough and then close screen to svae memory
' and exit procedure.
' infinte loop until mouse button is pushed
'
Repeat
Until Mouse Key=1
Screen Close 2
Screen 0
End Proc
Procedure TXTPRINT
'
' GET ACTUAL NAME OF FILE AGAIN
'
' PAT$=Dir$
If DRIV=0 Then CURDR$="df0:"
If DRIV=1 Then CURDR$="df1:"
WE$=F$(FLAGUP)
WERROR$=Mid$(WE$,1,1)
If WERROR$<>" " Then ERRO1 : Pop Proc : Screen 0
P=Instr(WE$," ",2)
WE3$=Mid$(WE$,2,P-2)
WE5$=WE3$
Print WE5$;" <<- File choosen!"
'
' Open a HIRES screen for text file
'
Screen Open 2,640,256,4,Hires
Curs Off : Pen 2 : Paper 0 : Flash Off : Cls 0
Home
'
' Open file for output
'
Open In 1,WE5$
'
' get length of choosen file
'
LGTH=Lof(1)
CNT=0 : TAL=0
'
CHAR$=""
'
Repeat
Add CNT,1 : Add TAL,1
'
' get first character from file
'
CHAR$=Input$(1,1)
AI=Asc(CHAR$)
If AI=>128 Then DISKERROR : Screen Close 2 : Close 1 : Pop Proc
'
' get cursor position on screen so as to prevent the text
' disapearing before its read!
'
YC=Y Curs : XC=X Curs
'
' The following lines check for control characters
' in the ASCII file
' if a carraige return (ASCII = 13) is detected then print a new line
'
If CHAR$=Chr$(13) Then Print ""; : Locate 0,
'
' now check for end of line character (10)
'
If CHAR$=Chr$(10) Then Print ""; : Locate 0,
'
' and now a check for a tab character (9)
'
If CHAR$=Chr$(9) Then Print Tab$
'
' if the bottom of screen is reached
' dont scroll! instead wait for the user to push
' mouse button before proceeding.
'
If YC=>29 Then Gosub NXTPAGE : CNT=0
Print CHAR$;
CHAR$=""
Until TAL=LGTH
'
' Finished reading text
'
Locate 0,29 : Inverse On : Print "press mouse to continue"
Inverse Off
Repeat
Until Mouse Key=1
Screen Close 2
Close 1
Screen 0
Pop Proc
'
' Waits for user to read file and
' Clears screen for some more text
'
NXTPAGE:
Locate 0,29 : Inverse On : Print "press mouse for next page"
Inverse Off
Repeat
Until Mouse Key=1
Cls 0
Home
Return
End Proc
Procedure QUIT
'
' first check if they want to quit or not
'
Screen 1
Cls 0
Locate 0,0
'
' get input using the requestor procedure
'
REQ[" ARE YOU SURE YOU WANT TO QUIT? ","","CONTINUE","CANCEL"]
'
' If the user select cancel then return (POP PROC) else continue
'
If Z=2 Then Pop Proc
'
'
CLEARUPSYSTEM:
'
' Clear message text and say byebye!
'
Cls 0
Print "Thanx For using ADHDOS!... Ejber Ozkan @1991";
'
' Wait a bit for end message to be read
'
For I=0 To 100 : Wait Vbl : Next I
'
' End program here
'
Screen Close 0
Screen Close 1
End
End Proc
Procedure DISKERROR
ERR=Errn
REQ["OH NO! MAJOR ERROR REPORT","ERROR NO"+Str$(ERR)+"","CONTINUE","CONTINUE"]
End Proc
' Requester Procedure v1 Amiga Shopper
Procedure REQ[T1$,T2$,B1$,B2$]
Shared Z
'
' opens a nice new screen on top of old screen
'
Screen Open 7,640,60,4,Hires
Screen Display 7,130,110,,
Screen To Front 7
Screen 7
Limit Mouse 215,110 To 350,155
Show
Flash Off
Paper 0 : Cls : Curs Off
Palette $0,$444,$777,$FFF
View
Reserve Zone 2
'
' checks to see if the text is longer than 33 characters
' so that it can print it in the boxe without OVERFLOW
'
If Len(T1$)>33 Then T1$=Left$(T1$,33)
If Len(T2$)>33 Then T2$=Left$(T2$,33)
If Len(B1$)>8 Then B1$=Left$(B1$,8)
If Len(B2$)>8 Then B2$=Left$(B2$,8)
'
' draws pretty boxs to write on!
'
Ink 1 : Bar 170,0 To 470,52
Ink 3 : Bar 171,1 To 470,59
Ink 2 : Bar 171,1 To 468,58
Ink 0 : Box 180,10 To 458,30
Ink 3 : Draw 180,30 To 458,30
Ink 3 : Draw 458,30 To 458,10
If Len(B1$)>0
Ink 3 : Box 200,37 To 270,52
Ink 0 : Draw 200,52 To 270,52
Ink 0 : Draw 270,52 To 270,37
End If
If Len(B2$)>0
Ink 3 : Box 360,37 To 430,52
Ink 0 : Draw 360,52 To 430,52
Ink 0 : Draw 430,52 To 430,37
End If
Ink 0,2
'
' Prints text required from the params
'
Text 184,19,T1$
Text 184,27,T2$
Text 204,47,B1$
Text 364,47,B2$
'
' Sets up zones for mouse input
'
If Len(B1$)>0 Then Set Zone 1,200,37 To 270,52
If Len(B2$)>0 Then Set Zone 2,360,37 To 430,52
'
' Repeats loop below until the user selects an option
'
Screen To Front 7
Do
Z=Mouse Zone
If Z=1 and Mouse Key=1 Then Ink 0 : Box 200,37 To 270,52 : Ink 3 : Draw 200,52 To 270,52 : Ink 3 : Draw 270,52 To 270,37 : Wait 10 : Screen Close 7 : Screen 0 : Limit Mouse : Pop Proc
If Z=2 and Mouse Key=1 Then Ink 0 : Box 360,37 To 430,52 : Ink 3 : Draw 360,52 To 430,52 : Ink 3 : Draw 430,52 To 430,37 : Wait 10 : Screen Close 7 : Screen 0 : Limit Mouse : Pop Proc
Loop
End Proc