home *** CD-ROM | disk | FTP | other *** search
/ The Datafile PD-CD 2 / DATAFILE_PDCD2.iso / utilities / _resource / !Resource / !RunImage (.txt) < prev    next >
RISC OS BBC BASIC V Source  |  1994-06-12  |  36KB  |  1,394 lines

  1.  >!RunImage
  2. "ERROR "+
  3. $+" at line "+
  4.  Set up variables and dimming memory.
  5.  ====================================
  6. CFirst=
  7. :Quit%=
  8. :Run%=
  9. :MaxFiles=99:SP=1:ScanItems%=0:ILen=&1000
  10. ISfname$="":ExName$="":ViewFile$="":FType$="":Virtual%=0:DragASprite=0
  11. GTaskN$="Resource Write":Ticked=0:Mod%=
  12. :Cur%=1:Mul$="":Debugging%=0
  13. KModName$="ResourceFiles":View=1:Total=1:Multiple%=0:Next%=0:FileOpen%=0
  14.  Block%1024,Block2% 512,Window% &1000,Ind% ILen,FListMenu &1000,Font% 256
  15.  Menu% 400,Object$(MaxFiles),Positioned$(MaxFiles),ScanName$(MaxFiles)
  16.  ScanPos$(99),ObType%(MaxFiles),ScanLen%(99),ScanType%(99):Free=Ind%
  17.  Scale% 32,Trans% 32:Verbose%=
  18. :ModSave$="Module":FailDrag%=
  19.  Clear the font memory and start messagetrans file.
  20.  ==================================================
  21.  X=0 
  22.  256:Font%?X=0:
  23. StartMessage
  24.  Now here's the clever bit,  I'm calculating how much memory
  25.  I've used so I can reduce the wimpslot to the minimum.
  26.  ===========================================================
  27.  "OS_ReadMemMapInfo" 
  28.  PageSize%:Size%=
  29. :Size%+=8*1024
  30. ;Temp=Size% 
  31.  PageSize%:Size%=Size% 
  32.  PageSize%:Size%+=1
  33. Temp>(PageSize%/2) 
  34.  Size%+=1
  35. CSize%=Size%*PageSize%:
  36. =&8000+Size%:
  37.  "Wimp_SlotSize",Size%,-1
  38. $OSize%=Size%:Address=Size%+&8000
  39. Error(1,
  40. $+" at line "+
  41.  Start the task and kill any other active version of this program.
  42.  =================================================================
  43. Block%!0=0
  44.  "Wimp_Initialise",310,&4B534154,TaskN$,Block% 
  45.  WimpVer,THandle%
  46. Kill(TaskN$)
  47.  Open the template file and load the windows.
  48.  ============================================
  49.  "Wimp_OpenTemplate",,"<Resource$Dir>.Templates"
  50. !;Main%=
  51. CreateWindow("Main"):File%=
  52. CreateWindow("File")
  53. ";Save%=
  54. CreateWindow("Save"):Info%=
  55. CreateWindow("Info")
  56. #IFileInfo%=
  57. CreateWindow("FileInfo"):Choices%=
  58. CreateWindow("Choices")
  59. $EPane%=
  60. CreateWindow("Pane"):Operation%=
  61. CreateWindow("Operation")
  62.  Debugging% 
  63.  Debug%=
  64. CreateWindow("Debug")
  65.  "Wimp_CloseTemplate"
  66.  Set up the menu, iconbar and blank all the text icons.
  67.  ======================================================
  68. SetUpMenu(Menu%):
  69. DisplayText:First=
  70. IconBar:
  71. Blank
  72.  Icon%=2 
  73. IconText(Operation%,Icon%,""):
  74.  "Font_FindFont",,"Homerton.Medium",12*16,12*16 
  75.  FileLHandle%
  76. ,FTe=FileLHandle%:
  77.  Font%?Te=0 
  78.  Font%?Te+=1 
  79.  "Font_LoseFont",Te
  80.  Read in the choices and select the pane window accordingly.
  81.  ===========================================================
  82. Choices("<Resource$Dir>.Choices"):
  83. Select(Pane%,1,Run%)
  84. Select(Pane%,0,Multiple%):
  85. IconText(Pane%,3,Mul$)
  86. Select(Pane%,8,Virtual%)
  87.  Debugging% 
  88. 34Block%!0=Debug%:
  89.  "Wimp_GetWindowState",,Block%
  90.  "Wimp_OpenWindow",,Block%
  91. Error(2,
  92. $+" at line "+
  93.  Right here we go and poll.
  94.  ==========================
  95.  "Wimp_Poll",1,Block% 
  96.  Reason%
  97.  Reason% 
  98. Redraw
  99. OpeningWindow
  100. ClosingWindow
  101. Button
  102. DragBoxSave
  103. Keyboard(Block%!24)
  104. MenuSelect
  105.  17,18:
  106. Receive
  107.  Quit%
  108.  Lose all the fonts and close the messagetrans file.
  109.  ===================================================
  110.  L=0 
  111.  255:Y=Font%?L:
  112.  Y>0:
  113.  "Font_LoseFont",L:Y-=1:
  114.  "Font_LoseFont",Ifhandle%:
  115.  "MessageTrans_CloseFile",Filedesc%
  116. ClosingWindow
  117.  Block%!0 
  118.  Main%:
  119.  "Wimp_CloseWindow",,Block%:Block%!0=File%
  120.  Choices%:
  121.  "Wimp_CloseWindow",,Block%:Block%!0=Pane%
  122.  "Wimp_CloseWindow",,Block%
  123. OpeningWindow
  124.  As I'm using a pane I need to reposition the pane on top of my
  125.  choices window.  To make it easier I'm using two different
  126.  Block%.
  127.  ==============================================================
  128.  Block%!0 
  129.  Choices%
  130. ]Mminx=Block%!4:miny=Block%!8:maxx=Block%!12:maxy=Block%!16:Block2%!0=Pane%
  131.  "Wimp_GetWindowState",,Block2%:lx=Block2%!12-Block2%!4
  132. _Ely=Block2%!16-Block2%!8:Block2%!4=minx+26:Block2%!12=Block2%!4+lx
  133. `CBlock2%!16=maxy-24:Block2%!8=Block2%!16-ly:Block2%!28=Block%!28
  134.  "Wimp_OpenWindow",,Block2%:Block%!28=Pane%
  135.  "Wimp_OpenWindow",,Block%
  136. IconBar
  137. h@!Block%=-5:Block%!4=0:Block%!8=-16:Block%!12=80:Block%!16=82
  138.  "Font_FindFont",,"Homerton.Medium",12*16,12*16 
  139.  Ifhandle%
  140. j4Block%!20=(Ifhandle%<<24)+%11000100001011+(1<<6)
  141.  IconSpr% 14,IconText% 14
  142. lF$IconSpr%="sromapps;F17"+
  143. 0:$IconText%="Write":Block%!24=IconText%
  144. m"Block%!28=IconSpr%:Block%!32=1
  145.  Prioritised to be just right of Apps Icon.
  146.  ==========================================
  147.  "Wimp_CreateIcon",&45000000,Block% 
  148.  BarIcon%
  149. DragEnd
  150.  When a drag has finished, close the window and replace the sprite
  151.  =================================================================
  152.  WindowDrag% 
  153.  File%:Block2%!0=WindowDrag%:
  154.  "Wimp_CloseWindow",,Block2%
  155.  Save%:
  156.  DestWindow% 
  157.  Save%,Main%,File%,Choices%,Pane%,Choices%,Operation%,FileInfo%,Menu%
  158. z0FailDrag%=
  159.  PROCIconText(Save%,1,ModSave$)
  160.  Block2%!0=Save%:
  161.  "Wimp_CloseWindow",,Block2%
  162. ~MBlock2%!0=WindowDrag%:Block2%!4=IconDrag%:
  163.  "Wimp_GetIconState",,Block2%
  164. ValidText(WindowDrag%,IconDrag%,TextDrag$)
  165. CreateWindow(WName$)
  166.  Handle%
  167.  "Wimp_LoadTemplate",,Window%,Free,Ind%+ILen,Font%,WName$ 
  168.  ,,Free
  169.  "Wimp_CreateWindow",,Window% 
  170.  Handle%
  171. =Handle%
  172. DragBoxSave
  173.  "Wimp_GetPointerInfo",,Block%:DestWindow%=Block%!12
  174. +Block%!20=Block%!12:Block%!24=Block%!16
  175. MBlock%!28=Block%!0:Block%!32=Block%!4:Block%!36=0:Block%!0=64:Block%!12=0
  176. 8Block%!16=1:Block%!40=FType%:$(Block%+44)=Sfname$+
  177.  Replace the sprite and close the window.
  178.  ========================================
  179. DragEnd
  180.  FailDrag%=
  181.  "Wimp_SendMessage",18,Block%,Block%!20,Block%!24
  182. FailDrag%=
  183. Receive
  184.  Block%!16 
  185.  0:Quit%=
  186. DataSaveAck
  187. DataLoad
  188.  &502:
  189.  &40040:
  190. NetMessage
  191.  &400C1:
  192. ModeChange
  193.  &400CC:
  194. Iconising
  195. DataSaveAck
  196.  DragASprite 
  197.  "DragASprite_Stop"
  198. DestName$=
  199. Strip(Block%+44)
  200.  DraggingWindow% 
  201.  File%:
  202. DataSave_File
  203.  Save%:
  204. DataSave_Save
  205.  FileInfo%:
  206. DataSave_FileInfo
  207.  Pane%:
  208. DataSave_Pane
  209. DataSave_File:
  210.  A:A=0:A$=DestName$
  211. A$,9)="Resources" 
  212. A$,"."):A=
  213. A$,"."):A$=
  214.  A$-A):
  215.  Mod% 
  216. "Change%=(Positioned$(Cur%)="")
  217. DestName$,A$):DestName$=
  218. DestName$,A-2)
  219. ?Positioned$(Cur%)=DestName$:
  220.  Change% 
  221.  Next%+=1:Cur%=Next%
  222. DestName$,A$):DestName$=
  223. DestName$,A-2)
  224. 6Positioned$(Next%+1)=DestName$:Next%+=1:Cur%=Next%
  225. =Block%!0=File%:
  226.  "Wimp_CloseWindow",,Block%:
  227. DisplayText
  228.  Mod% 
  229.  Mod%=
  230. DataSave_Save
  231. DestName$,9)="Resources" 
  232. ;TotalLen=0:
  233.  f=1 
  234.  Next%:TotalLen+=
  235. Count(Object$(f)):
  236. TotalLen+=16*1024
  237. @Temp=TotalLen 
  238.  PageSize%:Slot=TotalLen 
  239.  PageSize%:Slot+=1:
  240.  Temp>(PageSize%/2) 
  241.  PageSize%+=1
  242. ASlot=Slot*PageSize%:
  243.  "Wimp_SlotSize",Size%+Slot,-1 
  244.  NSize%
  245.  NSize%=Size% 
  246. Dialogue(1234,"Not enough memory,  I need "+
  247. Slot/1024+"k free",1,""):
  248.  "Wimp_CreateMenu",-1:
  249. MakeMod:
  250.  "Wimp_SlotSize",Size%,-1 
  251.  NSize%
  252.  Size%<>NSize% 
  253. Dialogue(1234,"Not been able to free memory",1,"")
  254.  "Wimp_CreateMenu",-1
  255.  DestName$="<Wimp$Scrap>" 
  256. HBlock%!16=3:Block%!36=Size%:
  257.  "Wimp_SendMessage",18,Block%,Block%!4
  258. IconText(Save%,1,DestName$)
  259. ModSave$=DestName$
  260. DataSave_FileInfo
  261.  Number,A$
  262. DestName$,9)="Resources" 
  263.  Verbose% 
  264. IconText(Operation%,2,"Retrieve")
  265. A$=DestName$
  266.  IconDrag% 
  267.  Verbose% 
  268. IconText(Operation%,4,"Retrieving single file")
  269. IconText(Operation%,3,
  270. Right(ScanName$(SP)))
  271. Retrieve(SP)
  272.  DestName$="<Wimp$Scrap>" 
  273. HBlock%!16=3:Block%!36=Size%:
  274.  "Wimp_SendMessage",18,Block%,Block%!4
  275.  Verbose% 
  276. IconText(Operation%,4,"Retrieving all files")
  277.  DestName$<>"<Wimp$Scrap>" 
  278.  Number=1 
  279.  ScanItems%
  280.  Verbose% 
  281. IconText(Operation%,3,
  282. Right(ScanName$(Number)))
  283. CreateDirectorys(A$+ScanPos$(Number))
  284. 7DestName$=A$+ScanPos$(Number)+"."+ScanName$(Number)
  285. Retrieve(Number)
  286. CreateDirectorys(A$)
  287.  Path$,B$,A
  288.     B$=""
  289. A$,"."):Path$=
  290. A$,A):A$=
  291.  A$-A)
  292. A$,".")
  293.  A<>0
  294. "CDir "+Path$+B$+
  295. A$,A-1)
  296. B$=B$+
  297. A$,A-1)+".":
  298.  A$-A)
  299. A$,".")
  300. "CDir "+Path$+B$+
  301. A$,A-1)
  302. Retrieve(Number)
  303.  x,N,B$,Name$,Loc,Off,A,B,Finish%:Loc=0:Finish%=
  304. FileOpen%=
  305. (DestName$):X=
  306.  ExName$
  307. #X=StartOfData:
  308.  "Hourglass_On"
  309. :Ptr%=
  310. GetWord:
  311.  Ptr%<>0 
  312. #X+Ptr%-4:Load=
  313. GetWord:Exec=
  314. GetWord:Len=
  315. GetWord:Acc=
  316. GetWord
  317. &B$="":A=
  318.  A<>0:B$+=
  319. *Name$=
  320. Right(B$):Loc+=1:
  321.  Loc=Number 
  322. #X:[OPT 0:ALIGN:]:
  323. #X=P%
  324. %Len2=
  325. GetWord:
  326. ClaimSlot(Len) 
  327.  "OS_GBPB",4,X,Address,Len
  328.  "OS_GBPB",2,N,Address,Len:Finish%=
  329. 'Off=1:
  330.  Off<>Len+1:
  331. #X:Off+=1
  332.  "Hourglass_Percentage",100*(Off/Len)
  333. :Finish%=
  334.  "Wimp_SlotSize",Size%,-1
  335.  Loc>=Number 
  336.  Finish%=
  337.  Finish%:
  338.  #N:FileOpen%=
  339. "Settype "+DestName$+" "+
  340. ~(ScanType%(Number))
  341.  "Hourglass_Off"
  342. ClaimSlot(Extra)
  343.  OK%,A$,X:X=Extra
  344.  A$="":A$=STR$(X MOD 1024)+" Bytes.":X=X DIV 1024
  345.  A$=STR$(X MOD 1024)+"K "+A$:X=X DIV 1024
  346.  A$=STR$