Exercise 1: What USING/GIVING Genuinely Automate, and Filtering Records Before a Sort — Possible Solution ==================================================================== WHAT USING GENUINELY HANDLES AUTOMATICALLY This chapter's own real material states this plainly: USING automatically transfers records from the input file into the sort operation, with the compiler itself opening the input file, reading every record, making each one available to the sort, and closing that file afterward - all without the program needing to write any of that file-handling logic by hand. WHAT GIVING GENUINELY HANDLES AUTOMATICALLY GIVING does the equivalent real job on the output side: once sorting is complete, it automatically writes every sorted record to the named output file and closes it, again with no manual OPEN, WRITE, or CLOSE statements required from the program itself. WHY THIS MATTERS: WHAT USING/GIVING DON'T LET THE PROGRAM DO Because USING transfers every real record from the input file into the sort without exception, there's no real opportunity for the program to inspect or filter records before they're sorted - every record present in the input genuinely goes through the sort. The same is true in reverse for GIVING: every sorted record is genuinely written to the output with no filtering step available. WHAT WOULD NEED TO CHANGE TO FILTER RECORDS BEFORE SORTING This chapter's own material names the real alternative directly: INPUT PROCEDURE. Replacing USING with a real INPUT PROCEDURE hands control back to the program's own real logic before records ever reach the sort - the input procedure can select, modify, or copy records as needed, deciding which ones actually get released into the sort and which don't. This chapter's own material is also explicit that INPUT PROCEDURE and USING can never appear together in the same SORT statement - it's genuinely one or the other, not both. ANSWER: USING automatically opens the input file, reads every record, and closes it, feeding all of that data into the sort with no manual file-handling code; GIVING does the equivalent automatically on the output side once sorting finishes. Because USING transfers every input record without exception, there's no way to filter records out before sorting while still using USING - to filter records before the sort, USING would need to be replaced with a real INPUT PROCEDURE, which hands control to the program's own logic to select, modify, or skip records before they're released into the sort. This chapter's own material notes these two options are mutually exclusive - a program uses either USING or an INPUT PROCEDURE, never both together. WHY THIS WORKS AS AN ANSWER ------------------------------ This correctly separates what USING/GIVING each automate from what they explicitly don't allow (filtering), and names the real, chapter-stated alternative (INPUT PROCEDURE) along with its mutual- exclusivity constraint rather than describing filtering as simply "possible somehow."