home *** CD-ROM | disk | FTP | other *** search
/ ARM Club 3 / TheARMClub_PDCD3.iso / hensa / postscript / psutils_1 / !PSUtils_!RunImage (.txt) < prev    next >
Encoding:
RISC OS BBC BASIC V Source  |  1995-08-11  |  47.7 KB  |  1,905 lines

  1.  !PsUsils - Front end to psutils package.
  2.  Frontend (C) Graham Jones, 1995
  3.  Psutils package (C) Angus Duggan
  4. memory(
  5.    Next initialise the application with the WIMP, giving the task name,
  6.    sprite name and selecting buffer size of 1024.
  7. wimp_init("PSUtils Frontend","!psutils",
  8. ,2048,200,0)
  9.    Set up out error trap :
  10. wimp_error(1,
  11. $+" at line "+
  12. wimp_quit
  13.  Setup various variables
  14.  CL$(6): 
  15.  6 command lines
  16.  wins%(6), psize%(6,2): 
  17.  pane% 2048
  18. pagespecs% = 
  19. malloc(24)
  20. psnupwin%=0
  21. pstopswin%=1
  22. psbookwin%=2
  23. epsffitwin%=3
  24. psresizewin%=4
  25. psselectwin%=5
  26. config_name$ = ""
  27. config_on_save% = 
  28. curr_selection% = psnupwin%
  29. infile$ = ""
  30. psize%(psnupwin%,0) = 1
  31. psize%(pstopswin%,0) = 1
  32. psize%(psresizewin%,0) = 1
  33. psize%(psresizewin%,1) = 1
  34. size_win% = -1
  35. big_page_open% = 
  36. pw% = 0: ph% = 0: sc = 1.0
  37. mag% = 1: div% = 1
  38. flags_off% = 4
  39. scale_off% = 5
  40. xoff_off% = 10
  41. yoff_off% = 15
  42. fl%    = %00000001
  43. fr%    = %00000010
  44. fu%    = %00000100
  45. fsc%   = %00001000
  46. fplus% = %00010000
  47. fend%  = %00100000
  48. foff%  = %01000000
  49.    Next initialise the templates routines. This takes no parameters.
  50. win_init(10)
  51. font_init
  52. ?Htrin% = 
  53. font_gethandle("Trinity.Medium", 12, 12) : 
  54.  Lets try this 
  55. temp_init
  56. transfer_init
  57. create_windows
  58. setup_menus
  59. mid_save% = 
  60. saving%=
  61. drag_action% = 1
  62. psnup_CL
  63. pstops_CL
  64. epsffit_CL
  65. psbook_CL
  66. psresize_CL
  67. psselect_CL
  68. wimp_poll(0,0,0)
  69.  Never reached but it doesn't feel right not being there!
  70. wimp_mainmenu
  71. create_windows
  72.    Now we can read the application's templates file :
  73. temp_readfile("<PSUtils$Dir>.Templates",2600)
  74. a$  info% = 
  75. win_createwin("Info")
  76. bB  psnup% = 
  77. win_createwin("PSNup") : wins%(psnupwin%) = psnup%
  78. cF  pstops% = 
  79. win_createwin("PsToPs") : wins%(pstopswin%) = pstops%
  80. dJ  epsffit% = 
  81. win_createwin("EpsfFit") : wins%(epsffitwin%) = epsffit%
  82. eF  psbook% = 
  83. win_createwin("PsBook") : wins%(psbookwin%) = psbook%
  84. fN  psresize% = 
  85. win_createwin("PsResize") : wins%(psresizewin%) = psresize%
  86. gN  psselect% = 
  87. win_createwin("PsSelect") : wins%(psselectwin%) = psselect%
  88. h)  savewin% = 
  89. win_createwin("SaveAs")
  90. i,  topspane% = 
  91. win_createwin("toPsPane")
  92. j0  pstopsedit% = 
  93. win_createwin("PstoPsEdit")
  94. get_pagesize(pw%, ph%)
  95. m7  sc = 216/pw%: sc1 = 184/ph%: 
  96. (sc1 < sc) sc = sc1
  97.   pw% = pw% * sc: ph% = ph% * sc
  98. win_resize(topspane%, pw%*sc, ph%*sc)
  99. win_closewin(topspane%)
  100. icon_shade(psnup%,5)
  101. icon_shade(psnup%,6)
  102. icon_settext(psnup%, 3, "A4")
  103. icon_shade(pstops%,5)
  104. icon_shade(pstops%,6)
  105. icon_settext(pstops%, 3, "A4")
  106. icon_shade(psresize%,5)
  107. icon_shade(psresize%,6)
  108. icon_settext(psresize%, 3, "A4")
  109. icon_shade(psresize%,13)
  110. icon_shade(psresize%,14)
  111. icon_settext(psresize%, 10, "A4")
  112. setup_menus
  113.  this_name$, i%
  114.    Next initialise the menu library, stating that we intend to have
  115.    2 menus (we can change this value later if more are needed).
  116. menu_init(3)
  117.    Create the first (number 0) menu, giving it a title of "Test App" and
  118.    giving it 3 entries :
  119. menu_header("PsUtils",0,8)
  120. menu_header("",1,1)
  121. menu_header("Page sizes",2,14)
  122.    Now create the 3 entries, one being "Info", the second "Sub Menu"
  123.    and the third "Quit".
  124. menu_additem(0,0,"Info",menu_dotted)
  125. menu_additem(0,2,"Ps to Ps",0)
  126. menu_additem(0,1,"Ps Nup",menu_tick)
  127. menu_additem(0,3,"Ps Book",0)
  128. menu_additem(0,4,"Epsf Fit",0)
  129. menu_additem(0,5,"Ps Resize",0)
  130. menu_additem(0,6,"Ps Select",menu_dotted)
  131. menu_additem(0,7,"Quit",0)
  132. menu_additem(1,0,"Configure",0)
  133.  i% = 1 
  134. menu_submenu(0,i%,1)
  135. menu_subwindow(0,0,info%)
  136. menu_additem(2,0,"Custom",menu_dotted)
  137.  i% = 1 
  138. #    this_name$ = 
  139. page_name(i%)
  140. @    this_name$ = 
  141. toupper(
  142. this_name$, 1)) + 
  143. this_name$, 2)
  144. (    
  145. menu_additem(2,i%,this_name$,0)
  146. event_menuselection(B%)
  147.    Find out what entry in the first menu was selected
  148.  _wimp_oldmenu%=0 
  149.  !B% 
  150.       
  151. 2             curr_selection% = curr_selection%
  152. A      
  153.  7:                       
  154.    Sub menu, follow it down
  155.              
  156. wimp_quit
  157.       
  158. #        
  159. pstops_menu(!B%, B%!4)
  160.         
  161. ,    
  162.  _wimp_oldmenu% = 2 
  163. page_menu(!B%)
  164. page_menu(sel%)
  165.   new_nup% = sel%
  166.   resize_in% = 0
  167.   to_shade% = 5
  168.   show_size% = 3
  169.   real_win% = size_win%
  170.  (size_win% < 0) 
  171.     real_win% = -size_win%
  172.     resize_in% = 1
  173.     to_shade% = 13
  174.     show_size% = 10
  175. *  this_win% = 
  176. which_winnum(real_win%)
  177. menu_untick(2, psize%(this_win%,resize_in%))
  178. -  psize%(this_win%,resize_in%) = new_nup%
  179. menu_tick(2, psize%(this_win%,resize_in%))
  180.  psize%(this_win%,resize_in%)=0 
  181. ,    
  182.  Un-grey out the width/height boxes
  183. 1    
  184. icon_unshade(wins%(this_win%),to_shade%)
  185. 3    
  186. icon_unshade(wins%(this_win%),to_shade%+1)
  187. /    
  188. icon_shade(wins%(this_win%),to_shade%)
  189. 1    
  190. icon_shade(wins%(this_win%),to_shade%+1)
  191.  psize%(this_win%,resize_in%) = 0 
  192. =    
  193. icon_settext(wins%(this_win%), show_size%, "Custom")
  194. =    this_name$ = 
  195. page_name(psize%(this_win%,resize_in%))
  196. A    this_name$ = 
  197. toupper(
  198. this_name$, 1)) + 
  199. this_name$, 2) 
  200. ?    
  201. icon_settext(wins%(this_win%), show_size%, this_name$)
  202. pstops_menu(sel%, sub%)
  203.  X%,Y%,x%,y%
  204.  There is only one menu item on the submenu and it must have been clicked.
  205.  (sub% = -1) 
  206. *    
  207. menu_untick(0, curr_selection%+1)
  208. $    curr_selection% = (sel%) - 1
  209. (    
  210. menu_tick(0, curr_selection%+1)
  211.     which% = sel%-1
  212. ;    
  213.  (big_page_open%) 
  214.  (which% = wins%(pstopswin%)) 
  215. )    
  216. win_getsize(wins%(which%),x%,y%)
  217. os_screensize(X%,Y%)
  218. 9    
  219. win_movewin(wins%(which%),(X%-x%)
  220.  2,(Y%-y%)
  221. call_setup(which%)
  222. call_setup(num%)
  223.  num% 
  224.  psnupwin%:
  225.       
  226. psnup_setup
  227.  pstopswin%:
  228.       
  229. pstops_setup
  230.  epsffitwin%:
  231.       
  232. epsffit_setup
  233.  psbookwin%:
  234.       
  235. psbook_setup
  236.  psresizewin%:
  237.       
  238. psresize_setup
  239.  psselectwin%:
  240.       
  241. psselect_setup
  242. call_CL(num%)
  243.  num% 
  244.  psnup%:
  245.       
  246. psnup_CL
  247.  pstops%:
  248.       
  249. pstops_CL
  250.  epsffit%:
  251.       
  252. epsffit_CL
  253.  psbook%:
  254.       
  255. psbook_CL
  256.  psresize%:
  257.       
  258. psresize_CL
  259.  psselect%:
  260.       
  261. psselect_CL
  262. event_iconbarselect(B%)
  263.  X%,Y%,x%,y%
  264.  saving% = 
  265. =    
  266.  (big_page_open%) 
  267.  (curr_selection% = pstopswin%) 
  268. 2    
  269. win_getsize(wins%(curr_selection%),x%,y%)
  270. os_screensize(X%,Y%)
  271. B    
  272. win_movewin(wins%(curr_selection%),(X%-x%)
  273.  2,(Y%-y%)
  274. $    
  275. call_setup(curr_selection%)
  276. transfer_willload(type%, open%)
  277. (    
  278.  (type% = &FF5) 
  279.  (open% = 
  280.  0     
  281.  if it's PostScript and not a dataopen
  282.        =
  283. "        
  284.        =
  285. $        
  286. %    ENDFN
  287. transfer_loadfile(name$, type%, is_safe%)
  288.  x%,y%,z%,w%,h%
  289.   infile$ = name$
  290. icon_settext(savewin%, 2, infile$)
  291.  Do a save drag to get an output filename, then get all the PSNup options set and call
  292.  the program
  293.  x%,y%,z%
  294. win_getsize(savewin%,w%,h%)          :   
  295.  Get window size into x%,y%
  296. win_movewin(savewin%,x%, y%)
  297. icon_setcaret(savewin%, 2, -1)
  298.   saving% = 
  299. savewin_click(icon%, but%)
  300.  Just got a mouse click, now check for a drag with it.
  301.  (icon%=0) 
  302.  ((but% = 16) 
  303.  (but% = 64)) 
  304. 8N    
  305. transfer_startdrag(
  306. icon_gettext(savewin%, 2), &FF5, 10, savewin%, 0)
  307. 9        
  308.  icon%=1 
  309. <,    
  310.  Check the file has a path with it.
  311. =-    outfile$ = 
  312. icon_gettext(savewin%, 2)
  313. outfile$, ".") = 0 
  314. ?h      hello%=
  315. wimp_messagebox(
  316. , "Warning from PSUtils","Drag the file icon to a directory to save")
  317.       
  318. A        
  319. B&    
  320.  if it has then save the file
  321. C>    
  322.  otherwise pop up a warning window and tell the user.
  323. D-    
  324. transfer_savefile(outfile$, &FF5, 0)
  325. E(    
  326.  but%=4 
  327. win_closewin(savewin%)
  328. F        
  329. click_ok(win%, but%)
  330.  which_win%
  331.  Any of the config windows.
  332. M%  which_win% = 
  333. win_findwin(win%)
  334. call_CL(which_win%)
  335. (which_win% = pstops%) 
  336. (but% = 1) 
  337. S0      
  338. win_resize(topspane%, pw%*sc, ph%*sc)
  339. T'      !pane% = 
  340. win_handle(pstops%)
  341. U*      
  342.  "Wimp_GetWindowState",, pane%
  343. V1      
  344.  "Wimp_SendMessage", 2, pane%, !pane%
  345. W#      
  346. win_redrawwin(topspane%)
  347. X        
  348.  mid_save% 
  349. \9    
  350. which_winnum(which_win%) = curr_selection%) 
  351.       mid_save% = 
  352. ^3      
  353. transfer_savefile(config_name$, &FF5, 0)
  354. _0      
  355.  Call the PROC to save the file .....
  356. `        
  357.  (but% = 4) 
  358. c!    
  359. win_closewin(which_win%)
  360. d8    
  361. (which_win% = pstops%) 
  362. win_closewin(topspane%)
  363. page_click(win%, but%, icon%)
  364.  but% <> 0 
  365.  x%,y%,z%
  366.     resize% = 
  367. l;    
  368. win_findwin(win%) = psresize%) 
  369.  (icon%=15)) 
  370.       resize% = 
  371. n(      new_win% = -
  372. win_findwin(win%)
  373.       new_real% = -new_win%
  374.       new_resize% = 1
  375. q        
  376. r'      new_win% = 
  377. win_findwin(win%)
  378.       new_real% = new_win%
  379.       new_resize% = 0
  380. u        
  381.     resize_in% = 0
  382.     real_win% = size_win%
  383. (size_win% < -1) 
  384. y       real_win% = -size_win%
  385.       resize_in% = 1
  386. {        
  387. |W    
  388. (real_win% <> -1) 
  389. menu_untick(2, psize%(
  390. which_winnum(real_win%),resize_in%))
  391.     size_win% = new_win%
  392.     real_win% = new_real%
  393. C    
  394. menu_tick(2, psize%(
  395. which_winnum(real_win%),new_resize%))
  396. menu_popup(2, x%,y%)
  397. event_mouseclick(B%)
  398.  B%!12=
  399. win_handle(savewin%) 
  400. savewin_click(B%!16, B%!8): 
  401. win_findwin(B%!12) = topspane%) 
  402. open_bigpage: 
  403.  B%!16=1 
  404. click_ok(B%!12, B%!8): 
  405. win_findwin(B%!12) = psnup%) 
  406. win_findwin(B%!12) = pstops%) 
  407. win_findwin(B%!12) = psresize%)) 
  408.  (B%!16=12)) 
  409. win_findwin(B%!12) = psresize%)) 
  410.  (B%!16=15)) 
  411. page_click(B%!12, B%!8, B%!16)
  412. open_bigpage
  413.  x%, y%, X%, Y%
  414.   big_page_open% = 
  415. win_closewin(pstops%): 
  416. win_closewin(topspane%)
  417. get_pagesize(x%, y%)
  418. win_setextent(pstopsedit%, 0, -y%*mag%/div%, x%*mag%/div%, 0)
  419. win_resize(pstopsedit%, x%*mag%/div%, y%*mag%/div%)
  420. os_screensize(X%,Y%)
  421. win_movewin(pstopsedit%,(X%-x%)
  422.  2,(Y%-y%)
  423. transfer_savefile(name$, type%, safe%)
  424.  saving%=
  425. win_closewin(savewin%)
  426.   saving%=
  427.  config_on_save% 
  428. 2    
  429. win_getsize(wins%(curr_selection%),x%,y%)
  430. os_screensize(X%,Y%)
  431. B    
  432. win_movewin(wins%(curr_selection%),(X%-x%)
  433.  2,(Y%-y%)
  434. $    
  435. call_setup(curr_selection%)
  436.     config_name$ = name$
  437.     mid_save% = 
  438.         
  439. \hello% = 
  440. wimp_messagebox(
  441. , "Command line", CL$(curr_selection%)+" "+infile$+" "+name$)
  442.  "Wimp_StartTask",CL$(curr_selection%)+" "+infile$+" "+name$
  443.  "OS_File",18,name$,&FF5
  444. psnup_CL
  445.  the selections
  446.  lscape$, seascape$, swap$, cols$, sheet$, page$, border$, scale$
  447.  size$, pages$
  448.  Get the variables to the command line
  449. icon_getselect(psnup%, 15) lscape$ = " -l" 
  450.  lscape$=""
  451. icon_getselect(psnup%, 16) seascape$ = " -r" 
  452.  seascape$=""
  453. icon_getselect(psnup%, 17) swap$ = " -f" 
  454.  swap$=""
  455. icon_getselect(psnup%, 18) cols$ = " -c" 
  456.  cols$=""
  457. icon_getselect(psnup%, 19) border$ = " -d"+
  458. icon_gettext(psnup%, 9) 
  459.  border$=""
  460. icon_getselect(psnup%, 20) scale$ = " -s"+
  461. icon_gettext(psnup%, 10) 
  462.  scale$=""
  463. icon_getselect(psnup%, 13) sheet$ = " -m"+
  464. icon_gettext(psnup%, 7) 
  465.  sheet$=""
  466. icon_getselect(psnup%, 14) page$ = " -b"+
  467. icon_gettext(psnup%, 8) 
  468.  page$=""
  469. -  pages$ = " -"+
  470. icon_gettext(psnup%, 11)
  471.  pages$ = " -" pages$=""
  472.  psize%(psnupwin%,0) = 0 
  473. M    size$ = " -w"+
  474. icon_gettext(psnup%, 5)+" -h"+
  475. icon_gettext(psnup%, 6)
  476. 5    size$ = " -p"+
  477. page_name(psize%(psnupwin%,0))
  478. l  CL$(psnupwin%) = "psnup "+size$+lscape$+seascape$+swap$+cols$+page$+sheet$+border$+scale$+pages$+" -q"
  479.  Only needs the files now
  480. pstops_CL
  481.  the selections
  482.   border$, size$, pages$, bind$
  483.  Get the variables to the command line
  484. icon_getselect(pstops%, 9) bind$ = " -b" 
  485.  bind$=""
  486. icon_getselect(pstops%, 11) border$ = " -d"+
  487. icon_gettext(pstops%, 10) 
  488.  border$=""
  489. -  pages$ = " "+
  490. icon_gettext(pstops%, 13)
  491.  pages$ = " " pages$=" Default!!!!"
  492.  psize%(pstopswin%,0) = 0 
  493. O    size$ = " -w"+
  494. icon_gettext(pstops%, 5)+" -h"+
  495. icon_gettext(pstops%, 6)
  496. 6    size$ = " -p"+
  497. page_name(psize%(pstopswin%,0))
  498. B  CL$(pstopswin%) = "pstops "+size$+bind$+border$+" -q"+pages$
  499. pagespecs(pages$)
  500. get_pagesize(pw%, ph%)
  501. 7  sc = 216/pw%: sc1 = 184/ph%: 
  502. (sc1 < sc) sc = sc1
  503.   pw% = pw% * sc: ph% = ph% * sc
  504. epsffit_CL
  505.  c$,r$,a$,m$,s$,llx$,lly$,urx$,ury$
  506. icon_getselect(epsffit%, 0) c$ = " -c" 
  507.  c$=""
  508. icon_getselect(epsffit%, 2) m$ = " -m" 
  509.  m$=""
  510. icon_getselect(epsffit%, 3) r$ = " -r" 
  511.  r$=""
  512. icon_getselect(epsffit%, 4) s$ = " -s" 
  513.  s$=""
  514. icon_getselect(epsffit%, 5) a$ = " -a" 
  515.  a$=""
  516. )  llx$=" "+
  517. icon_gettext(epsffit%, 6)
  518. )  lly$=" "+
  519. icon_gettext(epsffit%, 8)
  520. *  urx$=" "+
  521. icon_gettext(epsffit%, 10)
  522. *  ury$=" "+
  523. icon_gettext(epsffit%, 12)
  524.  (llx$ = " ") 
  525.  (lly$ = " ") 
  526.  (urx$ = " ") 
  527.  (ury$ = " ") 
  528. }    fred% = 
  529. wimp_messagebox(
  530. , "Warning", "EpsfFit: Must define x and y coords for lower left and upper right position")
  531. F  CL$(epsffitwin%) = "epsffit "+c$+r$+a$+m$+s$+llx$+lly$+urx$+ury$
  532. psbook_CL
  533.  sig$
  534. *  sig$=" -s"+
  535. icon_gettext(psbook%, 2)
  536.  sig$=" -s" sig$=""
  537. &  CL$(psbookwin%)="psbook -q"+sig$
  538. psresize_CL
  539.  size$,minsize$
  540.  psize%(psresizewin%,0) = 0 
  541. S    size$ = " -w"+
  542. icon_gettext(psresize%, 5)+" -h"+
  543. icon_gettext(psresize%, 6)
  544. 8    size$ = " -p"+
  545. page_name(psize%(psresizewin%,0))
  546.  psize%(psresizewin%,1) = 0 
  547. W    insize$ = " -W"+
  548. icon_gettext(psresize%, 13)+" -H"+
  549. icon_gettext(psresize%, 14)
  550. :    insize$ = " -P"+
  551. page_name(psize%(psresizewin%,1))
  552. 6  CL$(psresizewin%)="psresize"+size$+insize$+" -q"
  553. psselect_CL
  554.  e$,o$,r$,pages$
  555. icon_getselect(psselect%, 0) e$ = " -e" 
  556.  e$=""
  557. icon_getselect(psselect%, 2) o$ = " -o" 
  558.  o$=""
  559. icon_getselect(psselect%, 3) r$ = " -r" 
  560.  r$=""
  561. .  pages$=" -p"+
  562. icon_gettext(psselect%, 4)
  563.  pages$=" -p" pages$=""
  564. 5  CL$(psselectwin%)="psselect -q"+e$+o$+r$+pages$
  565. which_winnum(win%)
  566.  i% = 0 
  567.  wins%(i%) = win% =i%
  568. H  fred%=
  569. wimp_messagebox(
  570. , "Error!", "Window not found somewhere!")
  571. psnup_setup
  572.  psize%(psnupwin%, 0) = 7 
  573. icon_setcaret(psnup%, 5, -1)
  574. icon_setcaret(psnup%, 7, -1)
  575. pstops_setup
  576.  width%, height%
  577.  temp% 2048 : 
  578.  Really temp?
  579. -%  !pane% = 
  580. win_handle(topspane%)
  581.  "Wimp_GetWindowState",, pane%
  582. /#  !temp% = 
  583. win_handle(pstops%)
  584.  "Wimp_GetWindowState",, temp%
  585.   pane%!28 = -1
  586. 2H  width% = (pane%!12 - pane%!4)/2 : height% = (pane%!16 - pane%!8)/2
  587. 3'  pane%!12 = width% + temp%!4 + 596
  588. 4(  pane%!16 = height% + temp%!8 + 218
  589. 5&  pane%!4 = temp%!4 + 596 - width%
  590. 6'  pane%!8 = temp%!8 + 218 - height%
  591.   temp%!28 = !pane%
  592.  &400C5,,pane%
  593.  psize%(pstopswin%, 0) = 7 
  594. ;&    
  595. icon_setcaret(pstops%, 5, -1)
  596. ='    
  597. icon_setcaret(pstops%, 10, -1)
  598. get_pagesize(pw%, ph%)
  599. A7  sc = 216/pw%: sc1 = 184/ph%: 
  600. (sc1 < sc) sc = sc1
  601.   pw% = pw% * sc: ph% = ph% * sc
  602. epsffit_setup
  603. icon_setcaret(epsffit%, 10, -1)
  604. psbook_setup
  605. icon_setcaret(psbook%, 2, -1)
  606. psresize_setup
  607.  psize%(psresizewin%, 0) = 7 
  608. icon_setcaret(psresize%, 5, -1)
  609.  psize%(psresizewin%, 1) = 7 
  610. R(   
  611. icon_setcaret(psresize%, 13, -1)
  612. psselect_setup
  613. icon_setcaret(psselect%, 4, -1)
  614. event_keypress(B%)
  615.  B%!24 <> &0D 
  616. ]#    
  617.  "Wimp_ProcessKey", B%!24
  618. _"    which% = 
  619. win_findwin(!B%)
  620. icon_select(which%, 1)
  621.   x% = TIME
  622.   REPEAT UNTIL TIME = x%+15
  623.  which% = savewin% 
  624. d/      outfile$ = 
  625. icon_gettext(savewin%, 2)
  626. e!      
  627. outfile$, ".") = 0 
  628. fj        hello%=
  629. wimp_messagebox(
  630. , "Warning from PSUtils","Drag the file icon to a directory to save")
  631.         
  632.       
  633. i/      
  634. transfer_savefile(outfile$, &FF5, 0)
  635. j        
  636. k&      
  637.  Any of the config windows.
  638.       
  639. call_CL(which%)
  640.       
  641.  mid_save% 
  642. p9        
  643. which_winnum(which%) = curr_selection%) 
  644.           mid_save% = 
  645. r7          
  646. transfer_savefile(config_name$, &FF5, 0)
  647. s4          
  648.  Call the PROC to save the file .....
  649.         
  650.       
  651.         
  652. w!    
  653. icon_deselect(which%, 1)
  654. x4    
  655. (which% = pstops%) 
  656. win_closewin(topspane%)
  657. y<    
  658. win_closewin(which%) : 
  659.  Close the window whatever.
  660. event_closewindow(I%)
  661.  handle%, x%, y%, b%
  662. win_findwin(!I%) = pstopsedit%) 
  663.  x%, y%, b%
  664.  b% = 1 
  665. K      
  666.  An attempt to check if the right button was pressed at the time
  667. %      
  668. win_getsize(pstops%,x%,y%)
  669.       
  670. os_screensize(X%,Y%)
  671. 5      
  672. win_movewin(pstops%,(X%-x%)
  673.  2,(Y%-y%)
  674. !      
  675. call_setup(pstopswin%)
  676.         
  677. &    !I% = 
  678. win_handle(pstopsedit%)
  679.  &400C6,,I%
  680.     big_page_open% = 
  681.         
  682. win_findwin(!I%) = savewin%) 
  683.  &400C6,,I%: 
  684. !  handle% = 
  685. win_findwin(!I%)
  686.  Not sure whether to include this?
  687.  mid_save% 
  688. which_winnum(handle%) = curr_selection%) 
  689.       mid_save% = 
  690.     PROCtransfer_savefile(config_name$, &FF5, 0)
  691.     REM Call the PROC to save the file .....
  692.  (handle% = pstops%) 
  693. '    !pane% = 
  694. win_handle(topspane%)
  695.  &400C6,,pane%
  696.    !I% = 
  697. win_handle(handle%)
  698.  &400C6,,I%
  699. event_openwindow(I%)
  700.  handle%, width%, height%
  701. !  handle% = 
  702. win_findwin(!I%)
  703.  (handle% = pstops%) 
  704. '    !pane% = 
  705. win_handle(topspane%)
  706. (    
  707.  "Wimp_GetWindowState",, pane%
  708. $    pane%!28 = I%!28 : 
  709.  216x184
  710. I    width% = (pane%!12 - pane%!4)/2: height% = (pane%!16 - pane%!8)/2
  711. &    pane%!12 = width% + I%!4 + 596
  712. '    pane%!16 = height% + I%!8 + 218
  713. %    pane%!4 = I%!4 + 596 - width%
  714. &    pane%!8 = I%!8 + 218 - height%
  715.     I%!28 = !pane%
  716.  &400C5,,pane%
  717.  &400C5,,I%  
  718. pagespecs(strin$)
  719.  num_pages, dplus%, rel_end%, pn%, l%, r%, u%, br%, sc%
  720.  bc%, bl%, scale, xoff, yoff, next%, pnext%
  721.  win_w%, win_h%, curr_page%
  722. strin$, ":") = 0 
  723.     spec$ = strin$
  724.     num_pages% = 1
  725. 1    num_pages% = 
  726. strin$, 
  727. strin$, ":")-1))
  728. '    spec$=
  729. strin$, 
  730. strin$, ":")+1)
  731.   !pagespecs% = num_pages%
  732.   dplus% = 
  733. realloc(pagespecs%, num_pages%*20+4) : 
  734.  20 bytes * number of pages
  735. win_getsize(topspane%, win_w%, win_h%)
  736.  i% = 1 
  737.  num_pages%
  738. /    curr_page% = pagespecs% + (i%-1)*20 + 4
  739. 8    !curr_page% = 0 : ?(curr_page% + flags_off%) = 0
  740. J    |(curr_page% + scale_off%) = 0.0 : |(curr_page% + xoff_off%) = 0.0
  741. (    |(curr_page% + yoff_off%) = 0.0 
  742. Q    
  743.  dplus% ?(curr_page% + flags_off%) = ?(curr_page% + flags_off%) 
  744.  fplus%
  745.     plus% = 
  746. spec$, "+")
  747.     comma% = 
  748. spec$, ",")
  749. (comma% <> 0) 
  750. >      
  751. spec$, ")") > comma%) 
  752. spec$, "(") < comma%) 
  753. 3        comma% = 
  754. spec$, 
  755. spec$, ")")+1), ",")
  756. 9        
  757.  comma% <> 0 comma% = comma% + 
  758. spec$, ")") 
  759.       
  760.         
  761. <    
  762.  ((plus% < comma%) 
  763.  (plus% <> 0)) 
  764.  (comma% = 0) 
  765.       next% = plus%
  766.       dplus% = 
  767.         
  768.       next% = comma%
  769.       dplus% = 
  770.         
  771.  next% > 0 
  772. '      next_page$ = 
  773. spec$, next%-1)
  774. "      spec$ = 
  775. spec$, next%+1)
  776.         
  777. )      next_page$ = spec$ : spec$ = ""
  778.         
  779. !    
  780. next_page$, 1) = "-" 
  781.       rel_end% = 
  782. 4      next_page$ = 
  783. next_page$, 
  784. (next_page$)-1)
  785. I      ?(curr_page% + flags_off%) = ?(curr_page% + flags_off%) 
  786.  fend%
  787.         
  788.     l% = 
  789. next_page$, "L")
  790.     r% = 
  791. next_page$, "R")
  792.     u% = 
  793. next_page$, "U")
  794.     sc% = 
  795. next_page$, "@")
  796.     bl% = 
  797. next_page$, "(")
  798. @    pnext% = l% : 
  799.  (pnext% > r%) 
  800.  (pnext% = 0) pnext% = r%
  801. 2    
  802.  (pnext% > u%) 
  803.  (pnext% = 0) pnext% = u%
  804. 4    
  805.  (pnext% > sc%) 
  806.  (pnext% = 0) pnext% = sc%
  807. 4    
  808.  (pnext% > bl%) 
  809.  (pnext% = 0) pnext% = bl%
  810.  pnext% = 0 
  811.       pn% = 
  812. (next_page$)
  813.         
  814. )      pn% = 
  815. next_page$, pnext%-1))
  816.         
  817.     !curr_page% = pn%
  818.  l% > 0 
  819.       l% = 
  820. G      ?(curr_page% + flags_off%) = ?(curr_page% + flags_off%) 
  821.         
  822.       l% = 
  823.         
  824.  r% > 0 
  825.       r% = 
  826. G      ?(curr_page% + flags_off%) = ?(curr_page% + flags_off%) 
  827.         
  828.       r% = 
  829.         
  830.  u% > 0 
  831.       u% = 
  832. G      ?(curr_page% + flags_off%) = ?(curr_page% + flags_off%) 
  833.         
  834.       u% = 
  835.         
  836.  sc% = 0 
  837.       scale = 1.0
  838.         
  839. (      scale = 
  840. next_page$, sc%+1))
  841. H      ?(curr_page% + flags_off%) = ?(curr_page% + flags_off%) 
  842.  fsc%
  843. ,      |(curr_page% + scale_off%) = scale
  844.         
  845.     5    
  846. (bl% <> 0) 
  847.  ((bl% < next%) 
  848.  (next% = 0)) 
  849. %      br$ = 
  850. next_page$, bl% + 1)
  851.       bc% = 
  852. br$, ",")
  853.       br% = 
  854. br$, ")")
  855. @      x$ = 
  856. br$, 0, bc%-1): y$ = 
  857. br$, bc%+1, br% - bc% -1 )
  858.       xoff = 
  859. parse_dim(x$)
  860.       yoff = 
  861. parse_dim(y$)
  862. I      ?(curr_page% + flags_off%) = ?(curr_page% + flags_off%) 
  863.  foff%
  864. L      |(curr_page% + xoff_off%) = xoff: |(curr_page% + yoff_off%) = yoff
  865.         
  866. &    
  867.  spec$ = "" i% = num_pages%+1
  868.  Needed in structure:- Number: Page num (Integer , word)
  869.                        Flags:  l, r, u, sc, same_page, reverse, offset (byte)
  870.                        Numbers: Scale, xoffset, yoffset (float multibyte)
  871.  Mem needed = 4 + 1 + 3*5 bytes = 20 bytes per page
  872. event_redraw(B%)
  873.  more%, i%, lpw%, lph%, x%, y%, curr_page%, x, y, nw, nh, nw%, nh%, win%, rescale, blx%, bly%, col%
  874.   win% = !B%
  875. win_findwin(win%) 
  876.  topspane%:
  877.       rescale = sc
  878.  pstopsedit%
  879.       rescale = mag%/div%
  880.  "Wimp_RedrawWindow",,B% 
  881.  more%
  882.  more%
  883. (<    
  884.  Basically take what is currently in pagespecs% and
  885. )=    
  886.  draw what you think is a reasonable representation!
  887.     col% = 11
  888. +"    
  889.  i% = 0 
  890.  (!pagespecs%-1)
  891. ,-      curr_page% = pagespecs% + i%*20 + 4
  892.       
  893.       x = 0.0: y = 0
  894.  The order is:- Shift then Rotate then Scale
  895.  But I think it is really the other way around
  896.  Only scale the dimensions not the coords since they are still zero the hero
  897.       nw = pw%: nh = ph%
  898. 48      
  899.  (?(curr_page% + flags_off%) 
  900.  fsc%) = fsc% 
  901. 5.        nw = nw*|(curr_page% + scale_off%)
  902. 6.        nh = nh*|(curr_page% + scale_off%)
  903.       
  904.       angle% = 0
  905. 96      
  906.  (?(curr_page% + flags_off%) 
  907.  fl%) = fl% 
  908. :         angle% = angle% + 90
  909. ;0        
  910.  nh, nw: nw = -nw: 
  911.  Well sort of!
  912.       
  913. =6      
  914.  (?(curr_page% + flags_off%) 
  915.  fr%) = fr% 
  916. >         angle% = angle% - 90
  917. ?0        
  918.  nh, nw: nh = -nh: 
  919.  Well sort of!
  920.       
  921. A6      
  922.  (?(curr_page% + flags_off%) 
  923.  fu%) = fu% 
  924. B!        angle% = angle% + 180
  925.         nw = -nw: nh = -nh
  926.       
  927. F:      
  928.  (?(curr_page% + flags_off%) 
  929.  foff%) = foff% 
  930. GI        x = |(curr_page% + xoff_off%) : y = |(curr_page% + yoff_off%)
  931.       
  932. I       
  933. font_setangle(angle%)
  934. J.      x = x*rescale: y = (y - ph%)*rescale
  935. K*      nh = nh*rescale: nw = nw*rescale
  936. LI      x% = x: y% = y: 
  937.  Just centre the blob on the point of interest
  938.       nw% = nw: nh% = nh
  939.       blx% = x%: bly% = y%
  940. O.      
  941.  nw% < 0 x% = x% + nw% : nw% = -nw%
  942. P.      
  943.  nh% < 0 y% = y% + nh% : nh% = -nh%
  944. Q(      nw% = x% + nw%: nh% = y% + nh%
  945. R6      
  946. coord_wintoreal(
  947. win_findwin(win%), x%, y%)
  948. S:      
  949. coord_wintoreal(
  950. win_findwin(win%), blx%, bly%)
  951. T8      
  952. coord_wintoreal(
  953. win_findwin(win%), nw%, nh%)
  954. U6      blx% = blx% + 8*
  955. (nw): bly% = bly% + 8*
  956. V=      
  957.  (?(curr_page% + flags_off%) 
  958.  fplus%) <> fplus% 
  959.         col% = col% + 1
  960.         
  961.  col%=16 col% = 8
  962.       
  963. Z#      
  964.  "Wimp_SetColour", col%
  965. [#      
  966.  x%, y%, nw%-x%, nh%-y%
  967. \/      
  968. font_setcolour(&00000000, &FFFFFF00)
  969. ];      
  970. font_plottext(
  971. (!curr_page%), trin%, blx%, bly%)
  972. ^        
  973.     !B% = win%
  974. `*    
  975.  "Wimp_GetRectangle",,B% 
  976.  more%
  977. get_pagesize(
  978.  w%, 
  979.  dummy$, w$, h$
  980.   dummy$ = ""
  981.  psize%(pstopswin%,0) 
  982. iH      w$ = 
  983. icon_gettext(pstops%, 5): h$ = 
  984. icon_gettext(pstops%, 6)
  985.       w% = 
  986. parse_dim(w$)
  987.       h% = 
  988. parse_dim(h$)
  989.       w% = 595: h% = 842
  990.       w% = 842: h% = 1191
  991.       w% = 421: h% = 595
  992.       w% = 516: h% = 729
  993.       w% = 612: h% = 792
  994.       w% = 612: h% = 1008
  995.       w% = 1224: h% = 792
  996.       w% = 792: h% = 1224
  997.       w% = 396: h% = 612
  998.       w% = 540: h% = 720
  999.       w% = 612: h% = 936
  1000.       w% = 610: h% = 780
  1001.       w% = 720: h% = 1008
  1002. parse_dim(
  1003.  dim$)
  1004.  c%, p%, i%, m%, u%, s%, error_cond%
  1005.   error_cond% = 
  1006.   u% = 0
  1007.   s% = 999
  1008.   c% = 
  1009. dim$, "c")
  1010.   p% = 
  1011. dim$, "p")
  1012.   i% = 
  1013. dim$, "i")
  1014.   m% = 
  1015. dim$, "m")
  1016.  (c% <> 0) u% = 1 : s% = c%
  1017.  (p% <> 0) 
  1018.  (p% < s%) u% = 2 : s% = p%
  1019.  (i% <> 0) 
  1020.  (i% < s%) u% = 3 : s% = i%
  1021.  (m% <> 0) 
  1022.  (m% < s%) u% = 4 : s% = m%
  1023. (      u% = 1: dim$ = 
  1024. (dim$))+"pt"
  1025.       = 
  1026. (dim$)
  1027. &      
  1028. dim$, s%+1, 1) <> "m") 
  1029.         error_cond% = 
  1030.       
  1031. *        dim$ = 
  1032. dim$, s%-1)))+"cm"
  1033. %        = 
  1034. dim$, s%-1))*72/2.54
  1035.       
  1036. &      
  1037. dim$, s%+1, 1) <> "t") 
  1038.         error_cond% = 
  1039.       
  1040. *        dim$ = 
  1041. dim$, s%-1)))+"pt"
  1042.         = 
  1043. dim$, s%-1))
  1044.       
  1045. &      
  1046. dim$, s%+1, 1) <> "n") 
  1047.         error_cond% = 
  1048.       
  1049. *        dim$ = 
  1050. dim$, s%-1)))+"in"
  1051.          = 
  1052. dim$, s%-1))*72
  1053.       
  1054. &      
  1055. dim$, s%+1, 1) <> "m") 
  1056.         error_cond% = 
  1057.       
  1058. *        dim$ = 
  1059. dim$, s%-1)))+"mm"
  1060. %        = 
  1061. dim$, s%-1))*72/25.4
  1062.       
  1063.  error_cond% 
  1064.     dim$ = dim$
  1065. ]    fred% = 
  1066. wimp_messagebox(
  1067. , "Error", "Error: Invalid dimension specifier somewhere!")
  1068.     = 0
  1069. N  fred% = 
  1070. wimp_messagebox(
  1071. , "Error", "Can't finish this function here!")
  1072. page_name(page_num%)
  1073.  page_num% 
  1074. [      fred% = 
  1075. wimp_messagebox(
  1076. , "Error", "Shouldn't have called page_name that way!")
  1077.       = ""
  1078.       = "a4"
  1079.       = "a3"
  1080.       = "a5"
  1081.       = "b5"
  1082.       = "letter"
  1083.       = "legal"
  1084.       = "ledger"
  1085.       = "tabloid"
  1086.       = "statement"
  1087.       = "executive"
  1088.       = "folio"
  1089.       = "quarto"
  1090.       = "10x14"
  1091. memory(Y%,S%)
  1092.  P%,D%,A%,B%,C%,E%,F%,G%,H%,I%,J%,K%,L%,M%,N%,O%,Q%,R%,T%,U%,V%,Z%,X%,W%
  1093.  copyright$,g%,h%,i%,l%,m%,n%,o%
  1094. Gcopyright$="Dynamic memory allocation routines, 
  1095.  Ian Palmer, 1993"
  1096.  _mem_code% 559
  1097. 0_mem_error%=Y%:_memdim%=S%:
  1098.  &51 
  1099.  _mpsize%
  1100.  &400EC,-1,-1 
  1101.  _mtop%:_mtop%+=&8000
  1102.  Z%=0 
  1103.  2:P%=_mem_code%:[OPT Z%
  1104. !B A%:B B%:B C%:B D%:B R%:B W%
  1105. H.A%:ADR R4,_memory%:LDR R1,[R4]:.E%:CMP R1,#0:BEQ F%:LDR R2,[R1,#-4]
  1106. LCMP R2,R0:BGE G%:MOV R4,R1:LDR R1,[R1]:B E%:.F%:MOV R0,#0:ADR R1,_memrv%
  1107. ESTR R0,[R1]:MOV PC,R14:.G%:LDR R2,[R1]:STR R2,[R4]:ADR R0,_memrv%
  1108. STR R1,[R0]:MOV PC,R14
  1109. M.B%:LDR R5,[R0,#-4]:ADD R6,R5,R0:ADD R6,R6,#4:ADR R4,_memory%:LDR R1,[R4]
  1110. B.H%:CMP R1,#0:BEQ I%:LDR R2,[R1,#-4]:ADD R3,R2,R1:ADD R3,R3,#4
  1111. QCMP R3,R0:BEQ J%:CMP R6,R1:BEQ K%:CMP R1,R0:BGT I%:MOV R4,R1:LDR R1,[R1]:B H%
  1112. B.I%:STR R0,[R4]:STR R1,[R0]:B L%:.J%:ADD R5,R5,R2:ADD R5,R5,#4
  1113. JSTR R5,[R1,#-4]:MOV R0,R1:LDR R1,[R1]:CMP R6,R1:BNE L%:LDR R2,[R1,#-4]
  1114. I.K%:ADD R5,R5,R2:ADD R5,R5,#4:STR R5,[R0,#-4]:LDR R1,[R1]:STR R1,[R0]
  1115. 9STR R0,[R4]:.L%:ADR R1,_memrv%:STR R0,[R1]:MOV PC,R14
  1116. I.C%:ADR R1,_memory%:.M%:LDR R2,[R1]:CMP R2,#0:BEQ N%:CMP R2,R0:BEQ O%
  1117. NMOVLT R1,R2:BLT M%:.N%:MOV R1,#0:.O%:ADR R0,_memrv%:STR R1,[R0]:MOV PC,R14
  1118. H.R%:ADR R4,_memory%:LDR R2,[R4]:.T%:CMP R2,#0:BEQ U%:LDR R3,[R2,#-4]
  1119. JADD R3,R3,R2:CMP R3,R0:BEQ V%:MOV R4,R2:LDR R2,[R2]:B T%:.U%:MOV R2,#0
  1120. I.V%:ADR R1,_memrv%:STR R2,[R1]:ADR R1,_memrv2%:STR R4,[R1]:MOV PC,R14
  1121. B.W%:ADR R1,_memory%:MOV R0,#0:LDR R2,[R1]:.Y%:CMP R2,#0:BEQ S%
  1122. 1LDR R3,[R2,#-4]:ADD R0,R0,R3:LDR R2,[R2]:B Y%
  1123. -.S%:ADR R1,_memrv%:STR R0,[R1]:MOV PC,R14
  1124. B.D%:STMFD R13!,{R8-R10,R14}:CMP R0,#0:LDMEQFD R13!,{R8-R10,PC}
  1125. -CMP R1,R2:LDMEQFD R13!,{R8-R10,PC}:BLT l%
  1126. H.g%:SUBS R0,R0,#32:BLT h%:LDMIA R1!,{R3-R10}:STMIA R2!,{R3-R10}:B g%
  1127. Q.h%:ADDS R0,R0,#32:.i%:LDMEQFD R13!,{R8-R10,PC}:LDR R4,[R1],#4:STR R4,[R2],#4
  1128. SUBS R0,R0,#4:B i%
  1129. !.l%:ADD R1,R1,R0:ADD R2,R2,R0
  1130. H.m%:SUBS R0,R0,#32:BLT n%:LDMDB R1!,{R3-R10}:STMDB R2!,{R3-R10}:B m%
  1131. D.n%:ADDS R0,R0,#32:.o%:LDMEQFD R13!,{R8-R10,PC}:LDR R4,[R1,#-4]!
  1132. 'STR R4,[R2,#-4]!:SUBS R0,R0,#4:B o%
  1133. ._memory% EQUD 0
  1134. ._memrv% EQUD 0
  1135. ._memrv2% EQUD 0
  1136. _more_memory(S%)
  1137.  M%,L%,A%,X%,Y%,Z%:M%=0
  1138.  _memdim% 
  1139. M  A%=
  1140.  _mem_code%+16:L%=!_memrv%:
  1141.  L%<>0 
  1142.  S%-=!(L%-4)-4:!!_memrv2%=!L%
  1143.  S%<(
  1144. -2048) 
  1145.  M% S%-1:!M%=S%-4:
  1146.  L%<>0 
  1147.  M%=L%-4:!M%=S%+!(L%-4)
  1148. T  A%=_mtop%:
  1149.  _mem_code%+16:L%=!_memrv%:
  1150.  L%<>0 
  1151.  S%-=!(L%-4)-4:!(!_memrv2%)=!L%
  1152.  &400EC,-1,-1 
  1153.  X%,Y%,Z%:
  1154.  S%<Z% 
  1155. k    
  1156.  &400EC,X%+S%,Y% 
  1157.  Z%:M%=X%+&8000:!M%=Z%-X%-4:_mtop%=Z%+&8000:
  1158.  L%<>0 
  1159.  M%=L%-4:!M%=Z%-X%+!(L%-4)
  1160.  M%<>0 
  1161.  M%+=4
  1162. _less_memory
  1163.  A%,B%,L%,C%,S%,N%,D%
  1164. A%=_mtop%:
  1165.  _mem_code%+16
  1166. +B%=!_memrv%:C%=!_memrv2%:B%-=4:L%=4+!B%
  1167. ;D%=(L% 
  1168.  _mpsize%)*_mpsize%:N%=L%-D%:S%=_mtop%-D%-&8000
  1169.  &400EC,S%,-1 
  1170.  S%:_mtop%=S%+&8000
  1171.  N%>7 
  1172.  !B%=N%-4:
  1173.  !C%=0
  1174. wimp_init(T$,I$,L%,S%,V%,H%)
  1175.  B%,C%,X%,Y%,M%:
  1176.  S%=0 
  1177.  S%=512:
  1178.  S%<256 S%=256
  1179. &S_wimp_task$=T$:_wimp_buffer%=
  1180. malloc(S%):B%=
  1181. malloc(38+
  1182. (I$)):_wimp_iconbar%=B%
  1183.  &400C0,V%,&4B534154,T$,H% 
  1184.  _wimp_version%,_wimp_handle%
  1185.  I$<>"" 
  1186.  &400E9,40,,I$ 
  1187.  ,,,X%,Y%,,M%
  1188.  &35,M%,4 
  1189.  ,,C%:X%=X%<<C%
  1190.  &35,M%,5 
  1191.  ,,C%:Y%=Y%<<C%
  1192.   !B%=-2:
  1193.  !B%=-1
  1194. -=  B%!4=0:B%!8=0:B%!12=X%:B%!16=Y%:B%!20=&2102:B%!24=B%+36
  1195. .C  $(B%+36)=I$:B%!28=1:B%!32=
  1196. (I$)+1:
  1197.  &400C2,,B% 
  1198.  _wimp_icon%
  1199. wimp_error(F%,E%,M$)
  1200.  B%,R%:B%=_wimp_buffer%
  1201. 4%!B%=E%:$(B%+4)=M$:?(B%+4+
  1202. (M$))=0
  1203.  &400DF,B%,1,_wimp_task$
  1204. wimp_quit
  1205.  &400DF,B%,3,_wimp_task$ 
  1206.  R%=2 
  1207. wimp_quit
  1208. *|update
  1209. wimp_quit:
  1210.          *** update block ***
  1211.  I%=0 
  1212.  _temp_fonts%?I% 
  1213.  "Font_LoseFont",I%
  1214.  &400DD,_wimp_handle%,&4B534154
  1215. *|downdate
  1216. malloc(A%)
  1217.  M%,S%
  1218. K-S%=A%:A%=12+(A% 
  1219.  16)*16:
  1220.  A%<S% 
  1221.  A%+=16
  1222.  _mem_code%:M%=!_memrv%
  1223.  M%=0 
  1224.   M%=
  1225. _more_memory(A%+4)
  1226.  M%<>0 
  1227.  S%=!(M%-4):
  1228.  S%-A%>15 
  1229.  !(M%-4)=A%:
  1230. add_free(M%+A%,S%-A%)
  1231.  M%=0 
  1232.  _mem_error% 
  1233.  11,"Can't allocate memory"
  1234. win_init(E%)
  1235. V4_win_list%=
  1236. malloc(4*E%):E%=
  1237. size_of(_win_list%)
  1238.  A%=0 
  1239.  E%-1 
  1240.  4:!(_win_list%+A%)=0:
  1241. font_init
  1242. [2__font_angle=0:__font_xflip%=
  1243. :__font_yflip%=
  1244.  __font_transform% 24,__font_bbox% 36
  1245. ]4__font_transform%!0=&10000:__font_transform%!4=0
  1246. ^5__font_transform%!8=0:__font_transform%!12=&10000
  1247. _1__font_transform%!16=0:__font_transform%!20=0
  1248. _font_settransform
  1249. c0__font_transform%!0=
  1250. (__font_angle)*&10000
  1251. d0__font_transform%!4=
  1252. (__font_angle)*&10000
  1253. e1__font_transform%!8=-
  1254. (__font_angle)*&10000
  1255. f1__font_transform%!12=
  1256. (__font_angle)*&10000
  1257.  __font_xflip% __font_transform%!8=-(__font_transform%!8):__font_transform%!12=-(__font_transform%!12)
  1258.  __font_yflip% __font_transform%!0=-(__font_transform%!0):__font_transform%!4=-(__font_transform%!4)
  1259. font_gethandle(font$,x,y)
  1260.  font%
  1261.  "Font_FindFont",,font$,x*16,y*16,0,0 
  1262.  font%
  1263. =font%
  1264. temp_init
  1265. _temp_list%=0
  1266. _temp_spritearea%=0
  1267. _temp_fonts%=
  1268. malloc(256)
  1269.  I%=0 
  1270.  255:_temp_fonts%?I%=0:
  1271. *|update
  1272. transfer_init
  1273. _transfer_type%=0
  1274. _transfer_file$=""
  1275. _transfer_size%=0
  1276. _transfer_ref%=0
  1277. _transfer_dragging%=
  1278. _wimp_buffer%!0=1
  1279. _wimp_buffer%!4=2
  1280. _wimp_buffer%!8=3
  1281. _wimp_buffer%!12=5
  1282. _wimp_buffer%!16=6
  1283. _wimp_buffer%!20=7
  1284. _wimp_buffer%!24=&80142
  1285. _wimp_buffer%!28=&80144
  1286. _wimp_buffer%!32=&80145
  1287. _wimp_buffer%!36=0
  1288. wimp_addmessages(_wimp_buffer%)
  1289. _transfer_wantmess(mess%)
  1290.  mess% 
  1291.  1,2,3,5,6,&80144,&80145: =
  1292. event_transfermessage(block%)
  1293.  buffer%,size%,mess%
  1294. ?(block%+!block%)=0
  1295.  block%!16 
  1296. F    
  1297. transfer_willload(block%!40,
  1298.  block%!8<>_transfer_ref% 
  1299. 1      
  1300. os_putstring(block%+44,"<Wimp$Scrap>")
  1301.       block%!36=-1
  1302.       block%!12=block%!8
  1303.       block%!16=2
  1304.       !block%=60
  1305. 2      
  1306.  "Wimp_SendMessage",17,block%,block%!4
  1307.         
  1308. $    
  1309.  block%!12=_transfer_ref% 
  1310. #      block%!36=_transfer_size%
  1311.       block%!12=block%!8
  1312.       block%!16=3
  1313. =      
  1314.  "Wimp_SendMessage",18,block%,block%!20,block%!24
  1315. V      
  1316. transfer_savefile(
  1317. os_getstring(block%+44),_transfer_type%,(block%!36<>-1))
  1318. !      _transfer_ref%=block%!8
  1319.       
  1320. menu_remove
  1321.         
  1322. E    
  1323.  block%!4<>_wimp_handle% 
  1324. transfer_willload(block%!40,
  1325.       block%!12=block%!8
  1326.       block%!16=4
  1327. 2      
  1328.  "Wimp_SendMessage",17,block%,block%!4
  1329. i      
  1330. transfer_loadfile(
  1331. os_getstring(block%+44),block%!40,
  1332. os_getstring(block%+44)<>"<Wimp$Scrap>")
  1333.         
  1334. +    
  1335. transfer_willload(block%!40,
  1336.       block%!12=block%!8
  1337.       block%!16=4
  1338. 2      
  1339.  "Wimp_SendMessage",17,block%,block%!4
  1340. B      
  1341. transfer_loadfile(
  1342. os_getstring(block%+44),block%!40,
  1343.  &80145:
  1344.  block%!12 
  1345.           
  1346. _transfer_wantack(mess%)
  1347.  mess% 
  1348.  3,7,&80142: =
  1349. event_transferacknowledge(block%)
  1350.  dummy%
  1351.  block%!16 
  1352. #    
  1353.  block%!8=_transfer_ref% 
  1354. 5      
  1355. os_getstring(block%+44)="<Wimp$Scrap>" 
  1356. -        
  1357.  "OS_CLI","Remove <Wimp$Scrap>"
  1358.       
  1359. d      dummy%=
  1360. wimp_messagebox(
  1361. ,"Error from "+_wimp_task$,"Data transfer failed: Receiver died")
  1362.         
  1363. event_savedrag(block%)
  1364.  flag%
  1365.  _wimp_version%>=300 
  1366.  "OS_Byte",161,28 
  1367.  ,,flag%
  1368.   flag%=((flag% 
  1369.  2) = 2)
  1370.   flag%=
  1371.  flag% 
  1372.  "DragASprite_Stop"
  1373.  "Wimp_DragBox",,-1
  1374. _transfer_dragging%=
  1375. _transfer_file$,".")
  1376. ?  _transfer_file$=
  1377. _transfer_file$,
  1378. _transfer_file$,".")+1)
  1379.  "Wimp_GetPointerInfo",,_wimp_buffer%
  1380. G_wimp_buffer%!20=_wimp_buffer%!12:_wimp_buffer%!24=_wimp_buffer%!16
  1381. D_wimp_buffer%!28=!_wimp_buffer%:_wimp_buffer%!32=_wimp_buffer%!4
  1382. $_wimp_buffer%!36=_transfer_size%
  1383. $_wimp_buffer%!40=_transfer_type%
  1384. os_putstring(_wimp_buffer%+44,_transfer_file$)
  1385. )_wimp_buffer%!12=0:_wimp_buffer%!16=1
  1386. 4!_wimp_buffer%=44+4*((
  1387. (_transfer_file$)+4) 
  1388.  "Wimp_SendMessage",18,_wimp_buffer%,_wimp_buffer%!20,_wimp_buffer%!24
  1389. "_transfer_ref%=_wimp_buffer%!8
  1390. *|downdate
  1391. *|update
  1392. wimp_poll(M%,T%,P%):
  1393.       *** update block ***
  1394.  R%,I%,Q%
  1395.  T%=0 
  1396.  &400C7,M%,_wimp_buffer%,,P% 
  1397.  &42 
  1398.  Q%:Q%=Q%+T%
  1399.  &400E1,M%,_wimp_buffer%,Q%,P% 
  1400. :I%=_wimp_buffer%
  1401.  1 : 
  1402. event_redraw(I%)
  1403.  2 : 
  1404. event_openwindow(I%)
  1405.  3 : 
  1406. event_closewindow(I%)
  1407.  6 : 
  1408.  I%!12=-2 
  1409.              Q%=I%!8
  1410. 5             
  1411.  (Q% 
  1412. event_iconbarmenu(!I%)
  1413. 6             
  1414.  (Q% 
  1415. event_iconbarselect(I%)
  1416.            
  1417.              Q%=0
  1418. -             
  1419.  Q%=0 
  1420. event_mouseclick(I%)
  1421.            
  1422.  7 : 
  1423.  _transfer_dragging% 
  1424. $             
  1425. event_savedrag(I%)
  1426.            
  1427.  8 : 
  1428. event_keypress(I%)
  1429.  9 : 
  1430. event_menuselection(I%):
  1431. menu_keepopen
  1432.  17,18: 
  1433. _transfer_wantmess(I%!16) 
  1434. .                
  1435. event_transfermessage(I%)
  1436.               
  1437. &                
  1438. event_message(I%)
  1439.               
  1440.  19: 
  1441. _transfer_wantack(I%!16) 
  1442. /             
  1443. event_transferacknowledge(I%)
  1444.            
  1445. *|downdate
  1446. temp_readfile(F$,E%)
  1447.  C%,A%,D%,N%,T%,F%,Z%,H%,I%
  1448.  C%=0 
  1449. wimp_error(1,214,"Can't open template file "+F$)
  1450.  A%=0 
  1451.  15:D%=
  1452. :T%=0:Z%=
  1453. malloc(E%)
  1454.  A%=0 
  1455.  23:Z%?A%=
  1456.  !Z% 
  1457. +  N%=
  1458. malloc(32):!N%=T%:T%=N%:N%!4=Z%!4
  1459.  A%=0 
  1460.  11:F%=?(Z%+12+A%):
  1461.  F%=0 
  1462.  ?(Z%+A%+12)=13
  1463. :?(Z%+24)=13:$(N%+16)=
  1464. tolower($(Z%+12))
  1465.  !Z%=0:
  1466. D%=T%:A%=Z%
  1467. malloc(256)
  1468.  &400D9,,F$
  1469.  I%=0 
  1470.  255:H%?I%=0:
  1471.  I%  
  1472.   N%=
  1473. malloc(D%!4):D%!8=N%
  1474.  &400DB,,N%,A%,A%+E%,H%,$(D%+16),0 
  1475.  ,,C%:F%=4+C%-A%
  1476. (B  C%=
  1477. malloc(F%):D%!12=C%:
  1478.  &400DB,,N%,C%,C%+F%,H%,$(D%+16),0
  1479.  !D%=0 
  1480.  !D%=_temp_list%:_temp_list%=T%:D%=0:
  1481.  D%=!D%
  1482.  I%=0 
  1483. +$    
  1484.  H%?I% 
  1485.  _temp_fonts%?I%+=1
  1486.  _temp_spritearea% 
  1487.     N%!64=_temp_spritearea%
  1488.     I%=N%!84
  1489.  I%>0
  1490. 1+      
  1491.  (!(N%+104+32*I%) 
  1492.  &103)=&102 
  1493. 2-        !(N%+112+32*I%)=_temp_spritearea%
  1494.       
  1495.       I%-=1
  1496. 5        
  1497.  &400DA:
  1498. free(Z%)
  1499. free(H%)
  1500. win_createwin(N$)
  1501. >(D%=
  1502. temp_copy(N$):
  1503. win_createwin(D%)
  1504. win_resize(W%,X%,Y%)
  1505.  B%:B%=_wimp_buffer%:!B%=!(W%-8)
  1506.  &400CB,,B%:B%!12=B%!4+X%:B%!16=B%!8+Y%:
  1507.  &400C5,,B%
  1508. win_closewin(W%)
  1509. G3!_wimp_buffer%=!(W%-8):
  1510.  &400C6,,_wimp_buffer%
  1511. icon_shade(W%,I%)
  1512. K-!_wimp_buffer%=!(W%-8):_wimp_buffer%!4=I%
  1513. L4_wimp_buffer%!8=&400000:_wimp_buffer%!12=&400000
  1514.  &400CD,,_wimp_buffer%
  1515. icon_settext(W%,I%,T$)
  1516.  cw%,ci%,cx%,cy%,cp%
  1517. RF!_wimp_buffer%=!(W%-8):_wimp_buffer%!4=I%:
  1518.  &400CE,,_wimp_buffer%
  1519.  (_wimp_buffer%!24 
  1520.  1)=0 
  1521.  (_wimp_buffer%!24 
  1522.  256) 
  1523. os_putstring(_wimp_buffer%!28,
  1524. T$,_wimp_buffer%!36))
  1525.  &400D3,,_wimp_buffer%+128
  1526. VEcw%=_wimp_buffer%!128:ci%=_wimp_buffer%!132:cx%=_wimp_buffer%!136
  1527. W/cy%=_wimp_buffer%!140:cp%=_wimp_buffer%!148
  1528.  cw%=W%!-8 
  1529.  ci%=I% 
  1530.  cp% > 
  1531. (S$) 
  1532.  cp% = 
  1533.  &400D2,cw%,ci%,cx%,cy%,-1,cp%
  1534. \(_wimp_buffer%!8=0:_wimp_buffer%!12=0
  1535.  &400CD,,_wimp_buffer%
  1536. menu_init(N%)
  1537. b;menu_tick=1:menu_dotted=2:_wimp_menu%=
  1538. malloc((N%+1)*4)
  1539. c2_wimp_oldmenu%=0:_wimp_oldmx%=0:_wimp_oldmy%=0
  1540. d7!_wimp_menu%=N%:
  1541.  A%=1 
  1542.  N%:!(_wimp_menu%+4*A%)=0:
  1543. menu_header(T$,M%,N%)
  1544.  P%,A%
  1545. P%=!(_wimp_menu%+4*(M%+1))
  1546.  P%=0 
  1547. k5  P%=
  1548. malloc(32+24*N%):!(_wimp_menu%+4*(M%+1))=P%
  1549. size_of(P%)<(32+24*N%) 
  1550. realloc(P%,32+24*N%):!(_wimp_menu%+4*(M%+1))=P%
  1551. oF$P%=T$:P%?
  1552. (T$)=0:P%!12=&70207:P%!16=16*(1+
  1553. (T$)):P%!20=44:P%!24=0
  1554.  A%=0 
  1555.  N%-2:!(P%+28+A%*24)=0:
  1556. :!(P%+4+N%*24)=128
  1557. menu_additem(M%,N%,I$,F%)
  1558.  P%,W%
  1559. uMP%=!(_wimp_menu%+4*(M%+1)):
  1560.  P%=0 
  1561.  0,"Menu number "+
  1562. (M%)+" undefined"
  1563. v@!(P%+28+N%*24)=(!(P%+28+N%*24) 
  1564.  &F0) 
  1565.  F%:!(P%+32+N%*24)=-1
  1566. wD!(P%+36+N%*24)=&7000021:$(P%+40+N%*24)=I$:?(P%+40+N%*24+
  1567. (I$))=0
  1568. x)W%=16*(1+
  1569. (I$)):
  1570.  W%>P%!16 
  1571.  P%!16=W%
  1572. menu_submenu(M%,N%,S%)
  1573.  P%:P%=!(_wimp_menu%+4*(M%+1))
  1574. }&!(P%+28+N%*24)=!(P%+28+N%*24) 
  1575. ~*!(P%+32+N%*24)=!(_wimp_menu%+4*(S%+1))
  1576. menu_subwindow(M%,N%,S%)
  1577.  P%:P%=!(_wimp_menu%+4*(M%+1)):!(P%+32+N%*24)=!(S%-8)
  1578. toupper(S$)
  1579.  R$,A%,C%,L%:L%=
  1580. (S$):R$="":
  1581.  L%=0 
  1582.  A%=1 
  1583.  L%:C%=
  1584. S$,A%,1)):
  1585.  C%>96 
  1586.  C%<123 
  1587.  C%-=32
  1588. (C%):
  1589. menu_untick(M%,N%)
  1590.  P%:P%=!(_wimp_menu%+4*(M%+1))+28+N%*24:!P%=!P% 
  1591.  &FFFFFFFE
  1592. menu_tick(M%,N%)
  1593.  P%:P%=!(_wimp_menu%+4*(M%+1))+28+N%*24:!P%=!P% 
  1594. icon_unshade(W%,I%)
  1595. -!_wimp_buffer%=!(W%-8):_wimp_buffer%!4=I%
  1596. ._wimp_buffer%!8=0:_wimp_buffer%!12=&400000
  1597.  &400CD,,_wimp_buffer%
  1598. win_getsize(W%,
  1599.  B%:B%=_wimp_buffer%:!B%=!(W%-8)
  1600.  &400CB,,B%:X%=B%!12-B%!4:Y%=B%!16-B%!8
  1601. os_screensize(
  1602.  F%,P%
  1603.  &35,-1,4 
  1604.  ,,F%:
  1605.  &35,-1,11 
  1606.  ,,P%:X%=P%<<F%
  1607.  &35,-1,5 
  1608.  ,,F%:
  1609.  &35,-1,12 
  1610.  ,,P%:Y%=P%<<F%
  1611. win_movewin(W%,X%,Y%)
  1612.  x%,y%,B%:B%=_wimp_buffer%:!B%=!(W%-8)
  1613.  &400CB,,B%:x%=B%!12-B%!4:y%=B%!16-B%!8
  1614. +B%!4=X%:B%!8=Y%:B%!12=X%+x%:B%!16=Y%+y%
  1615.  &400C5,,B%
  1616. icon_setcaret(W%,I%,X%)
  1617.  X%=-1 
  1618. icon_gettext(W%,I%))
  1619.  &400D2,!(W%-8),I%,0,0,-1,X%
  1620. transfer_startdrag(file$,type%,size%,win%,icon%)
  1621.  flag%,xmin%,xmax%,ymin%,ymax%,xsize%,ysize%,sprite$
  1622. $!_wimp_buffer%=
  1623. win_handle(win%)
  1624.  "Wimp_GetWindowInfo",,_wimp_buffer%
  1625. 8xmin%=_wimp_buffer%!4+!(_wimp_buffer%+92+32*icon%+0)
  1626. 8xmax%=_wimp_buffer%!4+!(_wimp_buffer%+92+32*icon%+8)
  1627. [ymin%=_wimp_buffer%!8+!(_wimp_buffer%+92+32*icon%+4)+(_wimp_buffer%!16-_wimp_buffer%!8)
  1628. \ymax%=_wimp_buffer%!8+!(_wimp_buffer%+92+32*icon%+12)+(_wimp_buffer%!16-_wimp_buffer%!8)
  1629. os_screensize(xsize%,ysize%)
  1630.  _wimp_version%>=300 
  1631.  "OS_Byte",161,28 
  1632.  ,,flag%
  1633.   flag%=((flag% 
  1634.  2) = 2)
  1635.   flag%=
  1636.  flag% 
  1637.   _wimp_buffer%!0=xmin%
  1638.   _wimp_buffer%!4=ymin%
  1639.   _wimp_buffer%!8=xmax%
  1640.   _wimp_buffer%!12=ymax%
  1641. H  sprite$="file_":
  1642.  type%<&100 sprite$+="0":
  1643.  type%<&10 sprite$+="0"
  1644.   sprite$+=
  1645. ~(type%)
  1646.  "DragASprite_Start",%11000101,1,sprite$,_wimp_buffer%,0
  1647.   !_wimp_buffer%=0
  1648.   _wimp_buffer%!4=5
  1649. 2  _wimp_buffer%!8=xmin%:_wimp_buffer%!12=ymin%
  1650. 3  _wimp_buffer%!16=xmax%:_wimp_buffer%!20=ymax%
  1651. +  _wimp_buffer%!24=0:_wimp_buffer%!28=0
  1652. 5  _wimp_buffer%!32=xsize%:_wimp_buffer%!36=ysize%
  1653.  "Wimp_DragBox",,_wimp_buffer%
  1654. _transfer_type%=type%
  1655. _transfer_file$=file$
  1656. _transfer_size%=size%
  1657. _transfer_dragging%=
  1658. icon_gettext(W%,I%)
  1659. F!_wimp_buffer%=!(W%-8):_wimp_buffer%!4=I%:
  1660.  &400CE,,_wimp_buffer%
  1661.  (_wimp_buffer%!24 
  1662.  1)=0 
  1663.  (_wimp_buffer%!24 
  1664.  256) 
  1665. os_getstring(_wimp_buffer%!28)
  1666. wimp_messagebox(C%,T$,M$)
  1667.  B%,R%,F%:B%=_wimp_buffer%:F%=17:
  1668.  F%=19
  1669. $!B%=0:$(B%+4)=M$:?(B%+4+
  1670. (M$))=0
  1671.  &400DF,B%,F%,T$ 
  1672. win_findwin(H%)
  1673.  E%,A%,F%,P%
  1674. size_of(_win_list%):F%=-1:
  1675.  A%=0 
  1676.  E%-1 
  1677.  4:P%=_win_list%!A%
  1678.  P%<>0 
  1679.  !(P%-8)=H% 
  1680.  F%=P%
  1681. win_handle(W%)
  1682. =!(W%-8)
  1683. win_redrawwin(W%)
  1684.  x1%,y1%,x2%,y2%
  1685. !_wimp_buffer%=W%!-8
  1686.  "Wimp_GetWindowState",,_wimp_buffer%
  1687. x1%=_wimp_buffer%!20
  1688. y2%=_wimp_buffer%!24
  1689. 0x2%=x1%+(_wimp_buffer%!12)-(_wimp_buffer%!4)
  1690. 0y1%=y2%+(_wimp_buffer%!8)-(_wimp_buffer%!16)
  1691.  "Wimp_ForceRedraw",W%!-8,x1%,y1%,x2%,y2%
  1692. menu_popup(M%,X%,Y%)
  1693. P_wimp_oldmenu%=M%:_wimp_oldmx%=X%:_wimp_oldmy%=Y%:M%=!(_wimp_menu%+4*(M%+1))
  1694.  &400D4,,M%,X%,Y%
  1695. win_setextent(W%,x%,y%,X%,Y%)
  1696.  B%,O%,w%,h%:B%=_wimp_buffer%
  1697. !B%=W%!-8
  1698.  "Wimp_GetWindowState",,B%
  1699. :w%=X%-x%:h%=Y%-y%
  1700.  w% < B%!20+(B%!12-B%!4) 
  1701.   O%=
  1702.   B%!20 = w%-(B%!12-B%!4)
  1703.  B%!20<0 
  1704.  (B%!12-B%!4)>w% 
  1705.     B%!20 = 0
  1706.     B%!12 = B%!4 + w%
  1707.  h% < (B%!16-B%!8)-B%!24 
  1708.   O%=
  1709.   B%!24 = (B%!16-B%!8)-h%
  1710.  B%!24>0 
  1711.  (B%!16-B%!8)>h% 
  1712.     B%!24 = 0
  1713.     B%!8 = B%!16 - h%
  1714.  "Wimp_OpenWindow",,B%
  1715. 8!B%=x%:B%!4=y%:B%!8=X%:B%!12=Y%:
  1716.  &400D7,!(W%-8),B%
  1717. icon_getselect(W%,I%)
  1718. F!_wimp_buffer%=!(W%-8):_wimp_buffer%!4=I%:
  1719.  &400CE,,_wimp_buffer%
  1720.  (_wimp_buffer%!24 
  1721.  &200000) 
  1722. icon_select(W%,I%)
  1723. -!_wimp_buffer%=!(W%-8):_wimp_buffer%!4=I%
  1724. 4_wimp_buffer%!8=&200000:_wimp_buffer%!12=&200000
  1725.  &400CD,,_wimp_buffer%
  1726. icon_deselect(W%,I%)
  1727. -!_wimp_buffer%=!(W%-8):_wimp_buffer%!4=I%
  1728. ._wimp_buffer%!8=0:_wimp_buffer%!12=&200000
  1729.  &400CD,,_wimp_buffer%
  1730. realloc(
  1731.  P%,N%)
  1732.  A%,B%,C%
  1733.  P%=0 
  1734. malloc(N%):
  1735. %8C%=!(P%-4):B%=N%:N%=12+(N% 
  1736.  16)*16:
  1737.  N%<B% 
  1738.  N%+=16
  1739.  N%<=C% 
  1740.  (C%-N%)>15 
  1741.  !(P%-4)=N%:
  1742. add_free(P%+N%,C%-N%)
  1743. )L  A%=P%+C%+4:
  1744.  _mem_code%+8:B%=!_memrv%:A%=0:
  1745.  B%<>0 
  1746.  B%=!B%:A%=!(B%-4)
  1747.  B%<>0 
  1748.  C%+A%+4>=N% 
  1749. +%    !!_memrv%=!B%:!(P%-4)=C%+A%+4
  1750.     A%=C%:C%=
  1751. malloc(N%)
  1752.  C%<>0 
  1753. //      B%=P%:
  1754.  _mem_code%+12:
  1755. free(P%):P%=C%
  1756. 0        
  1757. 16      
  1758.  _mem_error% 
  1759.  11,"Can't allocate memory"
  1760. 2        
  1761. font_setangle(theta)
  1762. __font_angle=theta
  1763. _font_settransform
  1764. coord_wintoreal(W%,
  1765.  B%:B%=_wimp_buffer%
  1766. !B%=!(W%-8):
  1767.  &400CB,,B%
  1768. ?&X%=X%-B%!20+B%!4:Y%=B%!16-B%!24+Y%
  1769. font_setcolour(fore%,back%)
  1770.  "ColourTrans_SetFontColours",0,back%,fore%,14
  1771. font_plottext(text$,font%,x%,y%)
  1772. x% = x% * 400
  1773. y% = y% * 400
  1774.  "Font_Paint",font%,text$,%01111000000,x%,y%,,__font_transform%,
  1775.  text$
  1776. add_free(A%,L%)
  1777. M:L%=(L% 
  1778.  16)*16:
  1779.  L%>0 
  1780.  !A%=L%-4:A%+=4:
  1781.  _mem_code%+4
  1782. size_of(P%)
  1783. =!(P%-4)
  1784. wimp_addmessages(M%)
  1785.  "Wimp_AddMessages",M%
  1786. os_putstring(P%,S$)
  1787. $P%=S$:?(P%+
  1788. (S$))=0
  1789. os_getstring(P%)
  1790.  S$:S$="":
  1791.  ?P%>31 S$+=
  1792. (?P%):P%+=1:
  1793. menu_remove
  1794.  "Wimp_CreateMenu",,-1
  1795. event_iconbarmenu(X%)
  1796.  Y%,M%:
  1797. wimp_error(1,
  1798. $+" at line "+
  1799. fMM%=
  1800. wimp_mainmenu:Y%=96+
  1801. menu_menuheight(M%):X%-=16+(
  1802. menu_width(M%) 
  1803. menu_popup(M%,X%,Y%)
  1804. menu_keepopen
  1805.  _wimp_oldmenu%=-1 
  1806. m*M%=!(_wimp_menu%+4*(_wimp_oldmenu%+1))
  1807.  &400CF,,_wimp_buffer%
  1808.  (_wimp_buffer%!8 
  1809.  &400D4,,M%,_wimp_oldmx%,_wimp_oldmy%
  1810. event_message(B%)
  1811.  B%!16 
  1812.  0 : 
  1813. wimp_quit
  1814. tolower(S$)
  1815.  R$,A%,C%,L%:L%=
  1816. (S$):R$="":
  1817.  L%=0 
  1818.  A%=1 
  1819.  L%:C%=
  1820. S$,A%,1)):
  1821.  C%>64 
  1822.  C%<91 
  1823.  C%+=32
  1824. (C%):
  1825. free(A%)
  1826.  _mem_code%+4:L%=!_memrv%
  1827.  (L%+!(L%-4))=_mtop% 
  1828.  (4+!(L%-4))>=_mpsize% 
  1829. _less_memory
  1830. temp_copy(N$)
  1831.  F%,P%,S%,A%,T%,D%,L%,N%,B%,C%,I%
  1832. 'F%=0:P%=_temp_list%:N$=
  1833. tolower(N$)
  1834.  $(P%+16)=N$ 
  1835.  F%=P%
  1836.   P%=!P%
  1837.  F%=0 
  1838. wimp_error(1,0,"Can't locate template "+N$)
  1839. size_of(F%!8):P%=
  1840. malloc(S%+20)+16:T%=F%!8:!(P%-16)=&76C0000:!(P%-12)=0
  1841.  A%=0 
  1842.  S%-1 
  1843.  4:!(P%+A%+4)=T%!A%:
  1844. size_of(F%!12)
  1845. malloc(S%):!(P%-4)=D%:!(P%-8)=0:!P%=P%+4
  1846.  (T%!56)
  1847.  256 
  1848.  L%=T%!80:
  1849.  A%=0 
  1850.  L%-1 
  1851.  4:D%!A%=!(T%!72+A%):
  1852. :!(P%+72+4)=D%:D%+=L%
  1853. N%=T%!84:
  1854.  N%=0 
  1855.  B%=0 
  1856.  N%-1:I%=!(T%+104+32*B%)
  1857.  (I% 
  1858.  256)<>0 
  1859.  ((I% 
  1860.  1)<>0 
  1861.  (I% 
  1862.  2)<>0) 
  1863. )  C%=108+32*B%:L%=!(T%+C%+8):
  1864.  L%>0 
  1865. -    
  1866.  A%=0 
  1867.  L%-1 
  1868.  4:D%!A%=!(A%+T%!C%):
  1869. G    !(P%+C%+4)=D%:!(P%+C%+12)=L%:D%+=L%:!(P%+C%+8)=-1:A%=!(T%+C%+4)
  1870. b    
  1871.  (I% 
  1872.  1)<>0 
  1873.  A%>1 
  1874.  !(P%+C%+8)=D%:T$=
  1875. os_getstring(A%):
  1876. os_putstring(D%,T$):D%+=1+
  1877. win_createwin(D%)
  1878.  W%,A%,E%,F%
  1879.  !(D%-8)<>0 
  1880. wimp_error(1,0,"Trying to create a window that's already there")
  1881.  &400C1,,!D% 
  1882.  W%:!(D%-8)=W%
  1883. size_of(_win_list%):F%=-1:
  1884.  A%=0 
  1885.  E%-1 
  1886.  _win_list%!A%=0 
  1887.  F%=A%
  1888.  F%=-1 
  1889. realloc(_win_list%,E%+16):F%=E%:
  1890.  A%=E% 
  1891.  E%+15 
  1892.  4:_win_list%!A%=0:
  1893. _win_list%!F%=D%
  1894. menu_menuheight(N%)
  1895.  A%,H%,P%:N%+=1:P%=!(_wimp_menu%+4*N%):H%=0:A%=-1:
  1896. :A%+=1
  1897. *H%+=44:
  1898.  (!(P%+A%*24+28) 
  1899.  H%+=22
  1900.  (!(P%+A%*24+28) 
  1901.  128)
  1902. menu_width(N%)
  1903.  P%:P%=!(_wimp_menu%+(N%+1)*4)
  1904. =P%!16
  1905.