home *** CD-ROM | disk | FTP | other *** search
- >POSITION 20,1900
- >SIDE Left
- >STYLE Heading
- The WIMP Part 2
- >STYLE Body
- We have received a huge amount of mail complimenting our BASIC guide but
- everybody has said that the first part of programming the WIMP seemed to be
- in a different language. As understanding the early steps is so important I
- thought it better to go over it again rather than move onto the tricky subject of
- windows. The parameters for the various SWI calls were listed in the first
- Tyrant and so will not be listed again to try and save some space on this
- already overcrowded disk magazine.
-
- If you run the !Simple application included in the extras directory with this issue
- nothing appears to happen. In fact the program initializes itself and than polls.
- You can quit it from the Task Display. The !Run file needs little explanation.
- It runs the BASIC file and makes it occupy 16K of RAM. In fact on a 4MB
- machine 32K is the minimum and so it will run in this amount of memory
- instead.
-
- The program itself does a few things. First it initializes and sets up the error
- handling which will be covered in more detail in a future article. Then it
- initializes using the Wimp_Initialise SWI. SWIs from BASIC were discussed in
- detail in last issue and everybody seemed to understand that bit.
-
- The bit that nobody understood was the Wimp_Poll SWI. Basically this just
- asks the wimp what is going on. The WIMP then returns information to the
- program in a form of numbers. For example numbers 17 and 18 mean use
- message. Therefore when we receive 17 or 18 the program goes to a new
- procedure which looks at which user message has been received. Presently
- we only look for one, message 0 which means quit. If we have received it then
- the program ends.
-
- Not too difficult really. Just play around with the various masks and things on
- the Wimp_Poll and see what happens. The error routines should work if you do
- anything wrong.
-
- Please do not fail to contact me if you still have any problems with programming
- the WIMP so far. It is a difficult subject but when combined with languages
- such as C and ARM code which we will be bringing you soon it is important you
- have a good understanding of the WIMP and what better a language than
- BASIC.
- >POSITION 1300,1900
- >SIDE Right
- >STYLE Heading
- BASIC No.2
- >STYLE Body
- In the last instalment of this on going page, I bored you silly with the do's and
- don'ts of variables, but no more! This time I've supplied you with a fully working
- program whose only purpose in life is to record yours' and you friends'
- telephone numbers and addresses. In future instalments, it will be able to save
- interrogate and print the information you give it! It's not really life saving stuff I'll
- admit (You can get better presented stuff that runs on the desktop) but it does
- serve to demonstrate some important concepts of programming. The first is this
-
- >STYLE Sub
- Entering And Storing Data
- >STYLE Body
- The program uses two important 'devices' for this. The first is the keyword
- INPUT which is used to get names, addresses and numbers The syntax of the
- INPUT keyword is this:
- >STYLE Code
- INPUT ["display string"][,;]<variable>
- >STYLE Body
- forget about the brackets ([] and <>). This is an example of INPUT
- >STYLE Code
- INPUT "What is your name";name$
- >STYLE Body
- "What is your name" is the display string. ; is the separator between the string
- and variable name$ is the variable where the person's name will be stored
-
- The "Display string" can be any expression whose result is a string eg:
- >STYLE Code
- "Type your name person "+STR$person_number%
- "How are you "+person_title$
- >STYLE Body
- The separator as I call it, separates the string from the variable. It can either be
- a semi-colon (;) or a comma If it is a semi colon, a question mark is inserted
- after the display string. If it is a comma then no "?" is inserted.
-
- To store the data, three arrays of 50 elements are used to store The persons
- name, address and phone number. These are setup in this way:
- >STYLE Code
- DIM names$(50)
- DIM addresses$(50)
- DIM numbers$(50)
- >STYLE Body
- (I used a string array for the telephone numbers in order that dashes and
- backslashes can be used for things like extension numbers.)
- Data can then be stored in the array by this method:
- >STYLE Code
- names$(1)=name$
- addresses$(1)=address$
- >STYLE Body
-
- The accompanying program can by found in the extras directory
-
- Copy the example program and change parts of it so you become familiar with
- what each line does.
- Zeus
-