Home > Articles > Programming

  • Print
  • + Share This
This chapter is from the book

Method Main ( )

The first instruction that tells Phrogram to do something specific is always the first line in Method Main().Method Main() may seem like an arbitrary way to define where the program begins processing instructions, but this is based on how all other modern programming languages work. Just as every program (or phone call!) requires a start and end point, so does every method inside the program, which is why you see End Method on line 10.

We will explain methods further in this short cut, but for now, just take it as a given when you look at the following code that these four instructions "in" Method Main tell Phrogram to display the UFO:

Method Main()
     Define myUFO As Sprite
     myUFO.Load( "ufo.gif" )
     myUFO.MoveTo( 50, 50 )
     myUFO.Show()
End Method

You've probably wondered about the blank lines that are mixed in with the instructions. Blank lines are not actual instructions—Phrogram just ignores them. You can just as easily remove blank lines if you prefer, but we don't recommend that. We think you will find that using blank lines and indentation, as we show them in Figure 2.2, will help you and other people read and understand your program more easily.

Figure 2.2

Figure 2.2 Blank lines can group instructions logically, and make them easier to read

Let us summarize, in English, what the instructions on lines 5 through 8 tell Phrogram to do, and then we will examine the instructions in detail:

  • myUFO is a graphical object.
  • Load the graphics picture for myUFO from the image file "ufo.gif".
  • Move myUFO to the screen location (50, 50).
  • Show myUFO on the screen.
  • + Share This
  • 🔖 Save To Your Account