1. Getting started
As with all new languages, you need to do something simple. This following program, written by David Jackson of Clares shows you how simple it is to get Wimpbasic programs up and running. The tutorial which follows is in fact the first one that you are asked to do when learning Wimpbasic. The program is the famous 'Hello World' which virtually every programmer in the world has written at one time or another!
The HelloWorld Tutorial
1. Startup WimpBasic and open the Main window by clicking on the icon.
2. Enter Hello World into the Program name field.
3. Enter 64 in the Memory needed box
4. Open the Sprites viewer by clicking on this icon
5. Open the Tutorials.Sprites directory on your disc.
6. Drag the sprite file HelloSpr into the Sprites viewer window.
7. You should now see the sprite !hellowrld displayed in the viewer.
8. Close the Sprites viewer window.
9. Open a menu by clicking on the Iconbar sprite menu button in the Main window.
10. Select Application => !hellowrld from the menu.
11. Open the <Windows viewer=>winview> by clicking on this icon.
12. Select Library => Windows from the iconbar menu to open the Directory viewer.
13. Drag the ProgrInfo4 data file into the Windows viewer.
14. You can now close the Library => Windows viewer.
15. Create your Hello world window as follows.
16. Double click on ProgramInformation in the Windows viewer to edit this window.
17. Change the Name field to HelloWorld by menuing over the field and selecting Amend icon #n (n is the number of the icon). This opens the Modify icon window where you can enter HelloWorld into the Text box. Click OK to action the change.
18. Do the same for Purpose (enter Demonstrate WimpBasic), Author (enter your name) and Version (enter Version 1.00).
19. Select Save window from the Window Designer menu and click OK.
20. Close the Windows viewer.
21. Open the Code viewer by clicking on this icon.
22. Select Add code from the Code viewer menu.
23. Enter this procedure:
DefProcQuitProgram
Rem Called when user selects Quit from menu
Quit
EndProc
24. Save the code by clicking on Save code in the editor menu. The Procedure name is extracted from the DefProc and the comment is extracted from the Rem statement.
25. Select Add code from Code viewer menu again and enter this procedure:
DefProcOpenWindow
Rem Called when user clicks on iconbar icon
Open HelloWorld
EndProc
26. Save the code by clicking on Save code in the editor menu.
27. Close the Code viewer.
28. Open the Menus viewer by clicking on this icon.
29. Select Add menu from the Menus viewer menu.
30. Enter IconbarMenu as the Menu name. Description should contain something like Menu displayed on the icon bar. Enter Hello World into the grey Menu title, to the left of S-cut. The first menu entry below Hello World should be Info. Enter this by clicking into the white menu area and entering Info. Click on Extend menu to add another line to the menu and enter Quit.
31. Open the Submenu/window menu for the Info entry and select Windows => ProgramInformation. This will appear in the box and attaches the ProgramInformation window to the Info menu item.
32. Open the Procedure menu for the Quit entry and select PROCQuitProgram. This attaches the procedure to the menu item Quit and the procedure is called when the user clicks on Quit.
33. Click on the Save button to save the menu to the Menus viewer.
34. Close the Menus viewer.
35. Open the Iconbar menu in the Main window and select IconbarMenu. This attaches the menu you have created to the iconbar icon of your application.
36. Open the Select procedure menu in the Main window and select ProcOpenWindow. This tells the application to run the procedure when the user clicks on the iconbar icon with the Select mouse button.
37. Open the Main menu and save the design file as HelloDes using the File => Save design menu.
38. Save the application as !HelloWrld using the File => Save application menu. This compiles your application and saves it to disc.
Note: If you get an error during compilation see the notes on Debugging.
Your Hello World application is now ready and can be run by double clicking on the icon in the filer. Click on the icon on the icon bar to open the window and try out the icon bar menu.
Okay, so it's not very exciting but it is your first WimpBasic program and if you try to create it again you will do it very much faster this time.
Return to top of page.
|