: : : : I have to make a complicated program for school and i decided to
: : : : make a recipe book.And i need to know how i should start making it
: : : : since i dont have a clue ^_^' lol
: : : :
: : : :
: : : : Any help would be much appreciated
: : : :
: : : How much Pascal do you know at this point? The simplest method
: : : would be to have a separate file for each recipe, another file for
: : : a table of contents. The program would display the table of
: : : contents and prompt the user for which recipe he/she wants, get
: : : input and then display the appropriate recipe file. That assumes
: : : you know how the program files (Assign, ReSet, Close, ReadLn,
: : : WriteLn).
: : :
: : : The again, maybe you want something more than just a file display?
: : :
: : :
: :
: : Yes i know about assign,reset,close and the like what you described
: : is just what i want to do.But i would want to know how to make an
: : unlimited space to store recipes,thats what i really dont know at
: : this point of the project.
: :
: When I write a program the first thing I do is look at the data and
: see if I can simplify it. A recipe would have (1)the name of the
: dish being prepared, (2)a list of ingredients, (3)instructions for
: mixing and cooking, and (4)an index number. All this can get pretty
: complicated for the programmer, particularly if you decide to
: subdivide something like an ingredient into (a)name, (b)quantity,
: and (c)unit of measurement. For your project, I suggest you bypass
: all this complexity (at least for your first draft) by putting each
: recipe in a page of text. This simplifies things considerably
: because, as far as your program is concerned, each recipe is simply
: a text file and the program has no knowledge, or need to know,
: what’s inside the file.
:
: Thus if your recipe book has 12 recipes then your database has
: twelve text files which could be named 1.RCP, 2.RCP, 3.RCP, ..
: 12.RCP.
:
: I’m envisioning your program as starting by clearing the screen and
: listing a table of contents, listing all the recipes in the
: database. For example, the first four columns on a line would list
: the index number of the recipe, the next two columns would be blank,
: and the next 40 columns would be the name of the dish. E.g.
:
:
:
: 1 Irish stew
: 2 Spaghetti and meatballs
: 3 Haggis
: 4 Beef and barley soup
: 5 etc
:
:
:
: Where this information comes from is the next problem. For your
: first draft, I suggest this data be kept in another text file,
: TABLE.RCP. Thus, in pseudo code, the procedure for displaying the
: table of contents is
:
:
:
: clear the screen
: open file TABLE.RCP for reading
: while not end-of-file
: read a line from the file
: write that line to the screen
: close file
:
:
:
: The program now prompts the operator for an index number so it knows
: which recipe (file) to display on the screen. The operator scans
: the screen, makes his selection, enters it on the keyboard, and hits
: ENTER. Again, for a first draft, we will not get involved with
: error checking at this point and assume he enters something valid.
:
: The last task for the program is to write out the recipe on the
: screen. This is identical to the procedure for displaying the table
: of contents except that we open Index.RCP instead of TABLE.RCP,
: Index being a variable entered by the operator.
:
: For the sake of modularity, I would write the main part of the
: program as calling three routines:
:
:
: begin
: ShowTable ;
: Index := GetIndex ;
: ShowRecipe (Index)
: end.
:
:
:
: The above would get a simple program up and running, but there are
: several issues with it. First, all the data entry, including the
: table of contents needs to be entered using a text editor. Data
: cannot be entered from the program itself. Data entry from the
: program could be added but it’s really a tall order. It would mean
: adding an editor to the program, and that could mean that up to 90%
: of the code would be a text editor. One way around that that I have
: used in the past, kind or a cheat really, is to use Turbo Pascal’s
: Exec procedure to invoke an existing text editor.
:
: Another issue is that I’ve assumed that both the table of contents
: and any individual recipe will fit on one screen and not scroll off
: the screen. If either is bigger then you need to include something
: that will display the data one screen at a time.
:
: Using a text editor to build TABLE.RCP means it’s up to the user to
: be sure that the table of contents agrees with what is actually
: available. If the data in TABLE.RCP is wrong then the operator
: might select 7 for pumpkin pie and get a recipe for chocolate cake.
: This is something that I would address early in the project. One
: possibility is to have the program search for all files ending in
: .RPC and list the first line (the name of the dish) of each. The
: person entering the data need only create the file with the recipe
: and it would automatically appear in the table of contents. This is
: an example of “let the machine do the dirty work.”
:
: The total number of recipes would be limited only by how many files
: your hard drive can hold, which is probably more than you would ever
: need. This approach emphasizes simplicity over speed, memory
: conservation and disk space.
:
:
:
Wow,you were a great help! thanks a lot