Pascal

Moderators: None (Apply to moderate this forum)
Number of threads: 4106
Number of posts: 14016

This Forum Only
Post New Thread
Single Post View       Linear View       Threaded View      f

Report
Making a recipe book using pascal Posted by momomoko on 2 Nov 2008 at 1:36 PM
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
Report
Re: Making a recipe book using pascal Posted by Actor on 2 Nov 2008 at 6:54 PM
: 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?

Report
Re: Making a recipe book using pascal Posted by psychofox19 on 3 Nov 2008 at 1:47 AM
: : 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?
:
:

I assume he also needs to use a data structure such as a Linked List Record for this.

Report
Re: Making a recipe book using pascal Posted by Actor on 3 Nov 2008 at 11:38 AM
:
: I assume he also needs to use a data structure such as a Linked List
: Record for this.
:
:


Why do you assume that? There's nothing in the problem (as stated) that demands it, so the only reason for using a linked list would be if his teacher specifically required it.


Report
Re: Making a recipe book using pascal Posted by momomoko on 3 Nov 2008 at 3:48 PM
: : 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.
Report
Re: Making a recipe book using pascal Posted by Actor on 5 Nov 2008 at 3:14 PM
: : : 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.


Report
Re: Making a recipe book using pascal Posted by momomoko on 7 Nov 2008 at 6:03 PM
: : : : 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
Report
Re: Making a recipe book using pascal Posted by chefknivesset on 3 Dec 2009 at 4:25 AM
well. I know least about the topic discussed here. But I will definitely post to you if get any related information.

Thanks.
Report
Re: Making a recipe book using pascal Posted by vanniecons25 on 26 Dec 2009 at 4:35 AM
oh,this is interesting..would this be possible? LOL,..sounds good! may succeed with this one..

Dough Sheeters



 

Recent Jobs

Official Programmer's Heaven Blogs
Web Hosting | Browser and Social Games | Gadgets

Popular resources on Programmersheaven.com
Assembly | Basic | C | C# | C++ | Delphi | Flash | Java | JavaScript | Pascal | Perl | PHP | Python | Ruby | Visual Basic
© Copyright 2011 Programmersheaven.com - All rights reserved.
Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
Operated by CommunityHeaven, a BootstrapLabs company.