home *** CD-ROM | disk | FTP | other *** search
/ APDL Public Domain 2 / APDL_PD2A.iso / magazines / _tyrant2 / pages / page6 < prev    next >
Encoding:
Text File  |  1995-06-01  |  4.4 KB  |  101 lines

  1. >POSITION 20,1900
  2. >SIDE Left
  3. >STYLE Heading
  4. The WIMP Part 2
  5. >STYLE Body
  6. We have received a huge amount of mail complimenting our BASIC guide but
  7. everybody has said that the first part of programming the WIMP seemed to be
  8. in a different language.  As understanding the early steps is so important I
  9. thought it better to go over it again rather than move onto the tricky subject of
  10. windows.  The parameters for the various SWI calls were listed in the first
  11. Tyrant and so will not be listed again to try and save some space on this 
  12. already overcrowded disk magazine.
  13.  
  14. If you run the !Simple application included in the extras directory with this issue
  15. nothing appears to happen.  In fact the program initializes itself and than polls.
  16. You can quit it from the Task Display.  The !Run file needs little explanation.
  17. It runs the BASIC file and makes it occupy 16K of RAM.  In fact on a 4MB
  18. machine 32K is the minimum and so it will run in this amount of memory
  19. instead.
  20.  
  21. The program itself does a few things.  First it initializes and sets up the error 
  22. handling which will be covered in more detail in a future article.  Then it
  23. initializes using the Wimp_Initialise SWI.  SWIs from BASIC were discussed in
  24. detail in last issue and everybody seemed to understand that bit.
  25.  
  26. The bit that nobody understood was the Wimp_Poll SWI.  Basically this just
  27. asks the wimp what is going on.  The WIMP then returns information to the
  28. program in a form of numbers.  For example numbers 17 and 18 mean use
  29. message. Therefore when we receive 17 or 18 the program goes to a new
  30. procedure which looks at which user message has been received. Presently
  31. we only look for one, message 0 which means quit.  If we have received it then
  32. the program ends.
  33.  
  34. Not too difficult really.  Just play around with the various masks and things on
  35. the Wimp_Poll and see what happens.  The error routines should work if you do
  36. anything wrong.
  37.  
  38. Please do not fail to contact me if you still have any problems with programming
  39. the WIMP so far.  It is a difficult subject but when combined with languages
  40. such as C and ARM code which we will be bringing you soon it is important you
  41. have a good understanding of the WIMP and what better a language than
  42. BASIC.
  43. >POSITION 1300,1900
  44. >SIDE Right
  45. >STYLE Heading
  46. BASIC No.2
  47. >STYLE Body
  48. In the last instalment of this on going page, I bored you silly with the do's and
  49. don'ts of variables, but no more!  This time I've supplied you with a fully working
  50. program  whose only purpose in life is to record yours' and you friends'
  51. telephone numbers and addresses.  In future instalments, it will be able to save
  52. interrogate and print the information you give it!  It's not really life saving stuff I'll
  53. admit (You can get better presented stuff that runs on the desktop) but it does
  54. serve to demonstrate some important concepts of programming.  The first is this
  55.  
  56. >STYLE Sub
  57. Entering And Storing Data
  58. >STYLE Body
  59. The program uses two important 'devices' for this.  The first is the keyword 
  60. INPUT which is used to get names, addresses and numbers The syntax of the
  61. INPUT keyword is this:
  62. >STYLE Code
  63. INPUT ["display string"][,;]<variable>
  64. >STYLE Body
  65. forget about the brackets ([] and <>).  This is an example of INPUT
  66. >STYLE Code
  67. INPUT "What is your name";name$
  68. >STYLE Body
  69. "What is your name" is the display string.  ; is the separator between the string
  70. and variable name$ is the variable where the person's name will be stored
  71.  
  72. The "Display string" can be any expression whose result is a string eg:
  73. >STYLE Code
  74. "Type your name person "+STR$person_number%
  75. "How are you "+person_title$
  76. >STYLE Body
  77. The separator as I call it, separates the string from the variable.  It can either be
  78. a semi-colon (;) or a comma If it is a semi colon, a question mark is inserted
  79. after the display string.  If it is a comma then no "?" is inserted. 
  80.  
  81. To store the data, three arrays of 50 elements are used to store The persons
  82. name, address and phone number. These are setup in this way:
  83. >STYLE Code
  84. DIM names$(50)
  85. DIM addresses$(50)
  86. DIM numbers$(50)  
  87. >STYLE Body
  88. (I used a string array for the telephone numbers in order that dashes and
  89. backslashes can be used for things like extension numbers.)
  90. Data can then be stored in the array by this method:
  91. >STYLE Code
  92. names$(1)=name$
  93. addresses$(1)=address$
  94. >STYLE Body
  95.  
  96. The accompanying program can by found in the extras directory
  97.  
  98. Copy the example program and change parts of it so you become familiar with
  99. what each line does.
  100. Zeus
  101.