Fast Track 2.3: Difference between revisions
Line 15: | Line 15: | ||
Later, if we want to print out the list of names and email addresses (or use them to send out statements!) we open the file again. | Later, if we want to print out the list of names and email addresses (or use them to send out statements!) we open the file again. | ||
OPEN #EMAIL_FILE: “Name=customerlist, recl=58” | OPEN #EMAIL_FILE: “Name=customerlist, recl=58”, INTERNAL, INPUT ERROR errorhandling | ||
Reading and making changes to that information using GRID and LIST | Reading and making changes to that information using GRID and LIST |
Latest revision as of 21:45, 2 February 2015
Writing to a data file
WRITE #3, USING “N 8, C 50”: cusnum, email$
Writes the customer number and email to file #3, which we just opened. (File numbers can be replaced with labels to make your programs clearer). The N 8 means that the cusnum variable can be up to 8 digits long, while the C 50 means that the email$ variable can be up to 50 characters. These form descriptions can be put into a FORM statement and referenced by a line label, as you'll see in the READ example coming up.
Closing a data file
Closing a file is the easiest step:
CLOSE #3:
Reading a data file, and then using that information to print
Later, if we want to print out the list of names and email addresses (or use them to send out statements!) we open the file again.
OPEN #EMAIL_FILE: “Name=customerlist, recl=58”, INTERNAL, INPUT ERROR errorhandling
Reading and making changes to that information using GRID and LIST
READ #EMAIL_FILE, USING “N 8, C 50”: cusnum, email$
This will read the first record in the file and store it under the variable names cusnum and email$. But this is a whole list and so we will have to repeat the READ command and store the information into MAT cusnum and MAT email$. Using a For Next statement.
Emailform: form N 8, C 50 While N=1 READ #EMAIL_FILE, USING emailform: cusnum, email$ EOF lastrecord Loop lastrecord: ! Read is done.
CLOSE #EMAIL_FILE: