Start To Program Now!

 


1. How do I write a starter program?

The simplest possible starting program is the Hello World program. This asks you to type in your name, then prints out a short greeting:

  // Myfirst.cls
  Ubercode 1 Class Myfirst

  public function main()
  var 
    MyName:string[*]
  code
    MyName <- Inputbox("Myfirst", "What is your name?")
    call Msgbox("Myfirst", "Hello "+MyName+"!", "OK")
  end function

  end class

The following steps show how to run the program. They assume you've installed Ubercode - if not download the free Trial Package then continue.

(i) Start the Developer Environment

Start the Developer Environment from Windows, using Start - Programs - Ubercode - Developer Environment or by double clicking the Ubercode icon on the desktop.

When it starts, you will be shown the Startup Wizard screen. In the Startup Wizard, click the Close button because we don't need the wizard at this time. After the wizard has gone, your desktop should look like this:

Hello World Program - Picture of Developer Environment

The top part of the screen is occupied by the main menu.

(ii) Write the Program

In the Developer Environment, use the File - New - Program menu command to write the code. A dialog titled "New Program" will appear. Click in the entry field next to "Name" and type in "Myfirst" (without the quotes). Then click in the entry field next to "Program Type", delete the existing text and and type in "2" (again without the quotes). Click OK to create the new program which looks like this:

Picture of Edit window

The name you typed in (Myfirst) was used as the class name and the file name. It's not essential the name was "Myfirst", you could have typed any other alphabetic name. The choice of "2" (Program type = Main function) means the new program uses a function (block of code) instead of a window. Now change the program to use an Inputbox to prompt for the name and a Msgbox to display the result. Change the following code:

   public function main()
   code
     // Put code here
   end function

into this:

   public function main()
   var 
     MyName:string[*]
   code
     MyName <- Inputbox("Myfirst", "What is your name?")
     call Msgbox("Myfirst", "Hello "+MyName+"!", "OK")
   end function

The changes are to declare a string variable MyName, and to add the calls to Inputbox and Msgbox. When changing the code, make sure the commas and double-quotes match those above.

(iii) Run the program

Now it's time to compile the program and run it. Click the Run button and wait a few moments:

Picture of Run button

The program is saved automatically when the compiler starts. After it compiles, the program starts running as a Windows EXE file. You should then see the Inputbox appear:

Hello World Program (Inputbox)

Type some text in the Inputbox and click OK. You should then see the Msgbox:

Hello World Program (Msgbox)

The text that came from the Inputbox forms part of the greeting in the Msgbox. If you look at the call to Msgbox in the code, you'll see there are two string parameters. The first string "Myfirst" is put in the message box caption (the blue area) and the second string (the greeting message) is in the main part of the message box. This order is easy to remember because it flows down the page.

Finally, click OK to close the program.

2. How does Ubercode work?

Start by writing a program, which is a list of commands to be processed by the computer. A typical beginner's program has 20 or 30 lines of commands. Then design the forms (windows) used by the program. After writing the program you compile it. The compiler checks the code for errors and if OK it makes an EXE file. Then you run the EXE file which carries out the commands in the program. Here's a diagram:

Start to Program - Diagram shows how a program is created

The diagram shows how the compiler converts the program, the resource file(s) and the run time library into an EXE file. The run time library contains many powerful commands ready for use in your programs. This is code you don't have to write. The steps shown above are automated using the Developer Environment, which is a "control centre" for writing programs.

The EXE file shown near the bottom is a very important file. This contains all of your program in a condensed (binary) form, and can be run independently of the Developer Environment, or copied to other computers (licence permitting).

3. What help is available when writing a program?

Different levels of help are available, depending on whether you want help with a specific command, or whether you want help writing a particular type of program.

  • Within the Developer Environment, use the help system to get help on specific commands. Move the cursor to the command, press the F1 key and a help page appears. This works with run time library commands and language keywords (if, else etc). The help pages include example programs, so you can see how the command works and experiment with it.
  • If you want help with a specific command but you're not sure how to spell it, use Help - Index in the Developer Environment. This brings up a list of commands, and you can search for the one you want.
  • Use the Alphabetic Command Reference to read through the list of commands. The Alphabetic Command Reference is in the on-line help system.
  • After compiling a program, the browser can show more information about most of the identifiers used in the program. Use the View - Browse info command in the Developer Environment. The browser loads the list of symbols used in the program, and you can select any of them to get more information.
  • If your question is "How do I write a program to carry out a particular task", go to the main Technical Support page on the website. This webpage has a database of sample code for many different programming tasks. If you don't see what you need, use the email link to ask your question.
  • Answers to "How it Works" questions are in the help system. Use the Help - How Do I menu command in the Developer Environment to read a list of common "How it Works" type questions.

4. Where can I find more starter programs?

Example programs are available from the following places:

  • The Technical Support database has real-life working example programs.
  • The Developer Environment has more tested examples. Use the File - Open Examples command to see the list of examples, then you can open or run the examples directly.
  • The Help system has a tested example for most commands in the run time library. In the Developer Environment, use the Help - Index menu command to bring up the index and look for the command you are interested in. Then if the Example button is enabled, click it to copy the example to the clipboard, then back in the Developer Environment click Edit - Paste. You can run the example directly from the Developer Environment.
  • The Help system also has an alphabetical list of all the commands in Ubercode. To access the list, choose the Developer Environment's Help - Index command and look for the Alphabetic Command Reference topic. Each command has a detailed explanation and an example.

5. How do I run an example program?

  • The example programs are an easy way of learning programming. To run the examples, start the Developer Environment by double clicking its icon:

    Learn Programming - Startup icon

  • If you know the name of the file containing the example, use the File - Open command to open the file.
  • Click the Run button to compile and run the example:

    Learn Programming - Picture of Run button

  • If the example is stored in the help file, look for the "Example" button near the top of the help page:

    Learn Programming - Winhelp with the Example button circled

  • Whenever this button is enabled, click it to copy the example to the Windows clipboard. A short bleep sounds if the example was successfully copied.
  • In the Developer Environment, use Edit - Paste to paste the example program. When you are prompted to save the example program files, click OK to accept the defaults, or choose different folders and/or names if you want.
  • Click the Run button to compile and run the example.