home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
AMOS PD CD
/
amospdcd.iso
/
301-325
/
apd305
/
help.acc
/
help.amosSourceCode
< prev
next >
Wrap
AMOS Source Code
|
1987-02-25
|
14KB
|
511 lines
' ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
' AMOS Ascii Reader
'
' By P.J.Hickman
'
' (c) 1990 Mandarin Software
' ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Default
If Chip Free+Fast Free<100000
Close Workbench
Close Editor
End If
If Areg(1)
F$="AMOS:Help/Acc_Help.Lnk"
HELP_CALLED=True
Else
Screen Close 0
HELP_CALLED=False
End If
Get Rom Fonts
SET_UP_SCREENS
' -----------------------------------------------------------------------
' Define global variables for ascii reader bit
' -----------------------------------------------------------------------
Dim PAGESTART(100),PAGEEND(100)
FILE_PRESENT=False
CURRENT_PAGE=0
PAGE_LENGTH=23
' -----------------------------------------------------------------------
' Define global variables for link file bit
' -----------------------------------------------------------------------
Dim OPTION$(7,1)
For LOP=0 To 7
OPTION$(LOP,0)=""
OPTION$(LOP,1)=""
Next LOP
MENU_TITLE$=Space$(60)
AMOUNT_OF_OPTIONS=0
LINK_FILE_PRESENT=False
LINK_MENU_DISPLAYED=False
LINK_SELECTED=0
' -----------------------------------------------------------------------
' Global variables for alert box
' -----------------------------------------------------------------------
Dim LINE$(5),BUTTON$(3)
' -----------------------------------------------------------------------
Screen 2
If HELP_CALLED
FILE_LOAD
F$=""
End If
Repeat
Repeat
Screen 1
POSITION1=Mouse Zone
Screen 2
POSITION2=Mouse Zone
Screen 1
CLICK=Mouse Click
Until CLICK
If POSITION1=1 Then FINISH
If POSITION1=2 and Not LINK_MENU_DISPLAYED Then CHANGE_RES
If POSITION1=3 Then FILE_LOAD
If POSITION1=4 and FILE_PRESENT and Not LINK_MENU_DISPLAYED Then CHOOSE_PRINT
If POSITION1=5 and FILE_PRESENT and Not LINK_MENU_DISPLAYED Then PAGE_UP
If POSITION1=6 and FILE_PRESENT and Not LINK_MENU_DISPLAYED Then PAGE_DOWN
If POSITION1=7 and FILE_PRESENT and LINK_FILE_PRESENT and LINK_MENU_DISPLAYED
PAGE_SHOW[CURRENT_PAGE]
LINK_MENU_DISPLAYED=False
POSITION1=0
End If
If POSITION1=7 and LINK_FILE_PRESENT and Not LINK_MENU_DISPLAYED
DISPLAY_MENU
POSITION1=0
End If
If POSITION2>0 and POSITION2=<(AMOUNT_OF_OPTIONS+1) and POSITION2<>LINK_SELECTED and LINK_MENU_DISPLAYED
LINK_SELECTED=POSITION2
LINK_LOADER
End If
Until False
' -----------------------------------------------------------------------
' Finish the Ascii Reader.
' -----------------------------------------------------------------------
Procedure FINISH
Shared F$
If F$="AMOS:Help/Acc_Help.Lnk"
Screen 2
Clw
Centre "Please remember that this Ascii Reader uses a lot of memory."
Print
Centre "You should erase it from memory using the 'NEW OTHERS' option"
Print
Centre "from the editor menu."
Boom
Timer=0
Repeat : Wait Vbl : Until Mouse Click or Timer>200
End If
Run "Menu.Amos"
End
End Proc
' -----------------------------------------------------------------------
' Aaron Fothergill's (slightly altered to work in hires) Alert Box
' (Uses ZONE's 11+ and returns the button number as a PARAM)
' -----------------------------------------------------------------------
Procedure ALERT[W,H,BACK_COL,LINE_COL,NB,NL]
Shared LINE$(),BUTTON$()
Screen 2
TEMP=0
W=W*8
H=H*8
X=(Screen Width/2)-W/2
Y=10
Get Block 241,0,Y-2,Screen Width,H+6
Ink BACK_COL
Bar X,Y-2 To X+W,Y+H
Ink LINE_COL
Box X+1,Y-2 To X+W-1,Y+H-1
S=W/8/(NB+1)+1
Paper BACK_COL
Pen LINE_COL
For LOP=0 To NL
Locate 0,Y Text(Y)+1+LOP
Centre LINE$(LOP)
Next LOP
TEMP=0
While TEMP<>NB
Locate X Text(X)+S/2+S*TEMP,Y Text(Y+H)-2
Print Border$(Zone$(BUTTON$(TEMP),TEMP+10),2);
Inc TEMP
Wend
TEMP=0
Repeat
Repeat : Until Mouse Click and Mouse Key=1
TEMP=Mouse Zone
Until TEMP<>0
Put Block 241,0,Y-2
Del Block 241
Add TEMP,-9
End Proc[TEMP]
' -----------------------------------------------------------------------
Procedure CHOOSE_PRINT
Shared LINE$(),BUTTON$(),ENOUGH_MEM
If Fast Free+Chip Free>35000
ENOUGH_MEM=True
Else
ENOUGH_MEM=False
End If
If ENOUGH_MEM
LINE$(0)="How much of the file would you like to print?"
BUTTON$(0)="Just a page"
BUTTON$(1)="All of it!!"
BUTTON$(2)="CANCEL"
ALERT[52,7,0,1,3,1]
If Param=1
PAGE_PRINT
Else
If Param=2
FILE_PRINT
End If
End If
Else
LINE$(0)="Sorry, you need more memory to do this."
LINE$(2)="Print this file from Workbench instead."
BUTTON$(0)="Thanks for the reminder"
ALERT[44,8,0,1,1,3]
End If
End Proc
' -----------------------------------------------------------------------
Procedure MENU_TITLE_PRINT
Shared MENU_TITLE$
Centre At(,1)+MENU_TITLE$
For LOP=1 To Len(MENU_TITLE$)+2
TEMP$=TEMP$+"~"
Next LOP
Centre At(,2)+TEMP$
End Proc
' -----------------------------------------------------------------------
Procedure DISPLAY_MENU
Shared MENU_TITLE$,OPTION$(),AMOUNT_OF_OPTIONS,LINK_MENU_DISPLAYED
Screen 2
Cls 0
MENU_TITLE_PRINT
NUM=1
For LOP=5 To((AMOUNT_OF_OPTIONS)*2)+5 Step 2
Print At(14,LOP);NUM;At(14,LOP);"[";At(16,LOP);"] ";OPTION$(NUM-1,0)
Inc NUM
Next LOP
Inverse On
Centre At(,21)+"PLEASE CLICK ON THE OPTION YOU WISH TO VIEW."
Inverse Off
LINK_MENU_DISPLAYED=True
End Proc
' -----------------------------------------------------------------------
Procedure LINK_FILE_PROCESS
Shared LINK_FILE_PRESENT
LINK_FILE_PRESENT=True
MENU_TITLE_PRINT
DISPLAY_MENU
Limit Mouse X Hard(1,0),Y Hard(1,0) To X Hard(1,319),Y Hard(2,168)
End Proc
' -----------------------------------------------------------------------
Procedure FILE_PRINT
Shared FILE_LENGTH,LINE$(),BUTTON$()
On Error Goto FATEL_ERROR1 :
For LOP=Start(10) To Start(10)+Length(10)
A=Peek(LOP)
Lprint Chr$(A);
If A=10 Then Lprint Chr$(13);
Next LOP
Lprint
RECOVER_1:
Pop Proc
FATEL_ERROR1:
For LOP=1 To 5
Bell
Wait 2
Next LOP
LINE$(0)="There is a Printer problem!"
BUTTON$(0)="Sorry about that"
ALERT[32,7,0,1,1,1]
Resume RECOVER_1
End Proc
' -----------------------------------------------------------------------
Procedure CHANGE_RES
Shared PAGE_LENGTH,FILE_PRESENT
Ink 0
If PAGE_LENGTH=18
Text 107,17,"P"
PAGE_LENGTH=23
Else
Text 107,17,"N"
PAGE_LENGTH=18
End If
If FILE_PRESENT
FILE_PROCESS
End If
End Proc
' -----------------------------------------------------------------------
Procedure PAGE_PRINT
Shared CURRENT_PAGE,PAGESTART(),PAGEEND(),LINE$(),BUTTON$()
On Error Goto FATEL_ERROR2
ST=Start(10)
For LOP=PAGESTART(CURRENT_PAGE) To PAGEEND(CURRENT_PAGE)
A=Peek(LOP)
Lprint Chr$(A);
If A=10 Then Lprint Chr$(13);
Next LOP
Lprint
RECOVER_2:
Pop Proc
FATEL_ERROR2:
For LOP=1 To 5
Bell
Wait 2
Next LOP
LINE$(0)="There is a Printer problem!"
BUTTON$(0)="Sorry about that"
ALERT[32,7,0,1,1,1]
Resume RECOVER_2
End Proc
' -----------------------------------------------------------------------
Procedure PAGE_UP
Shared CURRENT_PAGE,PAGESTART(),PAGEEND()
If CURRENT_PAGE>0
Dec CURRENT_PAGE
PAGE_SHOW[CURRENT_PAGE]
End If
End Proc
' -----------------------------------------------------------------------
Procedure PAGE_DOWN
Shared CURRENT_PAGE,PAGESTART(),PAGEEND(),PAGE_NUM
If CURRENT_PAGE<PAGE_NUM-1
Inc CURRENT_PAGE
PAGE_SHOW[CURRENT_PAGE]
End If
End Proc
' -----------------------------------------------------------------------
Procedure FILE_LOAD
Shared FILE_PRESENT,FILE_LENGTH,LINK_FILE_PRESENT
Shared AMOUNT_OF_OPTIONS,MENU_TITLE$,OPTION$(),LINE$(),BUTTON$(),F$
On Error Goto FATEL_ERROR3
TEMP=1
If F$<>"AMOS:Help/Acc_Help.Lnk"
F$=Fsel$("WFT00:Docs/","TDC.Doc","Pick File To View")
Else
TEMP=3
End If
If Exist(F$)
Open In 1,F$
Input #1,IDTAG$
If IDTAG$="AARLFBYPJH"
TEMP=2
Input #1,MENU_TITLE$
Input #1,TEMP$
AMOUNT_OF_OPTIONS=Val(TEMP$)
For LOP=0 To AMOUNT_OF_OPTIONS
Input #1,OPTION$(LOP,0)
Input #1,OPTION$(LOP,1)
Next LOP
Close
LINK_FILE_PROCESS
Else
Close
FILE_LOADER[F$]
End If
Else
For LOP=1 To 5
Bell
Wait 2
Next LOP
If F$="AMOS:Help/Acc_Help.Lnk"
LINE$(0)=" I cannot find "
LINE$(1)=" 'AMOS:Help/Acc_Help.Lnk' "
BUTTON$(0)="Oh no......"
ALERT[23,8,0,1,1,2]
Else
For LOP=1 To 5
Bell
Wait 2
Next LOP
LINE$(0)="That File Does not"
LINE$(1)=" exist!!!!!!! !"
BUTTON$(0)=" Woops...... "
End If
End If
RECOVER_3:
F$=""
Pop Proc
FATEL_ERROR3:
Close
If FILE$<>""
For LOP=1 To 5
Bell
Wait 2
Next LOP
If TEMP=1
LINE$(0)="Woops, disc error!"
BUTTON$(0)="Never mind."
ALERT[21,7,0,1,1,1]
Else
If TEMP=2
LINE$(0)="I seem to be having"
LINE$(1)="a problem with this"
LINE$(2)=" Link file. "
BUTTON$(0)="Sorry......"
ALERT[22,8,0,1,1,3]
Else
If TEMP=3
LINE$(0)=" I cannot find "
LINE$(1)=" 'AMOS:Help/Acc_Help.Lnk' "
BUTTON$(0)="Oh no......"
ALERT[23,8,0,1,1,2]
End If
End If
End If
End If
Resume RECOVER_3
End Proc
' -----------------------------------------------------------------------
Procedure LINK_LOADER
Shared POSITION2,AMOUNT_OF_OPTIONS,MENU_TITLE$,OPTION$(),LINK_SELECTED,F$
FILE_LOADER[OPTION$(POSITION2-1,1)]
If Param=1 Then LINK_SELECTED=0
End Proc
' -----------------------------------------------------------------------
Procedure FILE_LOADER[F$]
Shared FILE_LENGTH,FILE_PRESENT,LINE$(),BUTTON$()
TEMP=0
On Error Goto FATEL_ERROR4
Open In 1,F$
FILE_LENGTH=Lof(1)
Close
Erase 10
If Chip Free+Fast Free>FILE_LENGTH+1024
Reserve As Work 10,FILE_LENGTH
Bload F$,Start(10)
FILE_PROCESS
FILE_PRESENT=True
Else
LINE$(0)=" Sorry, you do not have enough"
LINE$(1)=" memory to load this file. "
BUTTON$(0)=" Never mind.... "
ALERT[32,8,0,1,1,2]
End If
RECOVER_4:
Close
Pop Proc
FATEL_ERROR4:
TEMP=1
LINE$(0)="Woops, disc error!"
BUTTON$(0)="Never mind."
ALERT[21,7,0,1,1,1]
Resume RECOVER_4
End Proc[TEMP]
' -----------------------------------------------------------------------
Procedure SET_UP_SCREENS
Unpack 5 To 1
' ----- Show 'P' in TV icon to indicate PAL mode -----
Ink 0
Text 107,17,"P"
Restore POSITION_OF_ZONES
Reserve Zone 7
For LOP=1 To 7
Read X1,X2
Set Zone LOP,X1,4 To X2,27
Next LOP
OPEN_HIRES
Limit Mouse X Hard(1,0),Y Hard(1,0) To X Hard(1,320),Y Hard(2,200)
Reserve Zone 15
NUM=1
For LOP=5 To 19 Step 2
Print At(0,LOP);Zone$(Space$(79),NUM)
Inc NUM
Next LOP
Screen 1
POSITION_OF_ZONES:
Data 8,89,96,125,132,159,166,194,201,229,236,264,271,312
End Proc
' -----------------------------------------------------------------------
Procedure OPEN_HIRES
Shared PAGE_LENGTH
If PAGE_LENGTH=19
SCRLENGTH=168
Else
SCRLENGTH=210
End If
Screen Open 2,640,SCRLENGTH,2,Hires
Screen Display 2,,83,640,SCRLENGTH
Colour 1,$CCC
Curs Off : Flash Off : Cls 0
End Proc
' -----------------------------------------------------------------------
Procedure CONVERT
Shared FILE_LENGTH
ST=Start(10)
EN=Start(10)+FILE_LENGTH
Repeat
X=Hunt(ST To EN,Chr$(13))
If X<>0
Poke X,32
ST=X
End If
Until ST=EN or X=0
End Proc
' -----------------------------------------------------------------------
Procedure FILE_PROCESS
Shared PAGESTART(),PAGEEND(),FILE_LENGTH,PAGE_NUM,PAGE_LENGTH
Shared LINK_MENU_DISPLAYED,CURRENT_PAGE
PAGE_NUM=0
LINES=-1
TEMP=0
COUNT=0
Screen 2
Cls 0
Centre At(,9)+"Please Wait, Processing Document..........."
Bell
CONVERT
Centre At(,9)+"Please Wait, Paginating Document..........."
Bell
ST=Start(10)
EN=Start(10)+FILE_LENGTH
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>79) or A=0
Add COUNT,79
TEMP=True
Else
COUNT=A
End If
Until COUNT=>EN or A<>0 or TEMP=True
Until LINES=PAGE_LENGTH or COUNT=>EN
PAGEEND(PAGE_NUM)=COUNT
Inc PAGE_NUM
Until COUNT=>EN
PAGEEND(PAGE_NUM-1)=EN
Cls 0
PAGE_SHOW[0]
CURRENT_PAGE=0
Screen 1
LINK_MENU_DISPLAYED=False
End Proc
' -----------------------------------------------------------------------
Procedure PAGE_SHOW[NUM]
Shared PAGESTART(),PAGEEND(),FILE_LENGTH,PAGE_NUM,PAGE_LENGTH
Screen 2
Cls 0
Inverse On
Centre At(,PAGE_LENGTH+1)+"~~~~~~~~ PAGE:"+Str$(NUM+1)+" ~~~~~~~~"
Inverse Off
Home
ST=Start(10)
For LOP=PAGESTART(NUM) To PAGEEND(NUM)
A=Peek(LOP)
Print Chr$(A);
If A=10 Then Print Chr$(13);
Next LOP
Screen 1
End Proc