Adding Data to a Database

A database isn't very useful without some actual data, so zMUD provides several ways to easily populate your database with information. While you can start adding data as soon as you define the fields in a database, it can be very useful to also define some database Views before entering data. The reason for this is that any field set up as a filter in the View will automatically get set when a new record is created so that it satisfies the filter.

For example, if your view is set up to filter records with the Kind field set to Weapons, then when you create a new database record within this view, the Kind field will automatically get set to Weapons. All other fields in the new record are set to their default field value if any is specified. Using Views in this way allows you to enter data very quickly without setting certain fields to the same value all of the time. You'd enter all of your weapons using the Weapons view, your armor using the Armor view, etc.

Adding Records

There are many ways to add data records to your database. The most straightforward is to simply click in the first column of the last row of the current view. This last row is always reserved for a New record. As soon as you enter a value into any of the cells in the last row, a new record is automatically created. Pressing Tab from the last column of a row will send you to the first column of the next row, so you can add records by simple starting to type. Press Tab to move from column to column and from the end of one record to the start of the next. This again illustrates the value of defining your own View before entering data. If you enter data into the All view you have to supply values for each column. In your own view you only have to enter data for the columns that are displayed in the view.

You can also move around the grid using the arrow keys. The up and down arrow move you to the next or previous record, keeping the cursor in the same column. The left and right arrows are a bit trickier. If the entire field is highlighted, the left and right arrows will move you to the previous or next column. If the field is not highlighted, the left and right arrows just move the cursor within the text value of the field.

When entering data for each field, use the keyboard. For a text field, just type the value you want. For number fields, simply type the number you want, although you can also use the + and - keys on the keypad to increment and decrement the value. For Single Option fields, start typing the value of the field and the option that matches what you are typing will be shown as you type. If the field does not allow other values, a beep will occur if you press a key that is not allowed. For Option List fields, enter the first few unique characters of each option, and separate each option with a comma. Unlike the Single Option fields, the matching values are not displayed as you type.

The List and Detail modes

The List mode displays your database information in a grid format with each record on its own row and field values in the columns. This is similar to other database programs and spreadsheets such as Excel. The List mode is designed to make it very easy to enter data using the keyboard as described above. Clicking the Detail button switches the database into Detail mode and provides a different way to look at your data. In Detail mode, the list of records in the database are shown on the left, and in the main window to the right, each field of the database is shown on a separate line. Text fields are displayed as text input boxes, Memo fields are displayed as multiline input boxes, Number fields are displayed as a numeric input box, Single Option and Option Lists are shown as selection boxes, etc. If there are more fields than can be displayed in one window, you can scroll down to view the other fields. The Detail mode is designed to be edited with the mouse rather than with the keyboard. To edit a field, click on it. To edit a number, click the Up or Down arrow buttons to increment or decrement the number. Tab will still move you from one field to the next but will not move from the last field in a record to the next record. To create a new record, you click the New button on the toolbar. To delete a record you click the Delete button.

You can use either the List or Detail mode as much as you want. It doesn't matter which mode you use to view or edit your data. The View still controls the order of the fields and which fields are displayed, and how the list of records is filtered and sorted.

Copying and Pasting records

You can select a record by clicking on the record number column at the left of the record you want. To select multiple records, hold down the mouse and drag it up or down over several records. You can also select the start record and the Shift-Click on the end record to select an entire range of records. You can only select a range of records, you cannot use Ctrl-Click to select non adjacent records.

Once you have select the record or records you want, you can copy them to the clipboard with Ctrl-C or selecting Copy from the Edit menu. You can also Cut them which copies them to the clipboard but also deletes them from the database. Once records have been copied to the clipboard, you can use the Paste command in the Edit menu or Ctrl-V to add them back to the database. Copying a record and then pasting it multiple times is a good way to duplicate a record if you have several records that are very similar.

Pasting from other applications

A very powerful way to add data to your database is to copy and paste it from another application like Excel. Many people already have put information into their own spreadsheets or databases and can use the Paste Special command in the Edit menu to import it into zMUD.

The Paste Special imports data stored in the clipboard (from a Copy or Paste operation). The Import command imports data from a file on your local disk. However, both of these commands operate the same way.

When you use Paste Special or Import, you will first get a window that asks for information on how the data is delimited. zMUD automatically tries to figure out if the data is tab delimited, or comma delimited, or delimited by another character, or whether it is in fixed width fields. The display along the bottom of the window shows the data being imported and how it is split into columns. If zMUD guessed wrong about the delimiter, change it on this screen until the data looks like it is in the proper columns. Also, if the first line of the data contains the names or headers of the columns, click the Use First Row as Headings option.

Once you have the columns set up correctly, click the Next button and you will be asked to assign each column of data to a specific database Field value. If the Name or Header of a column matches a current database Field name, the assignment will be made automatically and shown in the list of columns on the left. Otherwise the column is marked as -ignored- which means the column will be ignored. To assign a column to a field value, click the column in the list on the left, or click it in the data display along the bottom. Then select the Field you want to assign it to in the Field Selection box. Do this for each column you wish to import.

Fields that have a type of Single Option or Option List have an additional feature. A common practice for multi-value fields is to create several columns in a spreadsheet, one column per possible value, and then put an X or other letter into the column if it has that value. For example, you might be listing which character classes are allowed to use a specific weapon. Your spreadsheet could have columns for Warrior, Mage, Cleric, Thief, etc and you would put an X in the column if that class is allowed to use the weapon. In the zMUD database, you can collapse all of those columns into a single field. In the above example, you might have an Option List field called AllowedClass that has the possible values Warrior, Mage, Cleric, Thief. When you select the Warrior column in your imported data, you would assign it to the AllowedClass field, and then further assign it to the Warrior value in the value selection box that appears below the field selection box. Then you'd assign the Mage column to the AllowedClass field with the Mage value, and so on. Now, when zMUD imports the data, any value in one of those columns (like an X) causes the assigned value to be added to the Option List field. So, in the above example, if there was an X in the Warrior column and an X in the Cleric column, the imported record would then end up with an AllowedClass field with a value of "Warrior,Cleric".

In some case you might end up with a very complex assignment of columns to fields. You can save the Paste Special setup to a file so that you can use it again later if you paste from the same source. Simply click the Save button to save your import settings to a file. To load previously saved settings, click the Load button. This makes it very simple to import lots of data from your existing spreadsheets or databases.

Setting Field Values

You can also set the value of a field for multiple records using the Set Field command in the Actions menu. You will be prompted to select the Field you wish to change, and then enter a value for that field. Using the @ button you can enter a zMUD expression that will be evaluated if you wish. If no records are selected, then the current record is modified, otherwise all selected records are modified. To change all records in the database, go to the All view and do a Select All in the Edit menu to select all of the records.

Adding data from the MUD

Because the zMUD database can be controlled from the zMUD scripting language, you can set up triggers and aliases to automatically capture the result of an "identify" spell on the MUD and create a new record with this data. For information on how to do this, see the help section on Scripting the Database.



Contents Database Views Quick Filters