### Use JavaObject Advanced

These are some advanced JavaObject usage examples.
JavaObject.InitializeArray
The example is based upon a Java Library jDBF - more information here: https://code.google.com/p/jdbf/downloads/list
A new DBF file with 2 fields FieldA (Char 8) and FieldB (Char 32) is created and 2 records are added.
To create new fields a JavaObject Array is created.
To add records a Object array is created.
' Create a new DBF file and add records
' Example related Java Code
' JDBField[] fields = {
' new JDBField("FieldA", 'C', 8, 0),
' new JDBField("FieldB", 'C', 32, 0)
' };
' DBFWriter dbfwriter = new DBFWriter("./testwrite.dbf", fields);
'
' Public void addRecord(Object[] aobj)
`Sub createDBF(sfile As String)
txtLog.Text = "DBF File: " & sfile & CRLF
' Define the fields
Dim joFieldArray As JavaObject
joFieldArray.InitializeArray("com.hexiong.jdbf.JDBField", Array( _
createDBFField("FieldA", "C", 8, 0), _
createDBFField("FieldB", "C", 32, 0)))
' Create the db= DBF file with the 2 fields
Dim joDBF As JavaObject
joDBF.InitializeNewInstance("com.hexiong.jdbf.DBFWriter", Array(sfile, joFieldArray))
' Add some records
Dim r(2) As Object
r(0) = "A1"
r(1) = "B1"
joDBF.RunMethod("addRecord", Array(r))
r(0) = "A2"
r(1) = "B2"
joDBF.RunMethod("addRecord", Array(r))
'
joDBF.RunMethod("close",Null)
End Sub`
' Class JDBField
' package com.hexiong.jdbf;
' Public class JDBField
' Public JDBField(String s, Char c, Int i, Int j)
`Sub createDBFField(n As String, c As Char, x As Int, y As Int) As JavaObject
Dim jo As JavaObject
jo.InitializeNewInstance("com.hexiong.jdbf.JDBField", Array(n, c, x, y))
Return jo
End Sub`

Changed: , Category: JavaObject, File: T6C208M1529.htm, ID: 1529