Alright boys and girls, the preliminaries are over. Let's turn our attention
to some actual data.
Puzzles and Problems
Beginning Xbasic Programming
Puzzle 5 - Nested loops
I've attached a sample database, containing the invoice_items table from AlphaSports, and an index (CDX) file.
Write an xbasic script that opens this table, arranges its records in ascending order based
on the "invoice_nu" field, and then computes the total for each invoice by summing
the "extension" fields for all records that have the same invoice number. For each invoice
write the invoice number, the number of different items on the invoice (not the item count,
but the number of "lines" on the invoice), and the invoice total to the trace window. At
the end, write the grand total of all the invoices to the trace window.
Instructions:
a) you may not use any of the built in summary functions, methods, or operations in Alpha Five. We're doing this one by hand.
b) you may open the table only once
c) you may not use any queries or filters
NOTE: These puzzles and exercises will be studied by beginning programmers. Supply
comments throughout your script to explain what your script is doing and why. You're
writing for posterity. Be thorough. Thanks.
Postscript: I've changed the attachment. It's now a complete database. Unzip the attachment and extract contents to an empty folder. This was necessary because the original attachment did not include supporting dictionary files that would have been necessary. Sorry for the confusion. -- tom
to some actual data.
Puzzles and Problems
Beginning Xbasic Programming
Puzzle 5 - Nested loops
I've attached a sample database, containing the invoice_items table from AlphaSports, and an index (CDX) file.
Write an xbasic script that opens this table, arranges its records in ascending order based
on the "invoice_nu" field, and then computes the total for each invoice by summing
the "extension" fields for all records that have the same invoice number. For each invoice
write the invoice number, the number of different items on the invoice (not the item count,
but the number of "lines" on the invoice), and the invoice total to the trace window. At
the end, write the grand total of all the invoices to the trace window.
Instructions:
a) you may not use any of the built in summary functions, methods, or operations in Alpha Five. We're doing this one by hand.
b) you may open the table only once
c) you may not use any queries or filters
NOTE: These puzzles and exercises will be studied by beginning programmers. Supply
comments throughout your script to explain what your script is doing and why. You're
writing for posterity. Be thorough. Thanks.
Postscript: I've changed the attachment. It's now a complete database. Unzip the attachment and extract contents to an empty folder. This was necessary because the original attachment did not include supporting dictionary files that would have been necessary. Sorry for the confusion. -- tom
Comment