home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The Datafile PD-CD 5
/
DATAFILE_PDCD5.iso
/
utilities
/
a
/
ampcalc
/
!AmpCalc
/
!RunImage
(
.txt
)
< prev
next >
Wrap
RISC OS BBC BASIC V Source
|
1994-02-13
|
13KB
|
618 lines
>AmpCalc
version 1.77 - Sun 13th February 94
Copyright
A. M. Pereira of 'Armful
%vers$="1.77 (13th February 1994)"
q% 1024, iicon 2048, menu 76:iend=iicon+2048:ip=iicon
mem$(9):undo$=""
a%=1
mem$(a%)
"AmpCalc - The amazing calculator!","Written by Ampy","An ArmFul production"
"Contact: 2:251/16.50 @fidonet","Have you registered?"
"What junk shall I put in these memories?","Cash donations ARE accepted :-)"
"This program is Freeware","Have fun!"
("<AmpCalc$Dir>.Config")
/temp$="Templates":dragwindows%=
:convswi%=
a$=
a$,1,1)<>"|"
b%=1
-
a$,b%,1))>64
a$,b%,1))<91
'
a$,b%,1)=
a$,b%,1))+32)
param$=
a$,":")+1)
a$,1,5)
4
"conve":
param$="text" temp$="TemplText"
4
"dragw":
param$,1,1)="n" dragwindows%=
0
"swico":
param$,1,1)="n" convswi%=
"Wimp_Initialise",200,&4b534154,"AmpCalc"
wimpv,task_h
"Wimp_OpenTemplate",,"<AmpCalc$Dir>."+temp$
"Wimp_LoadTemplate",,q%,ip,iend,-1,"calc",0
"Wimp_CreateWindow",,q%
calc_h%
"Wimp_LoadTemplate",,q%,ip,iend,-1,"ProgInfo",0
"Wimp_CreateWindow",,q%
info_h%
"Wimp_LoadTemplate",,q%,ip,iend,-1,"basswi",0
"Wimp_CreateWindow",,q%
basswi_h%
"Wimp_CloseTemplate"
wimpv=2
seticon(info_h%, 5, vers$)
seticon(info_h%, 6, vers$)
,M!q%=-1:q%!4=0:q%!8=0:q%!12=68:q%!16=68:q%!20=&3002:$(q%+24)="!ampcalc"+
"Wimp_CreateIcon",,q%
icbar
.F$menu="AmpCalc"+
0:menu!12=&70207:menu!16=160:menu!20=44:menu!24=0
/Emenu!28=&00:menu!32=info_h%:menu!36=&7000031:$(menu+40)="Info"+
0@menu!52=&80:menu!56=-1:menu!60=&7000031:$(menu+64)="Quit"+
base%=10:pollnull%=1
quit%=
error
"Wimp_Poll",%110000110000
pollnull%,q%
event
event
7$
"Wimp_OpenWindow",,q%
8%
"Wimp_CloseWindow",,q%
9,
q%!12=-2
barclick
winclick
keypress
!q%=1 quit%=
17,18:
message
quit%
"Wimp_CloseDown",task_h,&4b534154
message
q%!16
0:quit%=
filedrop
filedrop
q%!40
&fff:
L a%=!q%:b%=q%!4:c%=q%!8
droptext(
getfd)
!q%=a%:q%!4=b%
q%!12=c%
q%!16=4
q%!20=-2
q%!24=icbar
S*
"Wimp_SendMessage",17,q%,q%!4
&ffb:
basswi_open(
getfd)
getfd
fd$=""
fdchar$=""
X<256
fdchar$<>
fd$+=fdchar$
fdchar$=
(q%?X)
X+=1
barclick
(q%!8
%100)=%100
!q%=calc_h%
"Wimp_GetWindowState",,q%
q%!28=-1
"Wimp_OpenWindow",,q%
(q%!8
%010)=%010
"Wimp_CreateMenu",,menu,!q%-64,184
keypress
done%
done%=
q%!24=17 !q%=calc_h%:
"Wimp_CloseWindow",,q%:done%=
q%!24=13
eval:done%=
q%!24=19
swi:done%=
q%!24=2
tobin:done%=
q%!24=4
todec:done%=
q%!24=24
tohex:done%=
q%!24=25
tok:done%=
q%!24=11
tob:done%=
q%!24=61
equals:done%=
q%!24>&180
q%!24<&18A
recallmem:done%=
q%!24>&190
q%!24<&19A
setmem:done%=
q%!24=&1CA
undo$<>""
u$=
geticon(calc_h%, 0)
seticon(calc_h%, 0, undo$)
undo$=u$
done%=
done%
"Wimp_ProcessKey",q%!24
winclick
(q%!8=64
q%!8=16)
q%!12=info_h%
dragwin
q%!12=basswi_h%
q%!16
doconv
dontconv
%
(q%!8
%010)=0
dragwin
q%!12=calc_h%
q%!16
toasc
fromasc
tobin
todec
tohex
toswi
fromswi
spr16
'
eval :
multiply by 1 :-)
%
(q%!8
%010)=0
dragwin
dragwin
dragwindows%
q%!4=q%!12
"Wimp_GetWindowOutline",,q%+4
!q%=q%!4
q%!4=1
"Wimp_DragBox",,q%
toasc
seticon(calc_h%, 0,
cbase(
geticon(calc_h%, 0))))
fromasc
geticon(calc_h%, 0))>31
seticon(calc_h%, 0,
geticon(calc_h%, 0))))
geticon(calc_h%, 0), 1, 1)<"A"
fromswi
toswi
fromswi
swin=
geticon(calc_h%, 0))
"OS_SWINumberToString",swin,q%,600
q%?l=13
seticon(calc_h%, 0,
$q%))
toswi
seticon(calc_h%, 0, ""):
geticon(calc_h%, 0),1,10)="OS_WriteI+"
os_writei
"OS_SWINumberFromString",,
geticon(calc_h%, 0)
seticon(calc_h%, 0,
cbase(swi))
os_writei
!end$=
geticon(calc_h%,0),11)
end$<>"0"
(end$)=0 end$=
("ASC"+end$))
seticon(calc_h%, 0,
cbase(
(end$)+256))
tobin
seticon(calc_h%, 0, "%0"):
unsetbase
base%=2
3!q%=calc_h%:q%!4=4:q%!8=&b000000:q%!12=&f000000
"Wimp_SetIconState",,q%
geticon(calc_h%, 0)<>""
seticon(calc_h%, 0,
cbase(
geticon(calc_h%, 0))))
todec
seticon(calc_h%, 0, "0"):
unsetbase
base%=10
3!q%=calc_h%:q%!4=5:q%!8=&b000000:q%!12=&f000000
"Wimp_SetIconState",,q%
geticon(calc_h%, 0)<>""
seticon(calc_h%, 0,
cbase(
geticon(calc_h%, 0))))
tohex
seticon(calc_h%, 0, "&0"):
unsetbase
base%=16
3!q%=calc_h%:q%!4=6:q%!8=&b000000:q%!12=&f000000
"Wimp_SetIconState",,q%
geticon(calc_h%, 0)<>""
seticon(calc_h%, 0,
cbase(
geticon(calc_h%, 0))))
unsetbase
3!q%=calc_h%:q%!4=4:q%!8=&7000000:q%!12=&f000000
"Wimp_SetIconState",,q%
3!q%=calc_h%:q%!4=5:q%!8=&7000000:q%!12=&f000000
"Wimp_SetIconState",,q%
3!q%=calc_h%:q%!4=6:q%!8=&7000000:q%!12=&f000000
"Wimp_SetIconState",,q%
seticon(w, i, s$)
"Wimp_GetCaretPosition",,q%+200
q%!200=w
q%!204=i
(s$)<24
(s$)
ci=23
"Wimp_SetCaretPosition",q%!200,q%!204,-1,-1,-1,ci
4q%!600=w:q%!604=i:
"Wimp_GetIconState",,q%+600
$(q%!628)=s$
4q%!608=0:q%!612=0:
"Wimp_SetIconState",,q%+600
geticon(w, i):
x,x$
:!(q%+128)=w:!(q%+132)=i:
"Wimp_GetIconState",,q%+128
.x$="":x=q%!156:
?x>31:x$+=
?x:x+=1:
undo$=
geticon(calc_h%, 0)
check
0 :
toswi
1 :
seticon(calc_h%, 0,
cbase(
geticon(calc_h%, 0))))
cbase(val)
l,r$
base%
"OS_ConvertBinary4",
(val+0.5),q%+300,200
,l:r$="%"
10:$(q%+300)=
val:l=q%+300+
val:r$=""
"OS_ConvertHex8",
(val+0.5),q%+300,200
,l:r$="&"
p%=q%+300:
?p%=48:p%+=1:
?l=13:r$+=$p%:=r$
0, suspect SWI
1, suspect calculation
2, ignore
check
geticon(calc_h%, 0)="" =2
geticon(calc_h%,0))
geticon(calc_h%, 0))>0
seticon(calc_h%, 0,
cbase(
geticon(calc_h%, 0))/1024))
geticon(calc_h%, 0))>0
seticon(calc_h%, 0,
cbase(
geticon(calc_h%, 0))*1024))
geticon(calc_h%, 0))>0
geticon(calc_h%, 0))>0
??
seticon(calc_h%, 0,
cbase(
geticon(calc_h%, 0))/8))
geticon(calc_h%, 0))>0
geticon(calc_h%, 0))>0
H?
seticon(calc_h%, 0,
cbase(
geticon(calc_h%, 0))/4))
spr16
geticon(calc_h%, 0))>0
geticon(calc_h%, 0))>0
Q?
seticon(calc_h%, 0,
cbase(
geticon(calc_h%, 0))/2))
equals
geticon(calc_h%, 0)=""
seticon(calc_h%, 0, "=")
"Wimp_GetCaretPosition",,q%
"Wimp_SetCaretPosition",q%!200,q%!204,-1,-1,-1,1
error
a7!q%=
:$(q%+4)=
$+" (internal error code "+
+")"+
"Wimp_ReportError",q%,3,"AmpCalc"
,fatal
fatal=2 quit%=
:pollnull%=0
droptext(fn$)
total%, file%, line$
file%=
(fn$)
total%=0
#file%
q$="FEBBS"
line$=
#file%
line$,1,1)<>" "
o# line$=
line$,
line$," "))
q-
line$,1,1)=" " line$=
line$,2)
line$,1,1)<>" "
total%+=
(line$)
t
#file%
#file%=0
line$=
#file%
z-
line$,1,1)="#"
line$,1,1)="0"
line$=
line$,24)
}-
line$,1,1)=" " line$=
line$,2)
line$,1,1)<>" "
total%+=
(line$)
#file%
#file%
seticon(calc_h%, 0,
cbase(total%))
basswi_open(fn$)
seticon(basswi_h%, 6, fn$)
!q%=basswi_h%
"Wimp_GetWindowState",,q%
q%!28=-1
"Wimp_OpenWindow",,q%
dontconv
!q%=basswi_h%
"Wimp_CloseWindow",,q%
issel(w, i)
q%!128=w:q%!132=i
"Wimp_GetIconState",,q%+128
=(q%!152
1<<21)
doconv
issel(basswi_h%, 4)
basswi_tonum(
geticon(basswi_h%, 6))
issel(basswi_h%, 5)
basswi_toname(
geticon(basswi_h%, 6))
basswi_tonum(f$)
hex%=
issel(basswi_h%, 7)
space%=
issel(basswi_h%, 8)
"Hourglass_On"
q2%=q%+&100
"OS_File",5,f$
,,,,len%
"OS_Module",6,,,len%+4096
,,outstart%
"OS_Module",7,,outstart%:
#in%:
"Hourglass_Off":
dontconv:
error:
outp%=outstart%
?outp%=
#in%:outp%+=1
?q%=
#in%
?q%=&ff
?outp%=&ff
outp%+=1
q%?1=
#in%
q%?2=
#in%
&
"OS_GBPB",4,in%,q%+3,q%?2-3
!q2%=!q%
a=q%+3:b=q2%+3
?a<>13
1
(?a=&C8
a?1=&99)
swicommand(a)
, !b=!a:
swicommand(a) a+=1:b+=1
a+=2:b+=2
sys$=""
?a=32
a+=1
?a=34
a+=1
?a<>34
sys$+=
a+=1
a+=1
=
"XOS_SWINumberFromString",,sys$
num ;flags
(flags
1)=1
$b=
34+sys$+
-
hex% $b="&"+
~num
space% $b=" "+$b
b+=
?b=?a
a+=1:b+=1
?b=?a
q2%?2=b+1-q2%
a=0
q2%?2-1
?outp%=q2%?a
outp%+=1
#in%
#in%
"OS_File",10,f$,&ffb,,outstart%,outp%
"OS_Module",7,,outstart%
"Hourglass_Off"
dontconv
basswi_toname(f$)
num=0
spa