Separate speaker notes to accompany the PowerPoint presentation on arrays called arrayct:

 

Slide #1:

In this logic I am going to set up an array that will be added to as data is processed.  The data could be inputted by the user or read from a file.  As the data is processed, it is added to the array.

Slide #2:

This shows the array I would set up.  I am calling each element in the array by the name driveDonation.  Therefore the first element in the array is driveDonation(1) and the second element in the array is driveDonation(2).

Slide #3:

I am now starting an example where the user inputs a drive number (driveIn) and a donation (amtDonation).  I use the driveIn to add the amtDonation to the appropriate element in the array.

Remember, is set up this array to hold totals.

In this example the driveIn is 2 and the amtDonation is 100 so I add 100 to the second element in the array: driveDonation(driveIn).

Slide #4:

In this example, I am adding 350 to the fourth element in the array driveDonation(driveIn) where driveIn is a 4.

Slide #5:

In this example, I am adding 50 to the first element in the array driveDonation(driveIn) where driveIn is a 1.

Slide #6:

In this example, I am adding 500 to the second element in the array driveDonation(driveIn) where driveIn is a 2. Note that the second element in the array already had 100, so now it is 600.

Slide #7:

In this example, I am adding 250 to the sixth element in the array driveDonation(driveIn) where driveIn is a 6.

Slide #8:

In this example, I am adding 1000 to the second element in the array driveDonation(driveIn) where driveIn is a 2. The second element has been added to twice and it now contains 600 (100 + 500).  When I add the 1000, it will bring the second element in the array up to 1600.

Slide #9:

In this example, I am adding 1000 to the fifth element in the array driveDonation(driveIn) where driveIn is a 5.

Slide #10:

In this example, I am adding 2000 to the second element in the array driveDonation(driveIn) where driveIn is a 2. The second element is 1600 before the current add (I had already added 100 + 500 + 1000).  Adding the 2000 brings it up to 3600.

Slide #11:

Now I am at the end of processing and I want to print out the totals.  I take the totals from the array.  Note that I have a choice of simply writing out each one or doing a loop where I will move through the array increment a pointer as I take the elements.

Slide #12:

This is the beginning of the logic flowchart to show the logic involved in gathering the totals in the array and then displaying the totals.  Note that I also display the data as I go along in the processing.  The loop that actually does the processing of individual records is shown on the next slide.

Slide #13:

Here I add the input data to the appropriate element in the array using dept input as the subscript/index/pointer.

Note that different languages and different programmers will refer to the thing that specifies which element of the array we are using in different ways.

After adding to the element, I display the data that I have just processed and move on to get more data either by user input or by reading a record from a file.

When processing is complete I write out the totals from the array.

Slide #14:

I wrote a program in COBOL to illustrate.  This shows the processing of user input to take in the user id, the user name, the drive no and the amount of the contribution.

Slide #15:

This is a continuation of the execution of the COBOL program. Note the data entry and the output on the screen.

Slide #16:

I did more processing that does not show, but the final thing that is processed for the screen is the display of the totals from the array.

Slide #17:

This shows the definition of the data for input and the screen. It also shows the setup of the array which is going to have 6 elements that can each hold 6 whole numbers and 2 decimal numbers.  The OCCURS clause in COBOL establishes the array.

Slide #18:

This shows the processing paragraph and the looping paragraph where the data is processed.  Note the use of the array and its elements.

Slide #19:

This is the wrapup or terminate routine where I am displaying the totals from the array.

Another version of the code for both housekeeping and terminate is shown on the next slides.

Slide #20:

This is alternative code that makes better use of the subscript/index/pointer.  Now when I want to initialize the areas in memory to 0, I use a loop that goes through the elements one at a time and sets the element to 0.  The pointer/subscript/index I am using in this example has been defined as SUBZ.

Slide #21:

I did not change anything in the processing or the loop.

Slide #22:

In the terminate routine, I have now set up a loop to go through the elements in the array and display each one using SUBZ as my pointer/index/subscript.

Slide #23:

Now I am going to show a program running in Visual Basic 6.0 that does essentially the same processing. 

These are the first two entries.

Slide #24:

This shows two additional entries.  Both are for drive 2.

Slide #25:

Now I have entered another for drive 5 and one for drive 4.

Slide #26:

This shows one more entry for drive 2 and then the display of the totals after Show Totals is clicked.

Note that there was no entry for 3 or 6 so they show up as 0. Drive 2 had 3 entries for 200 + 2000 + 5000 and drive 5 had two entries for 500 + 5000.  Drive 1 had 1 entry for 100 and Drive 4 had 1 entry for 400.

Slide #27:

This shows the form that was created, note that a lot of setting were done in the properties.  The next slide will show the code.  I am only going to discuss a few things because what I did really goes beyond the scope of this course.

Slide #28:

This shows the code that was used.  If you understand VB you should take a look at it.  Otherwise, I will highlight some of the code on the next few slides.

Slide #29:

This shows the Visual Basic code that I used.  I tried to keep it fairly simple and straightforward, but I still do not think it will all be totally clear.

Slide #30:

Note that when I set up the array on the form it started with 0.  I could have had the internal 1 start with 0 as well but I decided to leave that matching the drive input.

Continue on next slide.

Slide #31:

Concatenate means to put two things together as one.  In msg I am putting four separate entities together as one.