OOo Basic crash course: Creating a simple game using strings in a database

Posted by suvi under OpenOffice.org, Programming

Just because OpenOffice.org Basic is designed to automate mundane tasks doesn’t mean that you must use it only for serious work. It’s a programming language after all, and nothing stops you from using it to write something fun. Today we’ll use it write a simple game where you have to guess a word, a letter at a time, from among words you’ve stored in a Base database. Although this is not a particularly sophisticated game, it contains a couple of string manipulation techniques and a clever trick for picking a random record from a database, which you might find useful when writing your own macros.

Before you start coding the game, you have to create a simple Base database (let’s call it “WordDB”) with a table called “wordlist” containing two fields: the “ID” integer field that acts as a primary key, and the “Word” text field used for storing words. Populate the database with the words you want to use in the game.

Read more at Linux.com

Leave a Reply

*
To prove you're a person (not a spam script), type the security word shown in the picture. Click on the picture to hear an audio file of the word.
Click to hear an audio file of the anti-spam word