home *** CD-ROM | disk | FTP | other *** search
/ The Datafile PD-CD 5 / DATAFILE_PDCD5.iso / utilities / d / discopy / !Discopy / Resources / Library (.txt) < prev    next >
RISC OS BBC BASIC V Source  |  1996-04-06  |  7KB  |  325 lines

  1.  >Library
  2.  Contents:
  3.  1) System calls
  4.  2) Wimp script Handling
  5.  3) Wimp Handling
  6.  System calls library
  7.  --------------------
  8.  Get file length
  9. Lib_FileLen(file$)
  10.  "OS_File",13,file$ 
  11.  ,,,,length
  12. =length
  13.  Get mode variables
  14. Lib_ModeVar(var)
  15.  "OS_ReadModeVariable",
  16. ,var 
  17.  ,,val
  18.  Wait for click
  19. Lib_MouseUp(time)
  20.  x,y,b
  21.  b<>0 
  22. -T>time
  23.  Redraw screen
  24. Lib_RedrawScreen
  25. #+xsize=
  26. Lib_ModeVar(11)<<
  27. Lib_ModeVar(4)
  28. $+ysize=
  29. Lib_ModeVar(12)<<
  30. Lib_ModeVar(5)
  31.  "Wimp_ForceRedraw",-1,0,0,xsize,ysize
  32.  >> Upper case
  33. Lib_Upper(wd$)
  34.  out$,pos,w$
  35. pos=1:
  36. wd$,pos,1)
  37.  w$>="a" 
  38.  w$<="z" 
  39.  out$+=
  40. (w$)-32) 
  41.  out$+=w$
  42. pos+=1
  43.  pos>
  44. 1    =out$
  45.  Field
  46. Lib_Field(
  47.  menu$)
  48. seperator$=","
  49.  result$
  50. 83result$=
  51. menu$,
  52. menu$+seperator$,seperator$)-1)
  53. 9'menu$=
  54. menu$,
  55. (menu$)-
  56. (result$)-1)
  57. =result$
  58. zerostr(ins)
  59. =    w$=""
  60.  ?ins>0
  61. (?ins)
  62. ins+=1
  63.  Wimp script handling
  64.  --------------------
  65.  Load the script
  66. Lib_ScriptLoad(scr$)
  67.  "OS_File",13,scr$ 
  68.  ,,,,s_len
  69.  script s_len
  70.  "OS_File",12,scr$,script
  71.  Interpret the script
  72. Lib_ScriptInt
  73. script_pos=script
  74. script_end=script+s_len
  75. terminated=
  76. com$=
  77. Lib_ScriptGetCom
  78. com$,":")
  79. command$=
  80. com$,pos-1)
  81. tag$=
  82. com$,
  83. (com$)-pos)
  84. Lib_ScriptHandle(
  85. Lib_Upper(command$),tag$)
  86.  terminated
  87.  Get a command
  88. Lib_ScriptGetCom
  89.  com$
  90. com$=""
  91.  ?script_pos<>10
  92. com$+=
  93. (?script_pos)
  94. script_pos+=1
  95. script_pos+=1
  96. h    =com$
  97.  Handle command
  98. Lib_ScriptHandle(c$,t$)
  99.  sprite$
  100.  "MESSAGES":mess_list$=t$
  101.  "TASK":task_handle%=
  102. Lib_InitTask(t$)
  103.  "ICONBAR":sprite$=
  104. Lib_Field(t$):pos$=
  105. Lib_Upper(
  106. Lib_Field(t$))
  107. wide=
  108. Lib_Field(t$))
  109.  pos$="RIGHT" 
  110.  pos=-1 
  111.  pos=-2
  112. v0i_bar_handle%=
  113. Lib_BarIcon(sprite$,pos,wide)
  114.  "MENUS":
  115.  menu(
  116. (t$)):menu_no=1
  117.  "MENUB":blen=
  118. (t$):
  119.  menu_block blen
  120.  "MENU":menu(menu_no)=menu_block:next=
  121. Lib_CreateMenu(menu_block,t$)
  122. menu_block=next:menu_no+=1
  123.  "OPENT":w=1:
  124. Lib_OpenTemplate(t$)
  125.  "WINDOWS":len=
  126. Lib_Field(t$)):
  127.  window(
  128. (t$)):
  129.  window_block% len
  130.  "WINDOWI":indir_len%=
  131. (t$):
  132.  indir_block% len
  133. &indir_end%=indir_block%+indir_len%
  134.  "LOADT":window(w)=
  135. Lib_LoadTemplate(t$):w+=1
  136.  "CLOSET":
  137. Lib_CloseTemplates
  138.  "ATTACH":menu=
  139. Lib_Field(t$))
  140. item=
  141. Lib_Field(t$))
  142. winh=
  143. Lib_Field(t$))
  144. Lib_AttachToMenu(menu(menu),item,window(winh))
  145.  "END":terminated=
  146.  "Error 0 Command '"+c$+"' not recognised in Wimp script"
  147.  Wimp handling
  148.  -------------
  149.  Initialise task
  150. Lib_InitTask(task$)
  151.  block% 512,task% 4
  152.  waste_block% 256
  153. adjust_bt%=1:menu_bt%=2
  154. select_bt%=4:icon_bar%=-2
  155. curmenu=-1
  156. quit=
  157. $task%="TASK"
  158.  messages 256
  159. offset=0
  160. mess_list$,",")
  161. -messages!offset=
  162. Lib_Field(mess_list$))
  163. offset+=4
  164. !messages!offset=
  165. (mess_list$)
  166. messages!(offset+4)=0
  167.  "Wimp_Initialise",310,!task%,task$,messages 
  168.  vers%,id%
  169. Lib_BarIcon(spr$,position%,width)
  170. block%!0=position%
  171. block%!4=0
  172. block%!8=0
  173. block%!12=width*2
  174. block%!16=68
  175. block%!20=&3002
  176. $(block%+24)=spr$
  177.  "Wimp_CreateIcon",,block% 
  178.  icon_handle%
  179. =icon_handle%
  180. Lib_CloseDown(taskid%)
  181.  "Wimp_CloseDown",taskid%,task%
  182. Lib_MessageHandle(handle%)
  183.  handle% 
  184.  0:quit=
  185. Lib_CreateMenu(ptr,menu$)
  186. title$=
  187. Lib_Field(menu$)
  188. (title$)<12 
  189.  title$+=
  190. $ptr=title$
  191. ptr?12=7:ptr?13=2
  192. ptr?14=7:ptr?15=0
  193. wide=
  194. (title$):ptr!20=44
  195. ptr!24=0:item_ptr=ptr+4
  196.  menu$<>""
  197. item_ptr+=24
  198. item$=
  199. Lib_Field(menu$)
  200. !item_ptr=0
  201. item_ptr!4=-1
  202. item_ptr!8=&7000021
  203. "#$%^",
  204. item$))>0
  205. item$) 
  206.  "#":?item_ptr=?item_ptr 
  207.  "$":?item_ptr=?item_ptr 
  208.  "%":item_ptr?10=item_ptr?10 
  209.  %1000000
  210.  "^":?item_ptr=?item_ptr 
  211.  %100
  212. item$=
  213. item$)
  214. (item$)>wide 
  215.  wide=
  216. (item$)
  217. $(item_ptr+12)=item$+
  218. #?item_ptr=?item_ptr 
  219.  %10000000
  220. ptr!16=(wide*8+6)*2
  221. next=item_ptr+24
  222.     =next
  223. Lib_MenuHigh(menu%)
  224.  item_ptr%
  225. item_ptr%=menu%+28
  226. height%=0
  227.  (?item_ptr% 
  228.  %10000000) = 0
  229. item_ptr%+=24
  230. height%+=1
  231. =96+(44*(height%+1))
  232.  Show a menu
  233. Lib_ShowMenu(x,menu)
  234. cur_menu=menu
  235. Lib_MenuHigh(menu)
  236.  "Wimp_CreateMenu",,menu,x-100,y
  237.  Report an error and quit
  238. Lib_ReportError(text$,no,line)
  239. !waste_block%=no
  240. )$(waste_block%+4)=text$+" @ "+
  241.  "Wimp_ReportError",waste_block%,1,"Discopy"
  242. Lib_Report(text$)
  243. !waste_block%=0
  244. $(waste_block%+4)=text$+
  245.  "Wimp_ReportError",waste_block%,1,"Discopy"
  246.  Open a template file
  247. Lib_OpenTemplate(file$)
  248.  "Wimp_OpenTemplate",,file$
  249.  Load a template. This looks complicated in the PRM's...
  250. Lib_LoadTemplate(w$)
  251.  "Wimp_LoadTemplate",,window_block%,indir_block%,indir_end%,-1,w$,0 
  252.  ,,indir_block%
  253.  "Wimp_CreateWindow",,window_block% 
  254.  handle%
  255. =handle%
  256.  Close templates
  257. Lib_CloseTemplates
  258. "Wimp_CloseTemplate"
  259.  Attach a window to a menu
  260. Lib_AttachToMenu(menu,item,winh)
  261.  menu!(28+24*(item-1)+4)=winh
  262.  Set an icons state
  263. Lib_SetIconState(window,icon,eor,clear)
  264. !waste_block%=window
  265. waste_block%!4=icon
  266. waste_block%!8=eor
  267. waste_block%!12=clear
  268.  "Wimp_SetIconState",,waste_block%
  269.  Return status of icon
  270. Lib_Selected(window,icon)
  271. !waste_block%=window
  272. waste_block%!4=icon
  273.  "Wimp_GetIconState",,waste_block%
  274. flags=waste_block%+24
  275. flag=!flags 
  276.  &200000
  277. =flag<>&200000
  278. Lib_OpenWindow(window,x,y,xs,ys)
  279. !waste_block%=window
  280. waste_block%!4=x
  281. waste_block%!8=y
  282. waste_block%!12=xs
  283. waste_block%!16=ys
  284. waste_block%!20=0
  285. waste_block%!24=0
  286. waste_block%!28=-1
  287.  "Wimp_OpenWindow",,waste_block%
  288. Lib_CloseWindow(window)
  289. !waste_block%=window
  290.  "Wimp_CloseWindow",,waste_block%
  291. Lib_GetIconIndir(win,icn)
  292. !waste_block%=win
  293. waste_block%!4=icn
  294.  "Wimp_GetIconState",,waste_block%
  295. icon_dat=waste_block%+8
  296. indir_ptr=icon_dat!20
  297. =indir_ptr
  298. Lib_ReadIconIndir(win,icn)
  299. !waste_block%=win
  300. waste_block%!4=icn
  301.  "Wimp_GetIconState",,waste_block%
  302. icon_dat=waste_block%+8
  303. indir_ptr=icon_dat!20
  304. len=icon_dat!28
  305. str$=""
  306.  a=indir_ptr 
  307.  indir_ptr+len
  308. str$+=
  309. Q    =str$
  310. Lib_UpdateIconIndir(win,icn,str$)
  311. !waste_block%=win
  312. waste_block%!4=icn
  313.  "Wimp_GetIconState",,waste_block%
  314. icon_dat=waste_block%+8
  315. indir_ptr=icon_dat!20
  316. $indir_ptr=str$
  317. waste_block%!8=0
  318. waste_block%!12=0
  319.  "Wimp_SetIconState",,waste_block%
  320. Lib_CheckDAS
  321.  "OS_Byte",161,28 
  322.  ,,fso
  323.  (fso 
  324.  %10) 
  325.