Introduction
How to Create a Grid Function Tutorial


    A few weeks ago, someone on the XBASIC mailing list posted a message asking how to go about creating a calendar grid. Since I have been developing a new grid function library, I thought it might be helpful if there was a short tutorial on how to create new grid functions (AKA tools, or widgets, or controls...).  This is not a very difficult process and hopefully this discussion will help all levels of XB programmers in creating their own XB grids.

    The XB PDE can be used to create various combinations of grids in order to create a GUI or Graphical User Interface (pronounced "gooey") program. This involves using the Toolkit and Appearance Windows. I am not going to review how these tools are used to create GUI programs since this subject is covered in other tutorials. I am going to briefly cover how you can convert a GUI progam into a new grid function.

Tutorial Index


What is a grid function?
    The function that creates and operates a particular grid is called its grid function. Grid functions give each grid type its individual characteristics. XuiLabel() and XuiPushButton() make XuiLabel and XuiPushButton grid types look and act differently.

    To perform their function, however, most grid functions have to report certain events or conditions to your program. For example, when a user clicks on a PushButton or presses a key, you're program needs to know. In other words, grid functions create and operate the GUI, and report important events back to your program. How your program responds to these events determines the nature of your program.

How to Create a new grid function
    There are basically just four steps to create a new custom grid function:

    I will go through each of these steps in more detail and provide example code along the way. As suggested by the poster on the mailing list, I will be creating a Calendar grid function named DsCalendar ( ) to use as the example.

Set Objectives
   It is often useful to jot down a list of objectives or goals that you want to accomplish with regards to your new grid function. This should be done before any code is written or any GUI is planned. For our calendar grid, we have the following  simple objectives:

    1. The user GUI should show current month, days in month, and year.
    2. The user should be able to select any previous or future month, day, or year.

    The two objectives clearly state what we want to accomplish. They do not try to describe how the code will work nor describe what the GUI interface will look like.

My Disclaimer



    I am not an expert in XB programming nor in Date and Time algorithms. If you find any bugs in the following examples (and I'm sure that there are a few) then feel free to correct them. I am also sure that there are better and faster ways to create new grid functions. This discussion just documents one particular method that is simple and straightforward.

 Next

(c) 2000  David SZAFRANSKI