# jRCS Client API reference
Updated: 2/1/2021, 3:17:10 AM
Created: 2/1/2021, 3:17:10 AM
Last Updated By: Peter Falson
Read Time: 8 minute(s)
# Logging into a jBASE account
public void Open(string hostName, int portNumber, string userName, string password, string account);
Class: JConnection
Return type: void
Throws: JException;
Java:
// Log in to jBASE
jc = new JConnection();
jc.open(hostName, JConstants.JRCS_PORT, username, password, "");
2
3
4
C#:
// Log in to jBASE
JConnection jc = new JConnection
jc.Open(ipAddress, JConnection.JRCS_PORT, username, password, "");
2
3
4
# Calling jBC subroutines
public void Call(string subName, string[] parms);
public void Call(string subName);
public void Call(string subName, JDynArray[] parms);
2
3
Class: JConnection
Return type: void
Throws: JException;
Java:
// Call a BASIC subroutine with two arguments
JDynArray[] jargs = new JDynArray[2];
jargs[0] = new JDynArray();
jargs[1] = new JDynArray();
jc.call(“exampleSub”, jArgs);
System.out.println(jargs[0]);
System.out.println(jargs[1]);
2
3
4
5
6
7
8
C#:
// Call a BASIC subroutine with two arguments
JDynArray[] Params = new JDynArray[7];
Params[0] = new JDynArray();
Params[1] = new JDynArray();
Conn.Call("examplesub", Params);
string result = "arg1 = " + Params[0].ToString() + Environment.NewLine + "arg2 = " + Params[1].ToString();
2
3
4
5
6
7
# Opening a jBASE file
A jRCS Connection must have been opened prior to opening a file.
public JFile OpenFile(string fileName);
Class: JConnection
Return type: JFile
Throws: JException;
Java:
//Open a jBASE file
JFile testFile = jc.OpenFile("TestFile");
2
3
C#:
//Open jBASE file
JFile testFile = Conn.OpenFile("TestFile");
2
3
# jBASE files operations
A jBASE file must have been opened prior to carrying out any of these file operations.
These are some of the methods defined in interface JFile,
public JDynArray Read(string key, bool locked, bool wait);
public JDynArray Read(string key, bool locked);
public JDynArray Read(string key);
public void Write(string key, JDynArray data);
public void Write(string key, JDynArray data, bool unlock);
2
3
4
5
Class: JFile
Return type: JDynArray
Throws: JException
Java:
// Read a record from an opened file
JDynArray rec = testFile.read(id, false, false);
2
3
4
C#:
// Read a record from an opened file
JDynArray jDynArray = testFile.Read(RecId, false, false);
2
3
Class: JFile
Return type: JDynArray
Throws: JException
jRCS record locking will wait indefinitely for a lock; it is recommended to use the "wait" function only on records that are expected to be available. Alternatively, you can read without a wait, and catch the exception thrown to check for a lock.
Java:
// Read a record from an opened file with locking, wait (ReadU)
JDynArray rec = testFile.read(id, true, true);
2
3
C#:
// Read a record from an opened file with locking, no wait (ReadU)
JDynArray jDynArray = testFile.Read(RecId, true, false);
2
3
Class: JFile
Return type: void
Throws: JException;
Java:
// Write a record to a previously opened file, releasing the lock
testFile.write(id,rec);
2
3
C#:
// Write a record to a previously opened file, releasing the lock
testFile.Write(RecId, jDynArray, true);
2
3
Class: JFile
Return type: void
Throws: JException;
Java:
// Write a record to a previously opened file, preserving the lock (WriteU)
testFile.write(id,rec, false);
2
3
C#:
// Write a record to a previously opened file, preserving the lock (WriteU)
testFile.Write(RecId, jDynArray, false);
2
3
# Executing a jBASE command
public JExecuteResults Execute(string command, JExecFlags flags);
public enum JExecFlags
{
EXEC_DEFAULT = 0,
EXEC_GET_CAPTURE = 1,
EXEC_GET_RETURNSTRING = 2,
EXEC_GET_RETURNLIST = 4
}
2
3
4
5
6
7
8
Class: JConnection
Return type: JExecuteResults
Throws: JException;
Java:
// Execute a jBASE command
JExecuteResults res;
int flags = 1;
String command = "jshow -c jrcssub";
res = jc.execute(command, flags); // This is the equivalent of JExecFlags.EXEC_GET_CAPTURE
String result = res.getCaptureString();
2
3
4
5
6
7
C#:
// Execute a jBASE command
private const JExecFlags Flags = JExecFlags.EXEC_GET_CAPTURE | JExecFlags.EXEC_GET_RETURNLIST | JExecFlags.EXEC_GET_RETURNSTRING;
string strCommand = "jdiag -dvL";
JExecuteResults Results = Conn.Execute(strCommand, Flags);
string strTemp = Results.CaptureString;
2
3
4
5
6
# Obtaining the current jBASE internal date
public int Date { get; }
public string OConv(string source, string code);
2
Class: JConnection
Return type: int
Throws: JException;
Java:
// Obtain the date from jBASE in internal format and convert to external format
int thisDate = jc.getDate();
String currentDate = jc.oConv(String.valueOf(thisDate), "D4");
2
3
4
C#:
// Obtain the date from jBASE in internal format and convert to external format
int thisDate = jc.Date;
string currentDate = jc.OConv(thisDate.ToString(), "D4");
2
3
4
# Executing jQL queries
public JExecuteResults ExecuteAndStore(string command, JExecFlags flags);
public JExecuteResults ExecuteAndStore(string command, JExecFlags flags, JSelectList passList);
public JExecuteResults ExecuteAndStore(string command, JExecFlags flags, JSelectList passList, int blockSize);
2
3
Class: JConnection
Return type: JExecuteResults
Throws: JException;
Java:
// Execute a jQL query
static char esc = '\u001B';
static char AM = JConstants.AM;
static JExecuteResults res;
static JCapture cap;
int flags = 7;
String blk = null;
String pageBrk = String.format("{0}[H{0}[J", esc);
String report = "";
command = "SORT CUSTOMER BY CUS.NAME CUS.NAME CUS.CITY CUS.PHONE (N";
JSelectList jsl = null;
res = jc.executeAndStore(command, flags, jsl, blockSize);
if (res instanceof JExecuteResults)
{
cap = res.getCapture();
if (cap instanceof JCapture)
{
while (!cap.atEnd())
{
blk = cap.nextBlock();
blk = blk.replace(AM, '\n');
blk = blk.replace(pageBrk, System.lineSeparator() + System.lineSeparator());
report = report + blk;
}
}
}
System.out.println(report);
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
C#:
// Execute a jQL query
private const JExecFlags Flags = JExecFlags.EXEC_GET_CAPTURE | JExecFlags.EXEC_GET_RETURNLIST | JExecFlags.EXEC_GET_RETURNSTRING;
JExecuteResults Result = null;
JCapture Cap = null;
string Blk = null;
string PageBrk = string.Format("{0}[H{0}[J", (char)27);
string Report = "";
string Command = "SORT CUSTOMER BY CUS.NAME CUS.NAME CUS.CITY CUS.PHONE (N";
JSelectList Dummy = null;
Result = jc.ExecuteAndStore(Command, Flags, Dummy, 2048);
if (Result is JExecuteResults)
{
Cap = Result.Capture;
if (Cap is JCapture)
{
while (!(Cap.AtEnd))
{
Blk = Cap.NextBlock();
Blk = Blk.Replace(JDynArray.AM.ToString(), "\n");
Blk = Blk.Replace(PageBrk, Environment.NewLine + Environment.NewLine);
Report = Report + Blk;
}
}
}
Console.WriteLine(Report);
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# Get the current jBASE version
public int Time { get; }
public string Locale { get; }
public JDynArray jBaseVersion { get; }
public int Date { get; }
public string CodePage { get; }
public int Port { get; }
2
3
4
5
6
Class: JConnection
Return type: various
Throws: JException;
Java:
// Get jBASE version
JDynArray jbaseVersion = jc.getjBaseVersion();
String versionNumber = jbaseVersion.extract(1) + "." + jbaseVersion.extract(2);
System.out.println("Current jBASE version is " + versionNumber + "!");
2
3
4
5
// Get jBASE version
JDynArray jbaseVersion = jc.jBaseVersion;
string versionNumber = jbaseVersion.Extract(1) + "." + jbaseVersion.Extract(2);
Console.WriteLine(value: "Current jBASE version is " + versionNumber + "!");
2
3
4
# jDynArray manipulation
public void Assign(JDynArray src);
public void Assign(string src);
public int Count(char delim);
public int Count(string delim);
public int DCount(string delim);
public int DCount(char delim);
public void Delete(int amc, int vmc, int svmc);
public void Delete(int amc, int vmc);
public void Delete(int amc);
public string Extract(int amc);
public string Extract(int amc, int vmc);
public string Extract(int amc, int vmc, int svmc);
public JDynArray ExtractDA(int amc, int vmc);
public JDynArray ExtractDA(int amc, int vmc, int svmc);
public JDynArray ExtractDA(int amc);
public string Field(char delim, int fieldNo);
public string Field(string delim, int fieldNo);
public void Insert(string data, int amc, int vmc);
public void Insert(string data, int amc);
public void Insert(JDynArray data, int amc);
public void Insert(JDynArray data, int amc, int vmc);
public void Insert(JDynArray data, int amc, int vmc, int svmc);
public void Insert(string data, int amc, int vmc, int svmc);
public void InsertDA(JDynArray data, int amc);
public void InsertDA(JDynArray data, int amc, int vmc, int svmc);
public void InsertDA(JDynArray data, int amc, int vmc);
public int Locate(string searchStr, int amc, int vmc, string order, int start);
public int Locate(string searchStr, int amc, string order, int start);
public int Locate(string searchStr, int amc, int vmc, string order);
public int Locate(string searchStr, int amc, string order);
public int Locate(string searchStr);
public int Locate(string searchStr, string order);
public int LocateIgnoreCase(string searchStr);
public int LocateIgnoreCase(string searchStr, string order);
public int LocateIgnoreCase(string searchStr, int amc, string order);
public int LocateIgnoreCase(string searchStr, int amc, int vmc, string order);
public int LocateIgnoreCase(string searchStr, int amc, string order, int start);
public int LocateIgnoreCase(string searchStr, int amc, int vmc, string order, int start);
public void Replace(string data, int amc);
public void Replace(string data, int amc, int vmc);
public void Replace(string data, int amc, int vmc, int svmc);
public void Replace(JDynArray data, int amc);
public void Replace(JDynArray data, int amc, int vmc);
public void Replace(JDynArray data, int amc, int vmc, int svmc);
public void ReplaceDA(JDynArray data, int amc);
public void ReplaceDA(JDynArray data, int amc, int vmc);
public void ReplaceDA(JDynArray data, int amc, int vmc, int svmc);
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
Class: JDynarray
Return type: various
Throws: JException;
Java:
// Sample jDynArray instructions
JDynArray dynTest = new JDynArray();
dynTest.insert("One", 1);
dynTest.replace("Two", 2);
JDynArray dynTest2 = new JDynArray("Three");
dynTest.insertDA(dynTest2, 3);
dynTest.insert("This is a long string of text", -1);
String tempTest = dynTest.extract(3);
int locVar = dynTest.locate("Three", "");
String locVarContent = dynTest.extract(locVar);
String locVarContentAgain = dynTest.field(JConstants.AM, locVar);
2
3
4
5
6
7
8
9
10
11
12
C#:
// Sample jDynArray instructions
JDynArray dynTest = new JDynArray();
dynTest.Insert("One", 1);
dynTest.Replace("Two", 2);
JDynArray dynTest2 = new JDynArray("Three");
dynTest.InsertDA(dynTest2, 3);
dynTest.Insert("This is a string of text", -1);
string tempTest = dynTest.Extract(3);
int locVar = dynTest.Locate("Three", "");
string locVarContent = dynTest.Extract(locVar);
string locVarContentAgain = dynTest.Field(JDynArray.AM, locVar);
2
3
4
5
6
7
8
9
10
11
12
# Note
The behaviour of JDynArray in jRCS and the jRCS client is not guaranteed to be the same as the behaviour of strings in BASIC.
Here is the Javadoc header for the 3-parameter Locate function:
/**
* Searches for a string in all values within a given attribute of the dynamic array.
* The values are in the specified sort order.
*
* @param searchStr String to look for
* @param amc Attribute number
* @param order Order of values, interpreted as follows:
* <p> "AL" - ascending, left-justified
* <p> "AR" - ascending, right-justified
* <p> "AN" - ascending, numeric
* <p> "DL" - descending, left-justified
* <p> "DR" - descending, right-justified
* <p> "DN" - descending, numeric
* <p> "" - no order
* @return Positive index of matching value or negative index of insertion
* point if a match is not found. If order is specified as a blank string, the
* function always returns -1 to indicate that the string was not found.
* @throws JException
*/
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19