home *** CD-ROM | disk | FTP | other *** search
/ Acorn User 3 / AUCD3.iso / airport / demos / webmaster / !UpdateSys / !RunImage (.txt) < prev    next >
RISC OS BBC BASIC V Source  |  1996-10-18  |  8KB  |  349 lines

  1.  > !RunImage
  2.  Authors : Neil Gardner, Updates by James Bye
  3.  Gratuitously hacked into !UpdateSystem by Paul Corke.
  4.  Aesthetic twiddling by Miles Sabin ;-)
  5. version$="1.00 (16 May 96)"
  6. initialise
  7. error
  8. "Wimp_Poll",0,q1% 
  9.  0    : 
  10. stage%=3 
  11. copy_files
  12.  2    : 
  13. "Wimp_OpenWindow",,q1%
  14.  3    : 
  15. "Wimp_CloseWindow",,q1%
  16. -             
  17. !q1%=SysUpdate% 
  18. shutdown:
  19.  6    : 
  20. mouseclick
  21.  7    : 
  22. decodedrag
  23.  9    : 
  24. menuselect
  25.  17,18: 
  26. receive(r%)
  27. initialise
  28. error_flag%=3
  29.  ws% 2048:wsend%=ws%+2048
  30.  menufree% 256:menuend%=menufree%+256
  31.  q1% 256, q2% 512
  32. "Wimp_Initialise",200,&4B534154,"UpdateSys"
  33. "Wimp_OpenTemplate",,"<UpdateSys$Dir>.Templates"
  34. "Wimp_LoadTemplate",,q2%,ws%,wsend%,-1,"info",0 
  35.  ,,ws%
  36. $(q2%!(88+96+20))=version$
  37. "Wimp_CreateWindow",,q2% 
  38.  info%
  39. "Wimp_LoadTemplate",,q2%,ws%,wsend%,-1,"system",0 
  40.  ,,ws%,,,,r6%
  41. file1%=q2%!(88+64+20)
  42. prompt%=q2%!(88+32+20)
  43. "Wimp_CreateWindow",,q2% 
  44.  SysUpdate%
  45. "Wimp_CloseTemplate"
  46. mainmenu%=
  47. crmenu
  48. "#UpdateSys,Info>info%,Quit"
  49.  file2% 255
  50. init_sys_window
  51. saveref%=0
  52. error_flag%=3
  53. getmodeinfo
  54. -I!q1%=SysUpdate%:
  55. "Wimp_GetWindowState",,q1%:
  56. "Wimp_OpenWindow",,q1%
  57. init_sys_window
  58. "OS_ReadVarVal","System$Dir",file1%,255,0,3 
  59.  ,,len%
  60. file1%?len%=13
  61. 3,$file2%="<UpdateSys$Dir>.System.!System"
  62. $prompt%="If the path shown is incorrect drag your !System directory here. Click Update to update the !System directory shown."
  63. stage%=1
  64. refresh_sys_window
  65. getmodeinfo
  66. q1%!0 = 4
  67. q1%!4 = 5
  68. q1%!8 = 11
  69. q1%!12= 12
  70. q1%!16= -1
  71. "OS_ReadVduVariables",q1%,q1%+20
  72. dx%=1<<(q1%!20)
  73. dy%=1<<(q1%!24)
  74. scrx1%=(q1%!28+1)*dx%
  75. scry1%=(q1%!32+1)*dy%
  76. mouseclick
  77. q1%!8 
  78. 4:   
  79. (q1%!12=SysUpdate%)
  80. (q1%!16=3) 
  81. continue
  82. J6         
  83. (q1%!12=SysUpdate%)
  84. (q1%!16=4) 
  85. shutdown
  86. 2:   
  87. q1%!12=SysUpdate% 
  88. domenu(mainmenu%,!q1%-64,q1%!4)
  89. continue
  90.  stage%=4 
  91. shutdown:
  92.  (?file1%=0) 
  93. errorbox("Master !System not yet set"):
  94. stage%=3
  95. decodedrag
  96.  f1%,f2%,h%,i%,mx%,my%,ext%
  97. W4f1%=
  98. ("<UpdateSys$Dir>.Output"):ext%=
  99. #f1%:
  100. f1%=filename%
  101.  f2%=f1%
  102.  f1%+=
  103. $f1%,".")
  104.  f1%=f2%
  105. "Wimp_GetPointerInfo",,q1%
  106. mx%=!q1%
  107. my%=q1%!4
  108. h%=q1%!12
  109. i%=q1%!16
  110. !q1%=(48+
  111. $f1%)
  112. q1%!12=0
  113. q1%!16=1
  114. q1%!20=h%
  115. q1%!24=i%
  116. q1%!28=mx%
  117. q1%!32=my%
  118. q1%!36=ext%
  119. q1%!40=&FFF
  120. $(q1%+44)=$f1%
  121. ?(q1%+44+
  122. $(q1%+44))=0
  123. "Wimp_SendMessage",17,q1%,h%,i%
  124. saveref%=q1%!8
  125. domenu(h%,x%,y%)
  126. r$menudata%=h%:menux%=x%:menuy%=y%
  127. "Wimp_CreateMenu",,h%,x%,y%
  128. menuselect
  129.  a$,i%
  130. "Wimp_DecodeMenu",,menudata%,q1%,
  131. 200," ") 
  132.  ,,,a$
  133. a$="" 
  134. a$="Quit" 
  135. shutdown:
  136. rtoz(p%)
  137.  ?p%<>0 q$+=
  138. ?p%:p%+=1:
  139. receive(r%)
  140.  name$,i%,x%
  141.  q1%!16 
  142. shutdown:
  143.  file dropped from application - return filename
  144. 3       
  145. ok("Application data cannot be merged")
  146.        
  147.  file dropped from Filer - identify object
  148.  stage% 
  149. check_type
  150. "         $file1%=
  151. rtoz(q1%+44)
  152. =         $prompt%="Drag the new !System into this window"
  153.           
  154. refresh_sys_window
  155. 8         $prompt%="Please wait ... processing files"
  156.           
  157. refresh_sys_window
  158.          stage%=3
  159. &502: 
  160. interactive_help
  161. &400C1: 
  162. getmodeinfo
  163. interactive_help
  164.  q1%!32 
  165. SysUpdate%: t$="This is the UpdateSys window.|M"
  166.  stage% 
  167. 1: t$ ="If the path shown is incorrect drag your !System directory here.|MClick SELECT on the Update button to update the !System directory shown."
  168. 2: t$ ="Drop the new !System directory on it."
  169. 4: t$ ="Update was successful.|MClick SELECT on the Cancel button to close this dialogue box."
  170. t$<>"" 
  171.  q1%!12=q1%!8
  172.  q1%!16=&503
  173.  $(q1%+20)=t$+
  174.  !q1%=(25+
  175. "Wimp_SendMessage",17,q1%,q1%!4
  176. check_type
  177. q1%!40<>&2000 
  178. upper(
  179. rtoz(q1%+44)),8)<>".!SYSTEM" 
  180. ok("This is not a !System directory")
  181. refresh_sys_window
  182. G!q2%=SysUpdate%:q2%!4=2:q2%!8=0:q2%!12=0:
  183. "Wimp_SetIconState",,q2%
  184. G!q2%=SysUpdate%:q2%!4=1:q2%!8=0:q2%!12=0:
  185. "Wimp_SetIconState",,q2%
  186. shutdown
  187. "Wimp_CloseDown"
  188. error
  189. error_flag%=3 
  190. errorbox("Unexpected error :- "+
  191. $+" ("+
  192. )+")")
  193. errorbox(
  194. error_flag%=3
  195. ok(e$)
  196. error_flag%=1
  197.  1,e$
  198. fatal(e$)
  199. error_flag%=2
  200.  1,e$
  201. errorbox(r$)
  202. !q1%=
  203. :$(q1%+4)=r$+
  204. "Wimp_ReportError",q1%,error_flag%,"UpdateSys utility" 
  205. r%=2 
  206. "Wimp_CloseDown":
  207. crmenu
  208.  m%,menu$,m$
  209.  (menufree%+28>menuend%) 
  210. fatal("Menu area full")
  211.  menu$
  212. menu$,2)="++"
  213.  menu$=
  214. menu$,
  215. menu$-2)+m$
  216. menuptr%=menufree%
  217. menu$,1)="#" i%=1:menutitle$=
  218. par(",") 
  219.  menutitle$=""
  220. $menuptr%=menutitle$
  221. menuptr%?12=7
  222. menuptr%?13=2
  223. menuptr%?14=7
  224. menuptr%?15=1
  225. menuptr%!16=196
  226. menuptr%!20=44
  227. menuptr%!24=0
  228. menuptr%+=28
  229. maxx%=
  230. menutitle$-3
  231.  item$=
  232. par(",")
  233. menuitem(item$)
  234.  item$=""
  235. m%=menufree%
  236. m%!16=(maxx%*8+6)*2
  237. menufree%=menuptr%
  238. menuitem(text$)
  239.  i%,flg%,subptr%,L%
  240.  text$="" menuptr%!-24=(menuptr%!-24)
  241.  (menuptr%+24>menuend%) 
  242. fatal("Menu area full")
  243. flg%=&00
  244. text$,">")
  245.  i%>0 
  246.  subptr%=
  247. text$,i%+1)
  248.  text$=
  249. text$,i%-1)
  250.  subptr%=-1
  251. text$,1)="#" text$=
  252. text$,
  253. text$-1):flg%+=&02
  254. menuptr%!0=flg%
  255. menuptr%!4=subptr%
  256. menuptr%!8=&07000021
  257. text$,1)="$" 
  258.  !menuptr%+=&04
  259.  menuptr%!8+=&100
  260. text$,"(")
  261.  i%>0 
  262.   L%=
  263. text$,i%+1)
  264.   text$=
  265. text$,i%-1)
  266.   L%=12
  267.  menuptr%!12=
  268. text$,2)
  269.  menuptr%!16=-1
  270.  menuptr%!20=L%
  271. L%>16 L%=16
  272.  text$=
  273. L%," ")
  274. text$<=12
  275.   $(menuptr%+12)=text$
  276. '  I%=
  277. workspace(
  278. text$+1):$I%=text$
  279. 8  menuptr%!12=I%:menuptr%!16=-1:menuptr%!20=
  280. text$+1
  281. "  menuptr%!8=menuptr%!8 
  282.  &100
  283. text$>maxx% maxx%=
  284. text$
  285. menuptr%+=24
  286. par(sep$)
  287. i1%=i%+1
  288. menu$+sep$,sep$,i1%)
  289. menu$,i1%,i%-i1%)
  290. shade(menuhandle%,item%)
  291. #Cmenuhandle%!(28+8+24*item%)=menuhandle%!(28+8+24*item%)
  292. &400000
  293. shade_status(menuhandle%,item%)
  294. '8= -((menuhandle%!(28+8+24*item%) 
  295.  &400000)=&400000)
  296. set_shade(menuhandle%,item%,value%)
  297. shade_status(menuhandle%,item%)<>value% 
  298. shade(menuhandle%,item%)
  299. tick(menuhandle%,item%)
  300. .9menuhandle%!(28+24*item%)=menuhandle%!(28+24*item%)
  301. tick_status(menuhandle%,item%)
  302. 2!= menuhandle%!(28+24*item%)
  303. set_tick(menuhandle%,item%,value%)
  304. tick_status(menuhandle%,item%)<>value% 
  305. tick(menuhandle%,item%)
  306. workspace(L%)
  307.  curws%+L%>ws%+maxws% 
  308. fatal("No more workspace")
  309. curws%+=L%
  310. =curws%-L%
  311. copy_files
  312. "Hourglass_On"
  313. "XOS_FSControl",26,$file2%,$file1%,%101001000000011 
  314.  r0%;reg%
  315.  (reg%
  316.  1)=1 
  317. A8 error_flag%=1:
  318. errorbox(
  319. rtoz(r0%+4)):error_flag%=3
  320. Bh $prompt%="!System update failed. Please correct the problem then drag your !System directory here."
  321.  stage%=1
  322. refresh_sys_window
  323.  OSCLI"copy "+$file2%+" "+$file1%+" rnf~c~va~dl~p~q~s~t"1
  324. stage%=4:
  325. alter_button
  326. Iu$prompt%="Your !System directory has been updated. Click
  327. SELECT on the Cancel button to close this dialogue box."
  328. refresh_sys_window
  329. "Hourglass_Off"
  330. upper(str$)
  331. rtn$, l%, c$
  332. rtn$=""
  333.  l%=1 
  334.   c$=
  335. str$,l%,1)
  336.  c$>="a" 
  337.  c$<="z" 
  338.      rtn$+=
  339.      rtn$+=c$
  340. Y    =rtn$
  341. alter_button
  342.  text%,blk%
  343.  blk% 256
  344. !blk%=SysUpdate%
  345. blk%!4=3
  346. blk%!8=&00400000
  347. blk%!12=&00400000
  348. "Wimp_SetIconState",,blk%
  349.