• Baja Class 100.2

    From Finnigann@VERT/BNB to Pistolgrip on Tue Oct 23 06:09:00 2001
    So with all these varibles etc. How do you determine what's doing what?
    File names and so forth?

    Is the algorithm part? Pencil and Paper part... This one of the first
    steps and where I bog down.

    Determining where to start, or what must happen first, second,
    third...etc

    I guess after it is determined what you must do to get from the first
    step to the last step, then you can figure out what files and names to
    use.

    Is this something that can be taught?

    I imagine an experienced programmer has basic steps that they use in
    whatever program they are writing. And steps they include when... say
    they open a file they might check to see if one exists first (just
    guessingh here). They might also include error trapping routines so
    that when the inevitble errors do crop up, they will at least leave a
    trace.

    Alright lets design something simple; open, read, and depending on what
    is in the opened file, write a NEW file. Be it a score file or a record
    of events, doesn't matter, the steps taken in the order they are taken
    will show alot on how to solve a problem and deal with it.


    Although this is addressed to Pistolgrip, let anyone jump in at any
    time.


    ... Heisenberg may have slept here.
    --- MultiMail/MS-DOS v0.40
    þ Synchronet þ Bits-N-Bytes BBS - One Hellova BBS -- telnet://bnb.dtdns.net
  • From Amcleod@VERT to Finnigann on Tue Oct 23 07:17:00 2001
    RE: Baja Class 100.2
    BY: Finnigann to Pistolgrip on Tue Oct 23 2001 05:09 pm

    Is the algorithm part? Pencil and Paper part... This one of the first
    steps and where I bog down.

    Determining where to start, or what must happen first, second,
    third...etc

    I guess after it is determined what you must do to get from the first
    step to the last step, then you can figure out what files and names to
    use.

    This is all part of the program-design, which can be done entirely by non-programers if needed. There are many different techniques, and their merits are the subject of near-religeous argument.

    One very common method of designing your program is FLOWCHARTING. Yes, flowcharts are completely passe these days -- back in 1975 I was taught not to use it. But for the beginner, it can be a very simple method of visualizing the program algorythm. I personally like to use an informal data-flow diagram technique wherein I graphically depict where the data comes from, where it is stored, where it goes to, and how it is manipulated along the way. In actual fact, when you have experience, you automatically select the design method that your experience tells you most suited to the current problem-at-hand.

    Is this something that can be taught?

    There are classes and text-books available on the subject of system design. Any introductory work on programming will attempt to give you the gist.

    I imagine an experienced programmer has basic steps that they use in whatever program they are writing. And steps they include when... say
    they open a file they might check to see if one exists first

    Sure. Again, experience will tell you what fragments work best. Let's say you are opening a file. You could do

    hnd = fopen( "filename.text", "r" );

    but suppose the file didn't open for whatever reason? So maybe you just make
    a habit of doing

    if (!(hnd=fopen(""filename.text","r"))) {
    puts(strerror(errno));
    exit(1);
    }

    every time instead. Each programmer will develop his own style.

    Alright lets design something simple; open, read, and depending on what
    is in the opened file, write a NEW file.

    Okay, let me set YOU an exercise. To develop a BAJA program to do the following:

    1) Open a disk file called INPUT.DAT for reading, halt with an error
    message if the file is not found or for some reason won't open.
    2) Open a disk file called OUTPUT.DAT for writing, creating the file
    if it doesn't exist, truncate it if it does exist. If it can't be
    opened/created, a) close the input file opened in step 1, b) print
    an error message, c) halt.
    3) Read one line at a time from the input file, for processing.
    4) Process each line as follows:
    4a) If the line is a comment (starts with "#") ignore it.
    4b) If it is NOT a comment, convert it to UPPER CASE
    5) Write each line to the output file.
    6) When all input data has been processed, close input & output files.

    There you go. A simple program, broken down into six simple parts. Work on each part and show us what you come up with. Obvious place to start is with the BAJA documentation and the command for opening a file. You are talking both INput and OUTput files. This will cover steps 1 and 2. While doing this you may as well check out how to CLOSE files, possibly needed in step 2 and definately in step 6.

    Get going!

    :)

    ---
    þ Synchronet þ Vertrauen þ Home of Synchronet þ [vert/cvs/bbs].synchro.net
  • From Finnigann@VERT/BNB to Amcleod on Tue Oct 23 10:42:00 2001
    Amcleod wrote to Finnigann <=-



    Get going!

    Oy vey! Homework... ok



    :)

    Would an apple here be out of place?

    ---
    þ Synchronet þ Vertrauen þ Home of Synchronet þ
    telnet://vert.synchro.net

    ... "Cha-CHING!!! YES! YES! YES!" {EG}
    --- MultiMail/MS-DOS v0.40
    þ Synchronet þ Bits-N-Bytes BBS - One Hellova BBS -- telnet://bnb.dtdns.net