Skip to content

Commit

Permalink
bug fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
teverett committed Sep 8, 2020
1 parent b063b53 commit f72a4fb
Showing 1 changed file with 68 additions and 67 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,77 +20,78 @@
* @author tome
*/
public class StringFunctions {
/**
* String concat
*/
public static String concat(Value v1, Value v2) {
if ((null != v1) && (null != v2)) {
/*
* enclose the result to signal to the ctor of Value that this is a string literal, not a variable name
*/
return "\"" + v2.getAsString() + v1.getAsString() + "\"";
}
return null;
}
/**
* String concat
*/
public static String concat(Value v1, Value v2) {
if ((null != v1) && (null != v2)) {
/*
* enclose the result to signal to the ctor of Value that this is a string literal, not a
* variable name
*/
return "\"" + v2.getAsString() + v1.getAsString() + "\"";
}
return null;
}

/**
* LEFT$(String, start, len)
*/
public static String LEFT(Value len, Value str) {
if ((null != str) & (null != len)) {
return "\"" + str.getAsString().substring(0, len.getInteger()) + "\"";
}
return null;
}
/**
* LEFT$(String, start, len)
*/
public static String LEFT(Value len, Value str) {
if ((null != str) && (null != len)) {
return "\"" + str.getAsString().substring(0, len.getInteger()) + "\"";
}
return null;
}

/**
* string length
*/
public static Integer LEN(Value v) {
if (null != v) {
return v.getAsString().length();
}
return null;
}
/**
* string length
*/
public static Integer LEN(Value v) {
if (null != v) {
return v.getAsString().length();
}
return null;
}

/**
* MID$(String, start, len)
*/
public static String MID(Value len, Value start, Value str) {
if ((null != str) && ((null != start) & (null != len))) {
return "\"" + str.getAsString().substring(start.getInteger(), len.getInteger() + start.getInteger()) + "\"";
}
return null;
}
/**
* MID$(String, start, len)
*/
public static String MID(Value len, Value start, Value str) {
if ((null != str) && ((null != start) & (null != len))) {
return "\"" + str.getAsString().substring(start.getInteger(), len.getInteger() + start.getInteger()) + "\"";
}
return null;
}

/**
* RIGHT$(String, start, len)
*/
public static String RIGHT(Value len, Value str) {
if ((null != str) & (null != len)) {
final int beginIndex = str.getAsString().length() - len.getInteger();
return "\"" + str.getAsString().substring(beginIndex, str.getAsString().length()) + "\"";
}
return null;
}
/**
* RIGHT$(String, start, len)
*/
public static String RIGHT(Value len, Value str) {
if ((null != str) && (null != len)) {
final int beginIndex = str.getAsString().length() - len.getInteger();
return "\"" + str.getAsString().substring(beginIndex, str.getAsString().length()) + "\"";
}
return null;
}

/**
* STR$
*/
public static String STR(Value v) {
if (null != v) {
return "\"" + v.getAsString() + "\"";
}
return null;
}
/**
* STR$
*/
public static String STR(Value v) {
if (null != v) {
return "\"" + v.getAsString() + "\"";
}
return null;
}

/**
* VAL
*/
public static String VAL(Value v) {
if (null != v) {
return "\"" + v.getInteger() + "\"";
}
return null;
}
/**
* VAL
*/
public static String VAL(Value v) {
if (null != v) {
return "\"" + v.getInteger() + "\"";
}
return null;
}
}

0 comments on commit f72a4fb

Please sign in to comment.