home *** CD-ROM | disk | FTP | other *** search
/ ARM Club 1 / ARM_CLUB_CD.iso / contents / magazines / progs / spectrum2 / !Spectrum2 / Articles / Regulars / Prog / WimpIdeaEx < prev   
Encoding:
Text File  |  1994-09-11  |  1.9 KB  |  77 lines

  1. {fon:tri}
  2. As an example for my Wimp idea, first here's a bit of wimp code.
  3. Actually there's a couple of deliberate mistakes in it, but it's so
  4. cryptic that the mistakes are not immediately obvious.
  5.  
  6. $b%="TASK"
  7. SYS"Wimp_Initialise", 200, !b%, Name$
  8. REM == load the templates ==
  9. SYS"Wimp_OpenTemplate",,Dir$+".Templates"
  10. SYS"Wimp_LoadTemplate",,b%,ptr%,Q%+1000,-1,"info"TO,,ptr%
  11. SYS"Wimp_CreateWindow",,b% TO Info%
  12. SYS"Wimp_LoadTemplate",,b%,ptr%,Q%+1000,-1,"control"TO,,ptr%
  13. SYS"Wimp_CreateWindow",,b% TO Control%
  14. SYS"Wimp_CloseTemplate"
  15. REM == Find the iconbar icon ==
  16. DIM isp% 12
  17. !b%=-1
  18. b%!4=0:b%!12=80:b%!8=0:b%!16=80
  19. b%!20=&3102:$isp%="!"+Name$
  20. b%!24=isp%:b%!28=1:b%!32=LEN$isp%+1
  21. SYS"Wimp_CreateIcon", , b% TO ih%
  22. REPEAT
  23. SYS"Wimp_Poll", 49, b% TO act%
  24. CASE act% OF
  25.   WHEN 2:SYS"Wimp_OpenWindow",,b%
  26.   WHEN 3:SYS"Wimp_CloseWindow",,b%
  27.   WHEN 6:PROCButton
  28. ENDCASE
  29. UNTIL Quit% 
  30. SYS"Wimp_CloseDown"
  31. END
  32. DEFPROCButton
  33. CASE b%!12 OF
  34.   WHEN Info%
  35.     PROCopenall
  36.   WHEN Control%
  37.     CASE b%!16 OF
  38.       WHEN 1:PROCthis
  39.       WHEN 2:PROCthat
  40.       WHEN 3:PROCother
  41.     ENDCASE
  42.   ENDCASE
  43. ENDPROC
  44.  
  45.  
  46.   This is what the same thing would look like if there was direct
  47. support for the Wimp from BASIC. All the standard stuff virtually
  48. disappears. The procedures that do the work look much the same except
  49. that the cryptic "b%!12" and "b%!16" have been replaced by meaningful
  50. variable names.
  51.  
  52.   APPLICATION("MyProg$Dir","MyProg")
  53.   ICONBAR("!MyProg")
  54.   WHENEVER MOUSE_CLICK window$,icon%,button%:PROCbutton
  55.   WIMP_POLL
  56.   END
  57.   DEFPROCbutton
  58.   CASE window$ OF
  59.     WHEN "Info"
  60.       PROCopenall
  61.     WHEN "Control"
  62.       CASE icon% OF
  63.         WHEN 1:PROCthis
  64.         WHEN 2:PROCthat
  65.         WHEN 3:PROCother
  66.       ENDCASE
  67.     ENDCASE
  68.   ENDPROC
  69.  
  70.   I can't that imagine any of this would be very difficult to add to
  71. the BASIC interpreter. With something like this, it would be possible
  72. for someone with a little bit of BASIC experience to write simple,
  73. readable, multitasking programs.
  74.  
  75. {spr:l03}
  76. {end}
  77.