next up previous contents
Next: 2 The Language Up: 1 Introduction Previous: 1.1 The Idea

1.2 Overview

QddbScript is extremely simple and even somewhat language independent. Its simplicity is best demonstrated with a simple example, so let's work our way through one. Suppose we have the following simple Qddb Schema for business invoices:

    Number verbosename "Invoice Number" type string
    Date type date format "%m/%d/%y %H:%M:%S"
    DayOfWeek verbosename "Day of Week"
    SalesPerson verbosename "Sales Person"
    Items (
        Qty type real format "%.2f"
        Code
        Desc verbosename "Description"
        Taxable exclude
        Price type real format "%.2f"
        Total type real format "%.2f"
    )*
    Subtotal type real format "%.2f"
    Discounts type real format "%.2f"
    Tax type real format "%.2f"
    Total type real format "%.2f"
    PaymentType verbosename "Payment Type" type real format "%.2f"
    PaymentAmount verbosename "Payment Amount" type real format "%.2f"
    AmountDue verbosename "Amount Due" type real format "%.2f"

The database described by this Schema contains a number of records, where each record contains a unique invoice number, any number of items, and some other informational fields. Using Qddb's nxqddb(1), we can have this simple database up and running in a few minutes. However, if we want to design a custom form, we have to use the Fx toolkit or Qtcl+Tk. As of Qddb 1.43R5, QddbScript gives us the ability to display the database fields with an automatically generated form-style interface. If the automatically generated form doesn't satisfy the designer, they can quickly modify the QddbScript by moving fields around, adding notebook tabs, changing field types and sizes, and so forth. The entire interface definition is written in QddbScript and does not require knowledge of Tck/Tk or any other scripting language. Custom functions, however, must be written in a standard (and more complicated) scripting language such as Tcl (Qtcl).

To build the initial database and interface template, you can run the following commands:

    1) $ qnewdb MyDB
    Remember to edit the Schema for relation MyDB.
    2) $ vi MyDB/Schema
    (type in Schema description)
    3) $ qddbscript autogen MyDB
    4) $ vi MyDB/QddbScript
    (change the interface definition)

After this sequence of commands, the contents of MyDB/QddbScript is as shown in Figure 1.1. Notice the marked (and intentional) similarity between the original Schema and the QddbScript. While this convenient default (see Figure 1.2 for a screenshot) may work fine for some situations, most applications need a more customized look and feel. By adding and moving some lines in our QddbScript and increasing the widths of various fields (Figure 1.3), we get a reasonably nice-looking form as seen in Figure 1.4. Typing has been significantly reduced from the equivalent code in Fx and the resulting script is significantly easier to manage (add new fields, etc.) Of course, all the standard database functions are automatically in place and ready to use after the QddbScript is modified.

  

    [prologue]
    [menubar]
    [options autoalign]
    [entry attr=Number width=10]
    [entry attr=Date width=10]
    [entry attr=DayOfWeek width=10]
    [entry attr=SalesPerson width=10]
    [break]
    [frame attr=Items border=3 relief=groove]
        [entry attr=Items.Qty width=10]
        [entry attr=Items.Code width=10]
        [entry attr=Items.Desc width=10]
        [entry attr=Items.Taxable width=10]
        [break]
        [entry attr=Items.Price width=10]
        [entry attr=Items.Total width=10]
    [end frame]
    [break]
    [entry attr=Subtotal width=10]
    [entry attr=Discounts width=10]
    [entry attr=Tax width=10]
    [entry attr=Total width=10]
    [break]
    [entry attr=PaymentType width=10]
    [entry attr=PaymentAmount width=10]
    [entry attr=AmountDue width=10]
    [epilogue]

Figure 1.1: Automatically generated QddbScript

   figure45
Figure 1.2: nxqddb screen before modifying QddbScript

  

    [prologue]
    [menubar]
    [options autoalign]
    [entry attr=Number width=15]
    [entry attr=Date width=10]
    [entry attr=DayOfWeek width=10]
    [break]
    [entry attr=SalesPerson width=40]
    [break]
    [frame attr=Items border=3 relief=groove]
        [entry attr=Items.Qty width=10]
        [entry attr=Items.Code width=10]
        [break]
        [entry attr=Items.Desc width=40]
        [break]
        [entry attr=Items.Taxable width=2 noexpand]
        [entry attr=Items.Price width=10] 
        [entry attr=Items.Total width=10]
    [end frame]
    [break]
    [entry attr=Subtotal width=10 side=right noexpand]
    [break]
    [entry attr=Discounts width=10 side=right noexpand]    
    [break]
    [entry attr=Tax width=10 side=right noexpand]
    [break]
    [entry attr=Total width=10 side=right noexpand]
    [break]
    [entry attr=PaymentAmount width=10 side=right noexpand]
    [radiobutton attr=PaymentType width=10 side=right noexpand
        value="Mastercard" value="Visa" value="AmEx" value={Discover}
    ]
    [break]
    [entry attr=AmountDue width=10 side=right noexpand]
    [epilogue]

Figure 1.3: Customized QddbScript

   figure55
Figure 1.4: nxqddb screen after modifying QddbScript


next up previous contents
Next: 2 The Language Up: 1 Introduction Previous: 1.1 The Idea

Herrin Software Development, Inc.