266 Storing Fixed Size Data in Random-Access Files Figure 8-2: The fixed size of each record makes it easy to identify the physical location of each record in a file. Each record takes up a fixed amount of space inside a file. FirstName LastName Age Phone FirstName LastName Age Phone FirstName LastName Age Phone Writing data To store (write) data to a random-access file, define a variable that represents your records like this: Type PeopleRecord LastName as String * 20 FirstName as String * 20 Age as Integer Phone as String * 12 End Type Dim Contact as PeopleRecord After you define a variable to represent your record, store data in the Contact variable, such as Contact.LastName = “Smith” Contact.FirstName = “Joey” Contact.Age = 28 Contact.Phone = “310-123-1234” The next step is to create a random-access file by defining a filename like this: Open “MyFile.dat” for Random as #1 Len = Len(Contact) This code opens (creates) a random-access file named Myfile.dat, identified by the number 1 (#1) and divided into chunks defined by the size or length (Len) of the Contact variable (record). You can choose any number to represent the random-access file. Using a number, such as #1 or #8, is much easier than typing the entire filename out each time you need to identify which file to use again.
Storing Fixed Size Data in Random-Access Files 267 When you open a random-access file to store data, you must correctly define the size of the records. If you define the record size too small, you may lose data. If you define the record size too large, you waste space. After you create and open a random-access file, you have to store data into that file like this: Put #1, 1, Contact The Put command tells the computer to use the file identified as #1 and store the Contact data as the first (1) record. To add more data to the random-access file, you’d have to store different data into the Contact variable and use additional Put commands, such as the following, to store data as the second record in the random-access file: Book II Chapter 8 Put #1, 2, Contact When you’re done adding records to a random-access file, close the file, which tells the computer that you’re done working with that file. Close #1 Reading and Saving Files Reading data After you store one or more records in a random-access file, you can retrieve (read) data from that random-access file by identifying the file to use, assigning a number to that file, and defining the size of each record in that file like this: Open “MyFile.dat” For Random As #1 Len = Len(Contact) When you open a random-access file to read data, you must correctly define the size of the records stored in that file. If you incorrectly define the size of the records, the computer can’t retrieve the data correctly. After you open an existing random-access file, you can retrieve data by using the Get command like this: Get #1, 2, Contact This command tells the computer to get information out of the file identified as the #1 file, retrieve the second record, and store it back into the Contact variable. At this point, you could store the data from the Contact variable into another variable and then retrieve another record from the randomaccess file. When you’re done using the random-access file, you have to close it like this: Close #1
Agreed in 2016, the motive of the General Data Protection Regulation (GDPR) is to better protect the personal data of European Union “data subjects” – EU citizens and other nationals physically present in the EU at the time data are collected. Visit: https://www.hipaajournal.com/gdpr-training/
The Health Insurance Portability and Accountability Act (HIPAA) was created primarily to modernize the flow of healthcare information, stipulate how Personally Identifiable Information maintained by the healthcare and healthcare insurance industries should be protected from fraud and theft, and address limitations on healthcare insurance coverage – such as portability and the coverage of individuals with pre-existing conditions.