Iterating History

Iterating History
 1ot = impact.gui.output_toolbox
 2db = impact.active_database
 3
 4ot.clear()
 5
 6cust = db.customers.find_by_code("ACME CORP")
 7
 8if cust is not None:
 9    ot.add("Located customer " + str(cust.code))
10
11    docs = cust.documents
12
13    if docs is None:
14        ot.add("No customer document support in the database")
15    else:
16        ot.add("customer document support is enabled in this database")
17
18        count = docs.count
19        ot.add(str(count) + " documents for '" + cust.name + "' currently in the database")
20
21        ot.add("Iterate using Item property")
22        for i in range(1, count  + 1):
23            doc = docs.item(i)
24            ot.add("Document: '" + doc.name + "', impact.creator: " + str(doc.added_by.login_id) + ", Size: " + str(doc.size) + " bytes")
25
26        ot.add("Iterate using for each")
27        for doc in docs:
28            ot.add("Document: '" + doc.name + "', impact.creator: " + str(doc.added_by.login_id) + ", Size: " + str(doc.size) + " bytes")
29
30        ot.add("Locate document by name")
31        doc = docs.item("Order Details.docx")
32
33        if not doc.isNone():
34            ot.add("Document: '" + doc.name + "', impact.creator: " + str(doc.added_by.login_id) + ", Size: " + str(doc.size) + " bytes")
35        else:
36            ot.add("Unable to locate document")
37else:
38    ot.add("Unable to locate a customer")
39
40