# Collection of code snippets by Arne Vajhøj 
# (from articles on eksperten.dk / vajhoej.dk written sometime between 2004 and now) 
from dk.vajhoej.isam import Key
from dk.vajhoej.isam import Key0
from dk.vajhoej.isam import IsamException
from dk.vajhoej.isam.local import LocalIsamSource

import Employee

print('Jython')
db = LocalIsamSource('emp.isq', 'dk.vajhoej.vms.rms.IndexSequential', True)
res = db.read(Employee, Key0('0002'))
if res != None:
    print('By no   : %s %s %s' % (res.no, res.name, res.role))
else:
    print('Key not found : no')
if res != None:
    res = db.read(Employee, Key(1, 'Brian B   '))
    print('By name : %s %s %s' % (res.no, res.name, res.role))
else:
    print('Key not found : name')
if res != None:
    res = db.read(Employee, Key(2, 'Engineer  '))
    print('By role : %s %s %s' % (res.no, res.name, res.role))
else:
    print('Key not found : role')
db.close()
