home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The Datafile PD-CD 5
/
DATAFILE_PDCD5.iso
/
utilities
/
d
/
discopy
/
!Discopy
/
Resources
/
Library
(
.txt
)
< prev
next >
Wrap
RISC OS BBC BASIC V Source
|
1996-04-06
|
7KB
|
325 lines
>Library
Contents:
1) System calls
2) Wimp script Handling
3) Wimp Handling
System calls library
--------------------
Get file length
Lib_FileLen(file$)
"OS_File",13,file$
,,,,length
=length
Get mode variables
Lib_ModeVar(var)
"OS_ReadModeVariable",
,var
,,val
Wait for click
Lib_MouseUp(time)
x,y,b
b<>0
-T>time
Redraw screen
Lib_RedrawScreen
#+xsize=
Lib_ModeVar(11)<<
Lib_ModeVar(4)
$+ysize=
Lib_ModeVar(12)<<
Lib_ModeVar(5)
"Wimp_ForceRedraw",-1,0,0,xsize,ysize
>> Upper case
Lib_Upper(wd$)
out$,pos,w$
pos=1:
wd$,pos,1)
w$>="a"
w$<="z"
out$+=
(w$)-32)
out$+=w$
pos+=1
pos>
1 =out$
Field
Lib_Field(
menu$)
seperator$=","
result$
83result$=
menu$,
menu$+seperator$,seperator$)-1)
9'menu$=
menu$,
(menu$)-
(result$)-1)
=result$
zerostr(ins)
= w$=""
?ins>0
(?ins)
ins+=1
Wimp script handling
--------------------
Load the script
Lib_ScriptLoad(scr$)
"OS_File",13,scr$
,,,,s_len
script s_len
"OS_File",12,scr$,script
Interpret the script
Lib_ScriptInt
script_pos=script
script_end=script+s_len
terminated=
com$=
Lib_ScriptGetCom
com$,":")
command$=
com$,pos-1)
tag$=
com$,
(com$)-pos)
Lib_ScriptHandle(
Lib_Upper(command$),tag$)
terminated
Get a command
Lib_ScriptGetCom
com$
com$=""
?script_pos<>10
com$+=
(?script_pos)
script_pos+=1
script_pos+=1
h =com$
Handle command
Lib_ScriptHandle(c$,t$)
sprite$
"MESSAGES":mess_list$=t$
"TASK":task_handle%=
Lib_InitTask(t$)
"ICONBAR":sprite$=
Lib_Field(t$):pos$=
Lib_Upper(
Lib_Field(t$))
wide=
Lib_Field(t$))
pos$="RIGHT"
pos=-1
pos=-2
v0i_bar_handle%=
Lib_BarIcon(sprite$,pos,wide)
"MENUS":
menu(
(t$)):menu_no=1
"MENUB":blen=
(t$):
menu_block blen
"MENU":menu(menu_no)=menu_block:next=
Lib_CreateMenu(menu_block,t$)
menu_block=next:menu_no+=1
"OPENT":w=1:
Lib_OpenTemplate(t$)
"WINDOWS":len=
Lib_Field(t$)):
window(
(t$)):
window_block% len
"WINDOWI":indir_len%=
(t$):
indir_block% len
&indir_end%=indir_block%+indir_len%
"LOADT":window(w)=
Lib_LoadTemplate(t$):w+=1
"CLOSET":
Lib_CloseTemplates
"ATTACH":menu=
Lib_Field(t$))
item=
Lib_Field(t$))
winh=
Lib_Field(t$))
Lib_AttachToMenu(menu(menu),item,window(winh))
"END":terminated=
"Error 0 Command '"+c$+"' not recognised in Wimp script"
Wimp handling
-------------
Initialise task
Lib_InitTask(task$)
block% 512,task% 4
waste_block% 256
adjust_bt%=1:menu_bt%=2
select_bt%=4:icon_bar%=-2
curmenu=-1
quit=
$task%="TASK"
messages 256
offset=0
mess_list$,",")
-messages!offset=
Lib_Field(mess_list$))
offset+=4
!messages!offset=
(mess_list$)
messages!(offset+4)=0
"Wimp_Initialise",310,!task%,task$,messages
vers%,id%
Lib_BarIcon(spr$,position%,width)
block%!0=position%
block%!4=0
block%!8=0
block%!12=width*2
block%!16=68
block%!20=&3002
$(block%+24)=spr$
"Wimp_CreateIcon",,block%
icon_handle%
=icon_handle%
Lib_CloseDown(taskid%)
"Wimp_CloseDown",taskid%,task%
Lib_MessageHandle(handle%)
handle%
0:quit=
Lib_CreateMenu(ptr,menu$)
title$=
Lib_Field(menu$)
(title$)<12
title$+=
$ptr=title$
ptr?12=7:ptr?13=2
ptr?14=7:ptr?15=0
wide=
(title$):ptr!20=44
ptr!24=0:item_ptr=ptr+4
menu$<>""
item_ptr+=24
item$=
Lib_Field(menu$)
!item_ptr=0
item_ptr!4=-1
item_ptr!8=&7000021
"#$%^",
item$))>0
item$)
"#":?item_ptr=?item_ptr
"$":?item_ptr=?item_ptr
"%":item_ptr?10=item_ptr?10
%1000000
"^":?item_ptr=?item_ptr
%100
item$=
item$)
(item$)>wide
wide=
(item$)
$(item_ptr+12)=item$+
#?item_ptr=?item_ptr
%10000000
ptr!16=(wide*8+6)*2
next=item_ptr+24
=next
Lib_MenuHigh(menu%)
item_ptr%
item_ptr%=menu%+28
height%=0
(?item_ptr%
%10000000) = 0
item_ptr%+=24
height%+=1
=96+(44*(height%+1))
Show a menu
Lib_ShowMenu(x,menu)
cur_menu=menu
Lib_MenuHigh(menu)
"Wimp_CreateMenu",,menu,x-100,y
Report an error and quit
Lib_ReportError(text$,no,line)
!waste_block%=no
)$(waste_block%+4)=text$+" @ "+
"Wimp_ReportError",waste_block%,1,"Discopy"
Lib_Report(text$)
!waste_block%=0
$(waste_block%+4)=text$+
"Wimp_ReportError",waste_block%,1,"Discopy"
Open a template file
Lib_OpenTemplate(file$)
"Wimp_OpenTemplate",,file$
Load a template. This looks complicated in the PRM's...
Lib_LoadTemplate(w$)
"Wimp_LoadTemplate",,window_block%,indir_block%,indir_end%,-1,w$,0
,,indir_block%
"Wimp_CreateWindow",,window_block%
handle%
=handle%
Close templates
Lib_CloseTemplates
"Wimp_CloseTemplate"
Attach a window to a menu
Lib_AttachToMenu(menu,item,winh)
menu!(28+24*(item-1)+4)=winh
Set an icons state
Lib_SetIconState(window,icon,eor,clear)
!waste_block%=window
waste_block%!4=icon
waste_block%!8=eor
waste_block%!12=clear
"Wimp_SetIconState",,waste_block%
Return status of icon
Lib_Selected(window,icon)
!waste_block%=window
waste_block%!4=icon
"Wimp_GetIconState",,waste_block%
flags=waste_block%+24
flag=!flags
&200000
=flag<>&200000
Lib_OpenWindow(window,x,y,xs,ys)
!waste_block%=window
waste_block%!4=x
waste_block%!8=y
waste_block%!12=xs
waste_block%!16=ys
waste_block%!20=0
waste_block%!24=0
waste_block%!28=-1
"Wimp_OpenWindow",,waste_block%
Lib_CloseWindow(window)
!waste_block%=window
"Wimp_CloseWindow",,waste_block%
Lib_GetIconIndir(win,icn)
!waste_block%=win
waste_block%!4=icn
"Wimp_GetIconState",,waste_block%
icon_dat=waste_block%+8
indir_ptr=icon_dat!20
=indir_ptr
Lib_ReadIconIndir(win,icn)
!waste_block%=win
waste_block%!4=icn
"Wimp_GetIconState",,waste_block%
icon_dat=waste_block%+8
indir_ptr=icon_dat!20
len=icon_dat!28
str$=""
a=indir_ptr
indir_ptr+len
str$+=
Q =str$
Lib_UpdateIconIndir(win,icn,str$)
!waste_block%=win
waste_block%!4=icn
"Wimp_GetIconState",,waste_block%
icon_dat=waste_block%+8
indir_ptr=icon_dat!20
$indir_ptr=str$
waste_block%!8=0
waste_block%!12=0
"Wimp_SetIconState",,waste_block%
Lib_CheckDAS
"OS_Byte",161,28
,,fso
(fso
%10)