Back

RBgen - Run Basic Code Generator

Overview
Example Database
Defining the Program
Running RBgen
Code Generation
Running the program code
Header
Sorting the data
Searching the data
Record Maintenance
Pop Up data

Overview

RBgen is a system that generates Run Basic code against a SQLite table.
The Generated code does the following.
1. List information in the table.
2. Gives you a Login to secure Add/Change and Delete
3. Allows various sorts
4. Allows drill down using Wild Cards or Compares on multiple fields
5. You can go to the next page, previous page or directly to a page
6. Creates CSV and fires the OO spread sheet.
7. Creates Pop Up Calendar
8. Creates Pop Up Time
9. Contains the necessary code to be launced from a RUN command.
10. Creates drop down for maintenance.
11. Creates Radio buttons for maintenance
12. Maintains Control sequence fields and reuses numbers.
back to top


Example Database

For an example we will create a calendar database that allows you to schedule time for various assets and/or users.
There are 3 tables
1. schTime table allows you to schedule time.
2. user table is a table of users
3. The asset table is a list of assets

Table:schTime

Name

Type

Length

schNum INT

 

userNum INT

 

schBeg DATE

 

schEnd DATE

 

assetNum INT

3

event CHAR

4

name VARCHAR

10

descr VARCHAR

50

Table:asset

Name

Type

Length

assetNum INT

3

assetType VARCHAR

3

short VARCHAR

10

Table:user

Name

Type

Length

userNum INT

10

firstName VARCHAR

22

middleName VARCHAR

22

lastName VARCHAR

22

addr VARCHAR

22

city VARCHAR

22

state CHAR

3

zip VARCHAR

10

country VARCHAR

4

phone VARCHAR

17

eMail VARCHAR

40

back to top


Notice the schTime table has a control field called schNum. Each record is assigned a unique number. The RBgen program can maintain unique assigned numbers. During the assignment, it does not always assign the next available number. If there are holes left from previously deleted records, it will reuse those numbers first. We have all spend time trying to resequence master files when you run out of numbers. With this number reuse, that is eliminated.

RBgen generates a base or beginning program. Since the RB program generator cannot guess exactly what everyone wants, it generates code to maintain the entire table information. It is up to you to modify the program. However, normally it is fairly complete, and you only have to do cosmetic changes.


Defining the Program
Lets begin by defining what we want.
1. We want a RB program to list, maintain, drill down, and sort the schTime table.
2. We want the maintenance to create a drop down list for users and assets.


back to top

Running RBgen

OK.. Lets generate the code.
Bringing up the RBgen program will present a screen that looks like this:

V 1.20

Code Generator

Generate RB Maint Code

DataBase
Table Name
Auto Seq Field


Database

Enter complete directory and database name

Tabe

A table within the database.

Drop Down or Radio

This will create Drop Down or Radio input fields. 1. Click the [Drop Down] button 2. Select a field you want a drop down on 3. Select a table to get the drop down information from 4. Click the [Accept] button. This will bring up the field to compare and what you want to display. 5. Select something to 'Compare' to 6. Select something to 'Display' in the drop down 7, Click [Make Drop]. This will show you the data that will make the drop down. You can [Delete] any drop downs you created. 8. Click [Gen Code]. This will create your program.

Auto Sequence field

Optional field. This is a control field for the table. When adding a new record the system will automatically assign a unique sequence number to it. For example if the table is customer, and the control field for customer is custNum. Then you can have the system assign a new custNum when you create a new Customer.

1. Enter the name and location of the database.
In this case it's c:\rbp101\projects\calendar_project\data\cal.db

2. Enter the schTime table to generate code for

3. Since we have a auto sequence number called schNum, we enter that.

Since we want Drop Downs for assets and users, click the [Drop Down] button.
The following screen will pop up.
schTime.field =

Table.

 


Since we want a drop down for asset, select assetNum in the first column, and look for the value of assetNum in the asset Table in the second column. Then click the [Accept Drop] button. Another Pop Up screen will appear as follows

Compare

=

Display

 


Here we need to know what to Compare to in the asset table, and what to Display in the Drop Down.
We want to compare to the asset number (assetNum), and display the description (descr)
Now click the [Make Drop] button to make the drop down. The following will appear:

1. Drop schTime.assetNum = asset.assetNum Display asset.descr

This lets you know you are creating a Drop down by comparing schTime.assetNum = asset.assetNum and Displaying asset.descr in the drop down.

Now do a similar thing for the user Drop Down

You could just as easily made the Drop Down into a Radio button by clicking the [Radio] button instead of the [Drop Down] button.

back to top


Code Generation

To generate the code click [Gen Code]. It will tell you where it placed the code;

Output File: c:\rbp101\public\schTime.bas

Cut the output area from the screen and place it wherever you want. Usually you bring it into an editor.


back to top

Running the Generated program code

Anyway the code is ready to run.

Since it has no idea how you want to secure your Login the username and password are the same as the table you generated the code. In this case it's user:schTime and pass:schTime.
You can change it in the program: (should be around line 6)
keyUser$ = "schTime"
keyPass$ = "schTime"

Running the Generated code you should see the following screen.

Records:8 Pages:1

SchNum  

Maint

SchNum

UserNum

SchBeg

SchEnd

AssetNum

Event

Name

Descr

View

1

1

2009-10-01 01:00 2009-10-01 02:00

0

vac Vacation I'm outta here

View

2

1

2009-10-01 04:00 2009-10-01 05:00

6

met Auditor Here come the auditors

View

3

2

2009-04-01 08:30 2009-04-01 09:30

1

met Sch Financial Meeting with Financial

View

4

1

2009-10-01 10:30 2009-10-01 10:45

0

sic sick I plan on being sick

View

5

1

2009-10-01 06:00 2009-10-01 07:00

0

vac Mexico I will be on the beach.

View

6

1

2009-09-29 08:00 2009-09-29 09:15

1

met Production Production meeting

View

7

1

2009-12-26 20:25 2009-12-31 20:16

0

oth Moving Vacation

View

8

2

2009-04-01 05:44 2009-04-01 06:44

0

met my meeting whatever

Notice there is no way to maintain the data, such as Add, Change, or Delete.
However if you click [Login] and enter schTime/schTime, you will be granted maintenance privileges.

Header:

[Login] - Login into the system to get maintenance privileges.
[Export] - Will create a CSV flat file for spewd sheets.
[Help] - The system generates some very basic help . It is up to you to change it.
[Exit] - Will leave the system and return to your web page. If you do not want it to leave the system, the modify or delete this.
Records: - Lets you know how many records match the search. If there is no search then it is the total records
Pages: - How many pages there are. This is based on the number of Lines per page and the number of records
[Prev] - Go to the previous page
Page number.. You can go directly to a page by changing this and clicking on [Next]
[Next] - Go to the next page
[Lpp] - The default lines per page is 25. You can change that and click [Lpp]

back to top

The second line:

Sorting
Sort drop down is for the sort method. In this case it's in SchNum sequence.
You can select another sort from the drop down and click [Sort]. For more refined sorts, or additions or deletions look at the comments in the generated code

back to top

Searching

If you click [Search] it will present a list of all the fields. You can select one or many fields to drill down on. You can use wild cards, or compares such as =.<> > < etc.

The table List.
The first column is the Maint.
[View] - lets you view the detail.
If you logged in and get privileges it will also show:
[Chg] - to change a record
[Del] - to Delete a record.

back to top

Maintenance.

When you click [Add], [Chg], or [Del] this screen will appear.

schTime Maintenance

SchNum

1

UserNum

SchBeg

 

SchEnd

 

AssetNum

Event

Name

Descr

   

Notice the Drop Downs for the UserNum and the AssetNum.

PopUps

All date fields have a [D] and a [T] button. If you click [D] a date picker pop up window ill appear. It will display the year and month you have in the field. If nothing is in the field, it displays the current month.

Oct 2009

Sun

Mon

Tue

Wed

Thr

Fri

Sat

 

 

 

 

If you click the [T] filed a time picker pop up window will appear.

Hr

Min

Sec


All time fields will have the [T] button..

back to top