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

public class P7 {
    public static void main(String[] args) throws IsamException, RecordException {
        try {
            // open database
            IsamSource db = new LocalIsamSource("msgs.isq", "dk.vajhoej.vms.rms.IndexSequential", false);
            // write message to database
            db.create(new MsgRec(7, "Hi from Java!"));
            // dump all messages in database
            IsamResult<MsgRec> it = db.readGE(MsgRec.class, new Key0<Integer>(0));
            while(it.read()) {
                MsgRec msg = it.current();
                System.out.println("|" + msg.getMsg() + "|");
            }
            // close database
            db.close();
        } catch (Exception ex) {
            ex.printStackTrace();
        }
    }
}
