Wimpbasic.org


End of bar cap home End of bar cap

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.

hello1

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 hello2 - 506 bytes

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.

hello3.gif

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.

hello4.gif

11. Open the <Windows viewer=>winview> by clicking on this icon.hello5.gif

12. Select Library => Windows from the iconbar menu to open the Directory viewer.

hello6.gif

13. Drag the ProgrInfo4 data file into the Windows viewer.

hello7.gif

14. You can now close the Library => Windows viewer.

15. Create your Hello world window as follows.

  • a) Select Add window from the Window viewer menu.

  • b) Press Menu over the new Window and choose Create icon=>Text. Choose the raised edge border.

  • c) A dialogue opens for you to enter the icon name; enter hello$ and add a description of your own before clicking on OK. The icon appears in the window.

  • hello7.gif

  • d) Press Menu over the icon and select Amend icon #0 to open the Modify icon window.

    Note: No icons must be selected when doing the above as this opens the dialogue in a different way.

    hello8.gif

  • e) Click into the Text writable icon, delete <Untitled> and enter Hello World followed by a click on OK.

  • f) Adjust the window so that there is a 1 inch border around the {*}Hello World{*} icon.

    hello9.gif

  • g) Press Menu over the window again and select Window size.

    hello10.gif

  • h) Click on Set to visible size followed by OK.

  • i) Press Menu over the window again and select Window data. Enter WimpBasic Tutorial into the Title text box. Deselect the H scroll, V scroll and Adjust buttons and click on OK. You now have a small window, with no scroll bars, containing an icon.

    hello11.gif

  • j) Press Menu over the window and click on Save window. A dialogue pops up where you enter the window name; call it HelloWorld and add your own description. The window name and description then appear in the Windows viewer. Note: At this stage the window data is not saved to disc, it is just stored within WimpBasic.

hello12.gif

16. Double click on ProgramInformation in the Windows viewer to edit this window.

hello14.gif

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.hello15.gif

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.

hello16.gif

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.hello17.gif

29. Select Add menu from the Menus viewer menu.

hello18.gif

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.

hello19.gif

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.

hello20.gif

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.

hello21.gif

37. Open the Main menu and save the design file as HelloDes using the File => Save design menu.

hello22.gif

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.

hello23.gif

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.



divider

The contents of these pages represent my own views and not necessarily those of my ISP