The problem I have is that UniDynArray "extract" method does not seem
to recognize Field, Value and Sub-Value delimiters in an UniDynArray.
In the code example below I tried to illustrated this. I created a
test file and record and populated that record with 10+ fields. When
running this program only the first field is displayed with all the
"actual" fields combined. Can anyone offer an explanation on why this
simple code example does not work:
Code:
import asjava.uniobjects.*;
import asjava.uniclientlibs.*;
public class Test {
public static void main(String args[]) {
int i, dynArraySize;
String temp;
String hostname = new String("localhost");
String username = new String("mick");
String passwd = new String("unixfs");
String account = new String("/uv/ADMIN");
String fileName = new String("PROJECT");
String recordID = new String("12654");
UniFile fileVar = null;
UniString record = null;
UniDynArray dynArray = null;
UniSession session = new UniSession();
//Open the session to the Universe Database
try {
session.connect(hostname, username, passwd, account);
System.out.print("Connected.\n");
}
catch(UniSessionException ev) {
System.out.print(ev.getMessage() + "\n");
System.out.print("Failed to connect.\n");
System.exit(0);
}
//Open the "test" file
try {
fileVar = session.open(fileName);
System.out.print("File opened.\n");
}
catch(UniSessionException ev) {
System.out.print(ev.getMessage() + "\n");
System.out.print("Failed to open the file.\n");
System.exit(0);
}
//Read the "test" record
try {
record = fileVar.read(recordID);
System.out.print("Record read.\n");
}
catch(UniFileException ev) {
System.out.print(ev.getMessage() + "\n");
System.out.print("Failed to read the test record.\n");
System.exit(0);
}
//Create a dynamic array from the record we've just read in
dynArray = new UniDynArray(record);
//Set the number of fields in this dynamic array
dynArraySize = dynArray.dcount(UniTokens.AT_FM);
//Display each value in this record
for (i=1; (i <= dynArraySize); i++) {
temp = dynArray.extract(i).toString();
System.out.print("Field #" + i + " = "+ temp + "\n");
}
}
}
> //Display each value in this record
> for (i=1; (i <= dynArraySize); i++) {
what happens if you try for(i=0 ?
I ran the java program I referenced in my earlier in my original post (with
the exception of the change you requested, starting at field 0) on both
Windows and Linux platforms. I found that the program running under Windows
does not combine the fields into one. Below is the output of the program.
By the way both Windows and Linux are using the same version of Java:
java version "1.4.1"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.
Java HotSpot(TM) Client VM (build 1.4.1-b21, mixed mode)
Windows:
C:\java\testing>java Test
Connected.
File opened.
Record read.
Number of fields in this record = 10
Field #0 =
Field #1 = A
Field #2 = B
Field #3 = C
Field #4 = D
Field #5 = E
Field #6 = F
Field #7 = G
Field #8 = H
Field #9 = I
Field #10 = J
Linux:
#java Test
Connected.
File opened.
Record read.
Number of fields in this record = 1
Field #0 =
Field #1 = A?B?C?D?E?F?G?H?I?J
<pol...@mamsi.com> wrote in message
news:44a0c627.03040...@posting.google.com...