Welcome to the JPM Fair Fund Website

Zoomlux Lighting LLC. HKTDC Hong Kong International Lighting Fair Survey Autumn LED Lighting Up. Under the long shadow cast by the China-US trade friction.

Any program that we write is referred to as source code. Thus, I visit this page and learn it. The first statement input-last-name:

Navigation menu

Working with Fair Trade makes your business a partner in empowering individuals, building strong communities, Fair Trade for Business.

The Controls section briefly introduces the three dimensions of a controls landscape. Measuring Risk briefly discusses measurement concepts and challenges, and then provides a high-level discussion of risk factor measurements. FAIR underlines that risk is an uncertain event and one should not focus on what is possible, but on how probable is a given event. This probabilistic approach is applied to every factor that is analysed. The risk is the probability of a loss tied to an asset.

That same information also can introduce liability to the organization if a legal duty exists to protect it, or if customers have an expectation that the information about them will be appropriately protected. FAIR defines six kind of loss: Threat agents can be grouped by Threat Communities, subsets of the overall threat agent population that share key characteristics.

Threat communities must be precisely defined in order to effectively evaluate effect loss magnitude. Threat agents can act differently on an asset: These actions can affect different assets in different ways: Some assets have high criticality but low sensitivity: On the other hand, an asset with highly sensitive data can have a low productivity effect if not available, but embarrassment and legal effect if that data is disclosed: The combination of an asset's characteristics and the type of action against that asset that determines the fundamental nature and degree of loss.

From Wikipedia, the free encyclopedia. Redirected from Factor Analysis of Information Risk. Archived from the original on Retrieved from " https: Views Read Edit View history. In our case though this will become a line of our program. Note that there will be rules to follow for each line and so far there has been a hint of some of these constraints.

We shall get into more specifics later. Taking a group of valid lines of code and assuming some rules are followed, the result will be a section or paragraph of our program, just as we had for the English language. With more rules being met, a certain group of paragraphs or sections put together will result in a computer program, which parallels our chapter in English. Finally putting a group of programs together with further considerations will result in a user application.

This is very similar to our novel or work of non-fiction in English. We could proceed further by grouping a few applications together to give us a computer system. This we saw as our library in English. Our concern in this work is programming so we will concentrate on that aspect and only mention applications and systems on occasion.

You can see that P language and all it encompasses is very similar to what is involved with English. There are many similarities. File makeup Before proceeding with a simple computer program, let us look at how data is organized. All information is stored in files or databases, which strictly speaking are one and the same. A file consists of various elements or records. Thus a personnel file will have records that match individuals.

Each record consists of fields or variables. Our personnel file might have records that include some identification number such as a social security number or the like, name, address, city, state, zip code, telephone and date of birth. There may be other fields as well. Each field is a variable, which has a value, and each individual field has some kind of limit. The identification number might be limited to nine numeric digits and nothing else. It cannot be all zeros or all nines and there could be further restrictions.

The name will be limited to letters of the alphabet — upper and lower case — the period, apostrophe and hyphen. Other fields will have different restrictions. Zip code can be one of a few formats, such as five digits, nine digits or alternating digits and letters to accommodate our neighbors north of the border.

Dates have to be in a specific format, mostly all numeric but all spaces could also be acceptable, as could an entry of all zeroes. This would accommodate a date to be entered later. Our language will require all dates to be in yyyymmdd format, that is, four digits for the year and two each for the month and day. Later we will develop a date check to handle this. Other fields will have restrictions as well. The state has to be a valid twocharacter combination, which represents one of the fifty states.

City can be no more than fifteen characters and these can only be letters of the alphabet, the hyphen, the period and a space. Amount fields will always be numeric and some can be negative, such as a bank balance. Thus some amount fields need to be able to be positive or negative. This is handled by including a sign in the field. Amount fields have decimals in them, such as current balance, so that will must be taken care of as well.

Having delved into the structure of a file, you can probably see that the makeup is not unlike the book we talked about in the English language.

Each has basic elements that make up words or fields. These pieces in turn then get grouped together to form sentences or records. English then combines the sentences to get a book while the combination of our data records makes a file. In each case there are rules that need to be followed. If we fail to follow the rules for either, there will be problems.

For now it will consist of just a few fields, account number, last name, first name, middle initial, street address, city, state, zip code and balance. In some cases, the computer will generate an account number — and even let the customer know what it is. In our system, the account number will be a nine-digit field greater than nine. Both the first and last names must consist of letters of the alphabet, the space, apostrophe, period and hyphen only.

John and Olivia Newton-John. The first name is limited to fifteen characters while the last name is restricted to eighteen. That should be enough characters. The middle initial must be A through Z, but it can also be left blank. The street address is limited to twenty-five characters and has the same restrictions as the name, except numbers are also allowed as well as the comma.

City must be no more than fifteen characters and these must consist only of letters of the alphabet, the period, space and hyphen. The state must be exactly two characters and it must be the valid abbreviation for one of the fifty. The zip code must be a five digit numeric field.

The balance will be a signed numeric field having eight digits, six to the left of the decimal point and two to the right. In fact this bank may even be more restrictive and caring about the customer — that could happen — as large balances might result in letters being sent out notifying customers that they may want to consider a certificate of deposit or the idea of buying stock.

Our file is the account file and if I want to read it in a program, I will specify the variable acctfile that represents a file which the program can read. How this is done will be shown when we get to the program. For now we need to worry about the fields that make up the file. We have to spell out the names of the fields, their sizes, where they are in the record and what type each field is. That scenario will make it impossible to process the file.

In our account number file, the account number will start in position 1 of the record and end in position 9, last name will start in position 10 and end in position 27, first name will begin in position 28 and end in position 42 and so forth until we get to balance, which ends in position This will be the case for each record on the file and it means we can find the data we want where it should be. We could have put commas as separators between the fields and accomplished the same result but what happens when one of the fields has a comma in it?

That could mess us up so our method will be better. We start by defining a file and its structure. The 8 account number file consists of nine fields. We must then thoroughly describe each field. This gives us some keywords. The first is define and the others are structure, integer, decimal, signed and character.

The actual program code to describe the account file record and its makeup is as follows: Let us begin with the first line, define file acctfile record account-record structure. The keyword define spells out to the program the name of the file — indicated by what follows the keyword file and what fields make up each record.

The field account-record is a variable, as are the nine fields in the record that follow. The record is related to these fields by the keyword structure which says that the variable account-record consists of nine fields. The end of the record is indicated by the next occurrence of the keyword define, or some keyword, such as read. Because of the way the structure is defined, this means that the field account-number starts in the very first position of the record.

The keyword integer 9 spells out that the field is a number consisting of 9 digits. As you may have guessed integer is another keyword. Any number that is an integer is a whole number, which can be 0. The next line, last-name character 18 is quite similar except this field is not numeric but rather consists of letters of the alphabet. Seinfeld fans, that show is fantasy. Note that this field contains 18 characters maximum. The variable first-name is similar to last-name except that it only has 15 characters.

The next four fields mirror the others above them, as they are either character or integer. Note that both variables account-number 10 and zip-code could have been defined using the keyword character rather than integer since each number is included in the character set.

The last line balance signed decimal 6. Since the account balance could be negative at times and it does involve cents as well as dollars, we need to spell that out. The variable signed allows for negative as well as positive numbers, while decimal 6. It knows exactly where the decimal point is even though it is not on the file. This will enable us to read a file and access specific fields in each record.

The keyword structure merely says we have a piece of a file, namely a record, and this record itself consists of different things. These are nothing more than the fields that make up the record. We can access the entire record or individual elements of it. A report program You can do a great deal with a computer program but in general all programs do the same thing.

They read data and produce output, either another file or a listing on paper or on a screen. In the process, sometimes files are updated. The data may be obtained from the system somehow, from screen input or from another file.

Despite this simple breakdown, the process could get quite complicated. A program could involve reading a dozen files to get different kinds of data and then produce a few files. A data entry program might involve a screen to allow input, which could be quite complicated.

It really depends on the system and what kind of computer you have. Fortunately our system will not be complex and so you may be a little upset to see more complexity when you get to a different system. Here are a few examples to illustrate this fact. It is discovered that someone messed up the account file for all the begin dates. Instead of or for the year, each record has or for this value. Someone writes a program to correct this situation.

The input to this program is the account file and the result will be either a new one or an updated account file. This all depends on what type of file it is. In either case the two files will be different, with the new one having the correct begin dates. Thus the program will read a file and create an output file. There could be another output file, namely a report to list the records that were changed. The account file needs to be updated with new accounts from time to time so there is a program to allow input into the file.

Once again we have an input file in the data being keyed and probably two output files, the updated account file as well as some kind of report. Even though the report file is not completely necessary, it is probably a very good idea to show the addition of the new accounts. Our first program will read the account number file and produce a listing of the fields on it.

Specifically, we will read a file and produce output in the form of a report, but just one record will be listed. As you could guess program-name is a keyword that we use to indicate the name of our program.

We will be writing many programs so we need to distinguish one from another. We do this with that keyword. The name we choose here for our program is a variable, acctprint. Note that we choose this name because we are listing account information.

The next few lines should be familiar as they describe the account record and all the fields that make it up. Through the structure keyword we can reference any of our nine fields in the record. We need to do this in order to print them on a report.

Note that the end of the structure will be determined by the keyword read. We then have two more keywords, read and into in the line read acctfile into account-record. The variable following read is our account file which has the name acctfile, another variable.

This line actually does two things. It opens the file and then reads it into the account record layout, making all the fields available to us so we can put them on a report. Using just read acctfile would accomplish the same result because of the way the file is defined. The keyword record ties the field, account-record to the account number file so that any read of that file will result in the data being moved to the field, account-record.

In the world of computers, there are numerous ways of doing things, which can be good and bad. This I pointed out in an earlier chapter when I talked about systems and rules. The next nine statements are all print statements using the keyword print. Hence the first one will print out the account number, which happens to be in this case.

The remaining eight print lines will then list the remaining eight fields in the record, as shown on the listing above. That is all there is to the program with the main activity consisting of a read, nine print lines and an end. This program simply opens and reads the file into an appropriate layout, prints out the nine fields on the first record, closes the file and ends — truly exciting stuff. There are a few concerns. For one, what about the rest of the records in the file?

Second, it might be nice to have some labels for the fields on the report so we know what each is and it may be better for the environment to print the fields across the page rather than down it.

While we are at it, what about a title for the report? These are all valid questions, which need resolving. Let us begin with the question about upper case in the names. The reason they are lower case is because someone entered them that way. We can resolve that in one of two ways by either reminding the data entry people to appropriately use capital letters in these situations or we could change our data entry program to make sure that these first characters are upper case on the file no matter what is entered.

You may remember that I said we needed only lower case before. And yet how do we account for the first letter of the name without capital letters? The restriction on using only lower case applies only to our computer program, not to the data itself. We can certainly get along well with that limitation. However, we probably need to allow both upper and lower case in the data that will be on our file. We could print a label before the account number by the statement: The double quote enables us to print literals or strings of values that can be helpful in reports.

It may be hard to see, but note that there is a space after the colon, which keeps the label and the actual account number from running together.

The first would print all the field labels and the second would print the actual field values. Since a line on our report has space for about characters and our record layout is 99 characters, we should have enough room on one line to print all the fields and have room for spaces between the fields as separators.

This we can do by the following print lines: The word balance and the value of it would all be on the same line with the other data and there would be more spacing between the fields. Nobody said computers are perfect. If the page you are reading does not have this discrepancy, it means that the publisher took care of the problem. In any case, I think you get the idea.

There would be three spaces between the fields and more depending on the values, specifically the name fields, which allow for more than the number of characters that each name actually has. Thus there will be exactly four spaces between the sign and the label last and exactly three spaces between the last digit of the account number and the first letter of the name, Smith.

Note that we have our upper case designation for the names, which means someone entered them correctly on the file. Though our first print statement takes up two lines in our program, it will all print on one line of our report. The same is true of the second print statement. If we had put the keyword print before the literal city, then the labels of the fields would have printed on two lines which is not what we want.

This string consists of exactly three spaces. I mentioned the keywords, character, integer, signed and decimal, 16 before, so you have a good idea what they stand for. In summery, the first can be just about anything, any letter of the alphabet, a number or special character. The keyword mask is used to reformat the balance so that it will have the appropriate dollar sign, commas if the amount is a thousand dollars or more as well as the decimal point in all cases.

The dollar sign used the way it is here allows it to float to just left of the significant digit in the amount. Recall that the record has for the balance, so with the mask, the leading zeroes on the left are not printed and the dollar sign winds up just to the left of The 9 in the mask forces the number to print, even if it is a zero.

The decimal amount will always print with this mask. Note also that we need two right parentheses to end the statement in order to balance those two parentheses on the left and the mask is enclosed within one set of parentheses. The outer parentheses are needed to assure that the mask goes with the variable, balance.

We could choose to not print the dollar sign or leave out the comma and this we could do with a change to the mask, using mask Our values would then be To suppress the leading zeroes we could change it to mask zzzzzz. The character z here just suppresses the leading zeroes.

We do this by introducing more keywords, status, if, go to and end-if. We do have three possibilities here, that is we could have a normal account file or an empty one or none at all so the keyword status will enable us to see which of the three comes into play in our program.

The last three keywords will give us the ability to make decisions and even branch if necessary, which we will need to do in many cases. The main logic of our program the code after the structure and its definition now is: This is done by the keyword status, which is always a two-digit number, or integer 2 , that we will use to verify that any processing of a file has no problems, whether it is a read, write or delete.

Here acct-status will be used to see if we have a successful read. A value of 0 will indicate that the read was error free. In fact we shall see later that other accesses to the file such as a write will also result in 0, provided they are successful. If we read the file and there are no more records left, the record status will be 9, indicating we have reached the end of the file.

The first is an assign statement, where the variable on the left is given the value 9. In the second line, the first part read-file is a label, which is used since we need to get back here over and over. Labels are followed by a colon. The next six lines work hand in hand. In this case we are looking at the field acct-status 19 to see if it has a value of 0.

This means that the read of the file was successful. If it is, the new line or two indicates what action is to be taken. In this case we have the fields we need to print a single line of our report. We print that line and then proceed to do another read.

This is accomplished because of the next keyword, go to, which allows us to branch to the label read-file. We can now try another read and proceed as before. The keyword end-if is used to indicate that our if statement is complete.

In this case we cannot proceed so we print out an error message. The end-if again means that this particular if statement is done. If the acct-status is 9, indicating the end of the file, we will wind up in the same place — exactly what we want. That is why we need the six dollar signs and one 9 or seven places in all. As a result, the leftmost digit would be truncated, which is not what we want.

The computer will do exactly what we tell it to do. The last line of our program 20 end-program: We saw it in the earlier version of this program. As you will agree, these modifications are a huge improvement over what we had. File access If you work with different computers you will hear about flat files, sequential files, indexed or keyed files and databases. This is also what is referred to as a sequential file. These types of files can be used quite successfully to back up a file and restore it and either can be done quickly.

An equivalent music device is the cassette or eight-track, each of which results in listening to every song in order or fast forwarding to get to the song you wish to hear. The next type of file is an indexed file or keyed file, which has some sort of key in it. This enables us to get to a specific record without reading every other record in the file. This could save us some time since we could obtain the record we want quite quickly, but we have to know the key to the record or at least part of that key or some other significant field.

Many systems give you this option. An equivalent music device is the record or CD since either can get us to a specific song without much effort, unlike the cassette or obsolete eight-track. Nonetheless you can have a file that is an indexed file with duplicate keys. There are all kinds of indexed files and the differences are due to the company that developed them or the time when they came out.

If you know one index file method you can adapt to any other. The last designation is a database, and as I mentioned earlier every file is a database as each has data that is a base for our system. Some will argue that a database needs to have a key and this equates to an indexed file, but certainly a sequential file is a database — with limitations.

Thus, every database is a file. If you work with other systems, you will note that the program using a file may have to open it, read it and finally close it. The language that uses this file may actually do a close of the file as the program ends just in case you somehow forgot to do it. This suggests to me that the close that seems to be required is not really necessary.

In our sample report program earlier we neither had to open nor close the file because our system is quite intelligent, which is what all systems should be.

For our system, all the files will be indexed files. They will all have unique keys and we can access records in the files by keys as well as read those files in a sequential manner. That is exactly what we did in our very first program to list the fields on the Account balance report. We will get into processing data by specific keys later. The file we used in the previous chapter was also processed sequentially.

In our system, the field 22 account number, will always be generated by the system. If our report had fifty accounts, they would all be in ascending order with the lowest key first and the highest last. Recalling the restriction on account number being greater than 9, there is a very good chance that the first record would have an account number of 10, followed by 11 and However there could be gaps in the numbers, as we shall see later.

Some computer systems will lock you out of a file if someone else is updating it. Thus if someone was updating a record in our account file, we may not be able to read any record in the file. Our system will be a little more permissive, having been designed by liberals. If two people want to update the record with account number at the same time, one of the two people will get to it first.

Just before Pat completes the update Chris accesses the same record and the zip code still has the value She changes the middle initial from L to P and Pat does his update, resulting in the new zip code in the record. But then Chris does her update and the middle initial now is P but the zip code has been returned to the value of , not what Pat had intended. The changed value has been overlayed.

We cannot allow this to happen and I will get to how this is handled when we work on an update program. I think you can see that locking the record temporarily should work and not locking the entire file means that both can update different records at the same time.

That would be the way to design the system. Designing the files is done by a DBA or data base analyst. He or she does this with input from other people for efficiency. This means time needs to be spent on analysis and design. In our account file our key may actually be larger than we need but that is something that needs research.

That whole consideration of trying to save two digits for dates by using only two positions for the year instead of four is what caused the Y2K fiasco. The design of the files will have to wait. These are just some problems involved in information technology systems and you will run into them no matter where you work. The better the system is thought out, 23 the more pleasurable will it be to work there. By the same token, there may not be that much work for you because of that.

The places that have plenty of opportunity for work will probably be the corporations that you would not rather set your foot into. I thought Abend was an appropriate name since we were studying computers. The word abend is a contraction of the phrase abnormal end, which many programs and systems do and with which not many people are happy. It means working overtime and on the weekend. I doubt that management would approve. In information technology there are quite a few ways for abends to occur.

A program could encounter bad data when it is looking for a numeric field and instead finds letters of the alphabet. The result is the program terminates. A system could run into a space problem and the result is an abend. The cause may be something as simple as the fact that the tape drive missed its normal maintenance cleaning, but it could be something else.

There could be a disk crash or you could run into bad sectors on the disk and the results could be really annoying. The word crash seems to be another way of saying that we had an abend because they are one and the same. The only way out was shutting down and restarting, which resulted in my recent changes being lost. And I thought computers were supposed to make our life easier.

Each of these possible scenarios has to be controlled. If not, there is no sense in having a system because reliability is compromised.

You might be spending more time with your computer than if you had a manual system. Obviously there will be difficulties from time to time and you will have to put up with the problems, but you need to do everything possible to limit these troubles. To avoid space problems you have to maintain files, eliminating those that are out of date or redundant.

It may be as simple as backing up these questionable files to a tape so that if they are needed, they can be retrieved. This leads to valuable space being saved. Another kind of maintenance has to do with backing up a file and then redefining it and restoring it from the backup.

What this does is eliminate fragmentation, which happens to files when they happen to have gaps in the data or be on multiple disk packs. One of the maintenance tasks on PCs is checking for fragmentation on the disk from time to time and taking action if necessary.

Another way of helping alleviate the space problem is eliminating duplicate data on a file, which I will get into later. However, talking to other corporations can give you some insight as to whom to avoid and who may have a worthwhile product for you to use.

Power failures could cause nightmares so you need some way to handle them. Unfortunately it may not be that simple. If you have programs that update files, backups at the appropriate time will save you from a great many headaches. If you use the one from the weekend, you could lose a great deal of data and time even though some files have been restored. Once again planning your system should reduce problems to a minimum.

Despite all precautions, even the best intentions can result in major screw-ups. In the early s, I worked full time for a computer company in the software department. My assignment was that of a consultant without commensurate pay.

I quit the company after about a year and a half when I saw that there seemed to be no future in this specific business. While I was in their employ, I was asked to create a purchase order system and I was given two options: I was specifically directed to determine my approach with some analysis, so I set forth and discovered that using what was there would have required more time and effort.

I should have wrote the system my way and not told a soul about it but instead I foolishly did as told. The result was that my boss complained when it took longer than he wanted me to spend. When I was done though, the effort was top-notch and the clients were pleased as punch — whatever that means. Unfortunately, Murphy showed up one day. What happened was that the client ran into a problem one day and had to resort to the backup of their system.

Their practice had been to do a daily backup of the system in case of any problems. They went back a few backups but even those were as worthless as Tom Delay being in charge of the ethics committee. Going back like they were doing meant that they would have lost a few days activities, but at least they had a system. That was just what was taking place with the purchase order system daily backup and there was no suitable backup.

Fortunately, the office where I worked — at the 26 time — had the purchase order system still on their computer. Well, had is the operative word because one of my co-workers deleted it there. By this time I had left the company but was contacted about the fiasco at home. I mentioned that on the desk where I spent my days at the office was a tape with the purchase order system.

Restoring it meant that the client would have to start data entry from the beginning, but at least they had their system back. You probably guessed the ending of this tale, but if not, I need only mention Murphy. Sure enough, someone had used the tape by writing over it and the system was lost forever. I do know that within a few months this computer company bit the dust.

You should never have a program that abends because of bad data caused by a field generated by the system. Any program that accepts input to be used as fields in a file should guarantee that this field will never result in an abend due to bad data. If the field is numeric, the program should never accept any other type of data into this field nor should it ever write out this field to the file if it is not numeric. This may take a bit more programming but it will result in evenings and weekends with virtually no calls from the computer room.

That will make your time at home more enjoyable. Problems will occur no matter what you do and no matter how careful you are designing systems. The steps you take will differ from system to system but you need to minimize the effects of crashes and software failures. As we get into further sample programs, I will offer some suggestions to help reduce the frustration without leaving your place of employment or jumping off a twenty-story building.

To save the destruction of trees for paper for our reports, our system will create the report but not actually print it to paper. Instead it will display data on the screen. You can get a full report printed but it will cost you. The intent is to make the cost so prohibitive that people will think twice about getting it on paper. For a lesser amount you can have just the page you need printed.

This will cause people to think about the reports they request and be more concerned for the environment. At the end of the chapter, I will talk briefly about going paperless. Obviously we need to look at data on files but we can do that without looking at a piece of paper. I never want to read a novel online but data in the office is an entirely different story. We can peek at records on the account file if we have some kind of inquiry program online. Since our file is indexed, we can look at a specific record if we know the account number.

Before getting into the actual program, let me talk about program specifications. These are nothing more a detailed summary of what the program is supposed to do.

They can be very long, encompassing not only what is to take place but also how that should be done. On the other hand specifications can be brief, to the point and it is up to the programmer to do the rest.

Our specifications can be written as Write a program to display account file fields based on the account number. It could also be Transfer the original account file report to the screen but limit it to one record at a time depending on the account number input. Vague as these specs may be, in either case you get the idea of what needs to be done and how it is to be done is up to the programmer as well as where to place the fields on the screen.

Actually, our goal is to have the user be so thrilled that she holds a party to celebrate the occasion. In order to get data on the screen we need the keyword, screen.

The computer monitor in most cases has 24 rows and 80 columns to display characters. Reducing the size of the characters can increase the number of rows and columns on the screen, but you need to be able to read the data. Any data in those positions on the line when this command is executed will be deleted. Note that if there happened to be something on the screen in positions 1 through 29, it will not be removed.

This centers the heading in the line. The first number after the left parenthesis indicates the row where the field will start while the second number represents the column. It should be noted that only the first line will be effected by our screen command. If we use either line above in our program we may run into some difficulties since our screen could already have information all over it on other lines.

Our data would still be displayed but so would much of the data that was there before. We will need to clear the screen and this can be done with the line screen erase where the combination of these two keywords will remove all previous data from the screen so that we will be ready to display just what we want and nothing more.

Adding the line screen erase 20,1 before that screen line with the literal error will erase whatever is on line Thus screen erase 10,18 will erase everything on line 10 starting in column The complete program would look like the following: Note first that the title of the account number inquiry program is acctinq and our second statement define file acctfile record account-record status acct-status key account-number structure introduces the keyword 30 file, which we should have had in the earlier programs.

It lets us know that we are defining a file. We clear the screen, but only once, and print the title on line 1 in column 30, followed by all the other headings on the appropriate lines. The next line introduces a new keyword: The keyword input halts all activity until something is entered. If there is input, we clear the error message at the bottom of the screen if one is displayed. It was on the screen a sufficient amount of time.

This is necessary for two reasons: This reminds me of one of my college professors who wrote with one hand and erased what he wrote with the other — not my idea of a good teacher. When it comes to important messages at the bottom of the screen, a good practice is to leave the error message on the screen until something is input.

We have defined account-number as a nine-digit integer and whatever is entered to the right of the literal account number: If it is, the account number file can be read. You will note that entry for the account number begins at position 36 in row number 4 but if we had omitted the 4,36 , it would start in the position right after the colon following the literal. This mention of the specific row and column allows for a space.

You will not be able to enter letters of the alphabet or any special characters into the input field. If you enter 9 for the account number, you would not need to key the leading zeros, since that one digit would suffice. The next line is a decision, which allows the user to end the program, which is done by entering 0 for the account number. Zero is certainly an integer but not a valid account number. As we have pointed out, account numbers have to be greater than 9.

Entering 0 terminates the program and forces a branch to the label end-program which ends all activity. The next statement read acctfile key account-number should be familiar. The only difference involves the keyword key. This statement takes the value that was entered for the account number, and uses it as a key to read the account file into the structure.

The statement could be replaced with read acctfile 31 since the definition of the file points to the key as account-number.

The file status is checked as in our original program. Here we have an indexed read. If the read is successful, the program will display the values of each field for the record that was read and the user can now enter another account number or exit the program. For invalid account numbers entered, a message will print on line 24 starting in column 20 listing the invalid input.

The keyword else gives us options so we will either read another record or be at the end of the program. This is another keyword which we have not seen with if statements. We actually cover three cases for the file status, 0, 5 and anything else. You may ask why we need to restrict the account number input to numeric as the read of the file would take care of that.

We could take whatever was entered and try to access the file. If the field is numeric, the record desired may be on the file, but maybe not. Each case would be handled. We could allow character 9 but then the user would have to key in leading zeros. Being defined as integer 9 is a better choice since it saves keying. If you have just an if statement or a combination of if and else, you only need one end-if.

The minus sign allows for negative numbers to be displayed. For a negative balance, the sign prints to the right of the second decimal digit. If the amount is positive, no sign will print. The negative sign is printed on the right because we have the dollar sign on the left. At the end of the program, that error message is printed. If everything went smoothly, we just print nothing on line The error message will remain on the screen until the operator presses enter.

That is the entire screen program to inquire on accounts and if you think that it is complicated, it does get involved but there are some systems where the whole process is even more confusing. Some methods of getting data to the screen involve escape sequences, which are quite different and mind-boggling until you get used to them.

As promised, I offer my thoughts on going paperless. A few years ago while on a contract at a major bank, I saw a report — I forget how often it came out — that used over a box of paper.

Strangely, the accompanying summary report was even longer. The requester probably had a few shares of Georgia-Pacific stock. No one said banks were dispensers of sanity. As you can tell, I care for the earth and prefer the paperless route, but not completely. My experience with the backup files of a previous chapter should have convinced you of that. A balance is needed, because of all the possibilities. Our friend Murphy may be lurking somewhere. Having worked at over a half-dozen software contracts at banks over the years, I saw that those institutions documented everything to death.

In the summer of , I needed some documents from a local bank on a few investments. They went back less than six years.

The bank found some but not all of what I requested. I was confused and thought that if accounts needed to be purged, they could have been printed out and stored, with an index of the account numbers on some kind of storage disk.

The latter would point to the location of each account number. Apparently, I never considered the fire that destroyed the paper stuff, rendering the related disk worthless. Now we know why our parents hid money in out-of-the-way places in their home, so no one could find it, not even their children — ever.

Program flow and compiles So far the two programs that have been discussed have taken an input file and produced output. In each case the input was the account file and the output was a report, even though one was paper and the other was on the screen. We still have to deal with updating a file, but once we do that, we will have covered every possible scenario as to what a computer program can do.

A computer program will execute one statement after another until finally it hits the end. In our P language, that happens to be the end keyword. It can get to different places because of branches to labels, triggered by go to statements. These can be conditional, that is based on an if statement, but they could also be unconditional. The latter would be seen if we had a group of print statements followed by a go to which did not have any if statement preceding it.

Consider the following statements: Note that the next statement can never be executed because of this go to statement. Otherwise control goes to the label start-read. Because of this logic, the next statement can never be reached as the if-then-else statement has forced a branch to one of two places and it will either get to next-step or start-read. It can never get to the statement following the end-if.

This line is dead code and there is no reason to leave it in the program. Sometimes people write code this way but the extra line only confuses those looking at the program. On other occasions a program may have been written without any dead code but someone modifies it and in so doing creates these lines of meaningless logic, which can never be executed. Changes were made that forced this scenario and whoever did them should also have deleted the dead code.

Now consider another group of statements: This would be true if the field file-switch has a value greater than 1. But now suppose that in our program this field will only be 0 or 1. At this point the last line is once again unreachable as before. Let us consider one more set of statements. Note though that we can never get to the label end-program if the file has any records because the variable acct-status will always be 0.

If the file was empty, then and only then would the program end because the status would not be 0 and the branch to the last statement would be taken.

If there is at least one record on the file, the status would be 0 and the print would be done and then a branch to the label start would take place. At this point, no new record will be read and the field file-status would still have a value of 0 and once again we would print out the same account number preceded by the appropriate label.

What we have is an infinite loop, as the program will continue to print out this same account number with the literal account number: The program would never end unless we somehow interrupted it.

The problem is we need to do the read of the file each time we get to the label start. A simple change will get us out of this mess.

All we need is to move the label up one line to the read statement and then we would eliminate this looping. Thus our statements become: This program could also have been written as start: You may ask if there is some way to check the lines of the program before we actually run it.

There are two possibilities for this. In the P language as in a few others, we write the program and then simply try to run it. If things are in order, all the fields are properly defined, every if statement has a matching end-if, each left parenthesis is matched by a corresponding right parenthesis and so on, then the program will do what it should.

On the other hand, if something is amiss such as an undefined field, then the program will try to run and pause because of that deficiency. At that point there will be some message indicating more or less what went wrong — at least in most languages. Of course there could be another different problem and once again you would have the same situation. You could correct it and resume the program and eventually get to the end.

Any program that we write is referred to as source code. Whether the running of the program proceeds as above or in one other manner, it will still be a source program. The other possibility is that we will need to compile the program or source code. This process is nothing more than running the program through a compiler to find out if there are any errors such as we mentioned above.

If there are problems, we will get a list of the trouble spots and we can change the code and then recompile the program. Once all the errors are cleared up, the compiler will create what is referred to as object code. This is what is actually executed when we run the program, at least if we compile the source code.

If you were to try to view some object code it would probably look like obscenities. However, this is what the computer needs to run your program and object code is sometimes called machine code for that reason.

As far as compiling a program, it sounds complicated but it is just running your source code through another computer program to create object code or find basic program problems. When you get to work with other people in a programming environment and you need to do a compile, you will be given enough information to proceed. At this point you may think that you are home free if your program compiles and then runs to completion.

Maybe so, but there could be logic problems. When you design a program you have a good idea what you want done so you code accordingly.

The computer then follows your directions but if you unknowingly have the wrong code, the 37 computer will still do what you tell it but it may not be exactly what you want. This is referred to as a logic error. What you then have to do if you see that the wrong thing is happening is check over the code and see what is causing the difficulty.

That may take longer than it took you to write the program, but you need to do it. So you may have thought that you would have an easy time but there could be problems. Just remember that the computer will do everything you tell it to do but it is up to you to dictate the proper instructions.

This means you need to know the rules of the language and how everything proceeds. The clearer your understanding, the fewer difficulties you will have.

This is the process of figuring where you went astray. If we run the program the report will have heading lines, followed by detail lines. It will fill up one page and then print the next one without any header lines. Note the program name has been changed. To do this the complete program follows. Most of this should be familiar and you can take for granted that I have all the spacing correct. The variable main-heading is set up to give us all we need. The first new keyword you see is field, which appears to be a variable.

It is used mostly for literals or to separate one field from another. It is the separator between the month and day and the day and year in our date. It occurs twice because we need it twice. Though field is a keyword, we cannot refer to it in our program. Each of the two statements, as well as field character 4 value space achieves the same result — even though one may not be grammatically incorrect.

They represent spaces, a space, nothing, a single blank and blanks. You will note that field occurs a few times in the program and just about each value is different. It represents either a certain amount of spaces for separation or a specific literal and is part of a structure, which enables us to use it. If we need to assign it a value that can change, we have to make it a variable and then we could reference it. Using field1 or field2 would do the job, although it would be better to give these fields more meaningful names.