Simple Standalone Contact Database Sofware. Because there are no predefined fields, this program can be used as an organizer database for contacts and a database. Creating a Simple Web Application Using a MySQL Database. Free simple database program? Discussion in 'Freeware' started by Chaos Master, Jun 5. Simple database software social advice. The simple and straightforward. Obvibase makes creating an online database as easy and fast as creating a spreadsheet. Clean and simple design. Checkboxes, multiple choice dropdowns. Create secure and sharable online database using Zoho Creator online database software. Data collection made simple. Your online database is a centralized. Practical: A Simple Database. Copyright . But let's face it- -you may be. Why. should you be expected to bother learning all the details of a. In this chapter you'll write a simple database for. CDs. You'll use similar techniques in Chapter 2. MP3s for our streaming MP3 server. In. fact, you could think of this as part of the MP3 software. MP3s to listen to, it. CDs you have and. In this chapter, I'll cover just enough Lisp as we go along for you. But I'll gloss over quite a few. For now you needn't sweat the small stuff- -the next several. Common Lisp constructs used here, and. One terminology note: I'll discuss a handful of Lisp operators in. In Chapter 4, you'll learn that Common Lisp provides. For the purposes of this chapter, you don't. I will, however, refer to. For now you can treat function, macro, and. Also, keep in mind that I won't bust out all the most sophisticated. Common Lisp techniques for your very first post- . The point of this chapter isn't that this is how you would. Lisp; rather, the point is for you to get an idea. Lisp is like and to see how even a relatively. Lisp program can be quite featureful. Simple database access sample application. Example of a simple HTML page. HTML uses hundreds of different tags to define a layout for web pages. Below is an example of a very simple page. How to Select the Best Database Software: Know Your Database Software Types. Here's the various database types: Desktop: A simple. To keep track of CDs that need to be ripped to MP3s and which CDs. CD, a rating of how much the user likes it. So, to start with. CD). Common Lisp gives you lots of choices of data. Common Lisp Object System (CLOS). For now you can stay at the simple end of the spectrum and use a. You can make a list with the LIST function, which. CL- USER> (list 1 2 3). You could use a four- item list, mapping a given position in the list. However, another flavor of. A plist is a list where every other element. I won't get into all the details of exactly. For the symbols. that name the fields in the CD database, you can use a particular. A keyword is any name. Lisp has real hash. CL- USER> (getf (list : a 1 : b 2 : c 3) : a). CL- USER> (getf (list : a 1 : b 2 : c 3) : c). Given all that, you can easily enough write a function make- cd. CD.(defun make- cd (title artist rating ripped). The word DEFUN tells us that this form is defining a new. The name of the function is make- cd. After the name. comes the parameter list. This function has four parameters. In. this case the body is just one form, a call to LIST. When. make- cd is called, the arguments passed to the call will be. For instance, to make a. CD Roses by Kathy Mattea, you might call. CL- USER> (make- cd . You need some. larger construct to hold the records. Again, for simplicity's sake, a. Also for simplicity you can use a. DEFVAR macro. The asterisks (*) in the name are a Lisp naming. You can use the PUSH macro to add items to *db*. But it's. probably a good idea to abstract things a tiny bit, so you should. Now you can use add- record and make- cd together to add. CDs to the database. CL- USER> (add- record (make- cd . And PUSH returns the new. So what you're actually seeing. You can also see the current value of *db* whenever you want. REPL. CL- USER> *db*. TITLE . For each value of cd, you use the. FORMAT function to print it. Admittedly, the FORMAT call is a little cryptic. However. FORMAT isn't particularly more complicated than C or Perl's. Python's string- % operator. In. Chapter 1. 8 I'll discuss FORMAT in greater detail. For now we can. take this call bit by bit. As you saw in Chapter 2, FORMAT takes. The second argument to FORMAT is a format string that can. FORMAT things. such as how to interpolate the rest of its arguments. Format. directives start with ~ (much the way printf's. FORMAT understands dozens of. However, for now I'll just focus on the ones you need to write. The ~a directive is the aesthetic directive; it means to. This. will render keywords without the leading : and strings without. For instance: CL- USER> (format t . The ~1. 0t tells. FORMAT to emit enough spaces to move to the tenth column before. A ~t doesn't consume any. CL- USER> (format t . In dump- db, the. FORMAT loop will consume one keyword and one value from the list. The ~% directive doesn't consume. FORMAT to emit a newline. Technically, you could have also used FORMAT to loop over the. While our add- record function works fine for adding records. Lispy for the casual user. And if they want to add a bunch. So you may want to write a. CDs. Right. away you know you'll need some way to prompt the user for a piece of. So let's write that.(defun prompt- read (prompt). Note that. there's no ~% in the format string, so the cursor will stay on. The call to FORCE- OUTPUT is necessary in some. Lisp doesn't wait for a newline before. Then you can read a single line of text with the aptly named. READ- LINE function. The variable *query- io* is a global. The return value of prompt- read. READ- LINE, which. You can combine your existing make- cd function with. CD record. from data it gets by prompting for each value in turn. Except prompt- read returns a string. Title and Artist fields, isn't so great for. Rating and Ripped fields, which should be a number and a boolean. For now. let's lean toward the quick and dirty: you can wrap the. Lisp's. PARSE- INTEGER function, like this: (parse- integer (prompt- read . However, it takes an. In keeping with the quick- and- dirty approach, you may just. Lisp's OR macro is just the. So you can use the following: (or (parse- integer (prompt- read . You can. just use the Common Lisp function Y- OR- N- P.(y- or- n- p . You can use the simple form of the LOOP macro, which. RETURN. For example: (defun add- cds (). But. it's not so nice that the user is going to be very happy if they have. Lisp. It. also makes sure the file is closed even if something goes wrong while. The list directly after WITH- OPEN- FILE. WITH- OPEN- FILE. It contains the name of the variable that will. WITH- OPEN- FILE, a value that must be a file name, and then some. Here you specify that. Once you have the file open, all you have to do is print the contents. Unlike FORMAT. PRINT prints Lisp objects in a form that can be read back in by. Lisp reader. The macro WITH- STANDARD- IO- SYNTAX ensures that. PRINT are set to. You'll use the same macro when you read the. Lisp reader and printer are operating. The argument to save- db should be a string containing the name. The exact form. of the string will depend on what operating system they're using. For. instance, on a Unix box they should be able to call save- db. CL- USER> (save- db . This is the same reader used by the REPL and. Lisp expression you could type at the REPL prompt. Again, the WITH- STANDARD- IO- SYNTAX macro. READ is using the same basic syntax that. PRINTed the data. The SETF macro is Common Lisp's main assignment operator. It. sets its first argument to the result of evaluating its second. So in load- db the *db* variable will contain. You do need to be careful about one. So if you've added records with add- record or. Now that you have a way to save and reload the database to go along. What you need is a way to. You might like, for instance, to be able to write. Again, it turns out that the choice of saving the records in. The function REMOVE- IF- NOT takes a predicate and a list and. In other words, it has removed all the elements. However, REMOVE- IF- NOT doesn't. It's like running grep over a file. The predicate. argument can be any function that accepts a single argument and. NIL for false and anything else for. For instance, if you wanted to extract all the even elements from a. REMOVE- IF- NOT as follows: CL- USER> (remove- if- not #'evenp '(1 2 3 4 5 6 7 8 9 1. In this case, the predicate is the function EVENP, which returns. The funny notation #'. For. instance, if EVENP didn't exist, you could write the previous. CL- USER> (remove- if- not #'(lambda (x) (= 0 (mod x 2))) '(1 2 3 4 5 6 7 8 9 1. In this case, the predicate is this anonymous function: (lambda (x) (= 0 (mod x 2)))which checks that its argument is equal to 0 modulus 2 (in other. If you wanted to extract only the odd numbers using. CL- USER> (remove- if- not #'(lambda (x) (= 1 (mod x 2))) '(1 2 3 4 5 6 7 8 9 1. Note that lambda isn't the name of the function- -it's the. Other than the lack of a name, however, a LAMBDA. DEFUN: the word lambda is. To select all the Dixie Chicks' albums in the database using. REMOVE- IF- NOT, you need a function that returns true when the. Remember that we. GETF can extract named fields from a plist. So assuming. cd is the name of a variable holding a single database record. The function EQUAL, when given string. So (equal. (getf cd : artist) . All you need to do. LAMBDA form to make an anonymous. REMOVE- IF- NOT. CL- USER> (remove- if- not. You can write that like. Note how the anonymous function, which contains code that won't run. REMOVE- IF- NOT, can nonetheless refer to. In this case the anonymous function. So that's select- by- artist. However, selecting by artist is. You. could write several more functions, such as. But they'd all be about. You can. instead make a more general select function that takes a. So what happened to the #'? Well, in this case you don't want. REMOVE- IF- NOT to use the function named selector- fn. You. want it to use the anonymous function that was passed as an argument. Though, the. #' comes back in the call to select. CL- USER> (select #'(lambda (cd) (equal (getf cd : artist) . Luckily, you can wrap up the. So now. you can rewrite the call to select like this: CL- USER> (select (artist- selector . But just. as you don't want to have to write select- by- title. Why not. write one general- purpose selector- function generator, a function. You can write such a function, but first you need a crash. In the functions you've written so far, you've specified a simple. For instance, the following function: (defun foo (a b c) (list a b c))has three parameters, a, b, and c, and must be. But sometimes you may want to write a. A version of. foo that uses keyword parameters might look like this: (defun foo (& key a b c) (list a b c))The only difference is the & key at the beginning of the. However, the calls to this new foo will look. These are all legal calls with the result to the.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. Archives
December 2016
Categories |