Text Functions - Pritesh-Mhatre/amibroker-library GitHub Wiki
Utility functions for amibroker that work on text data. These functions are available in text-util.afl. To use these functions, add following line at the top of your afl:
#include <text-util.afl>
Functions
strSubstring
AmiBroker substring function. Returns a string that is a substring of the text. Implementation of Java substring function in AmiBroker. For more details see javadoc.
Example
result = strSubstring("smiles", 1, 5);
// result will be "mile"
Parameters
Parameter | Type | Description |
---|---|---|
text | string | the text to operate on |
beginIndex | integer | the beginning index (inclusive), index of first character is zero |
endIndex | integer | the ending index (exclusive) |
strFirstN
Amibroker function that returns first N characters of a string.
Example
result = strFirstN("abcdef", 2);
// result will be "ab"
Parameters
Parameter | Type | Description |
---|---|---|
text | string | the text to operate on |
n | integer | number of characters |
strLastN
Amibroker function that returns last N characters of a string.
Example
result = strLastN("BANKNIFTY2010932400PE", 2);
// result will be "PE"
Parameters
Parameter | Type | Description |
---|---|---|
text | string | the text to operate on |
n | integer | number of characters |
strEquals
Amibroker function to find whether two strings are equal (case-sensitive).
Example
result = strEquals("Apple", "Orange");
// result will be false or zero
result = strEquals("Apple", "Apple");
// result will be true or one
Parameters
Parameter | Type | Description |
---|---|---|
a | string | the first string to compare |
b | string | the first string to compare |
strEqualsIgnoreCase
Amibroker function to find whether two strings are equal (case-insensitive).
Example
result = strEqualsIgnoreCase("Apple", "Orange");
// result will be false or zero
result = strEqualsIgnoreCase("APPLE", "apple");
// result will be true or one
Parameters
Parameter | Type | Description |
---|---|---|
a | string | the first string to compare |
b | string | the first string to compare |
strStartsWith
Amibroker function to find whether a string starts with specified prefix.
Example
result = strStartsWith("Apple", "Ora");
// result will be false or zero
result = strStartsWith("Apple", "App");
// result will be true or one
Parameters
Parameter | Type | Description |
---|---|---|
text | string | the string to check |
prefix | string | the prefix |
strEndsWith
Amibroker function to find whether a string ends with specified suffix.
Example
result = strEndsWith("Apple", "ilk");
// result will be false or zero
result = strEndsWith("Apple", "ple");
// result will be true or one
Parameters
Parameter | Type | Description |
---|---|---|
text | string | the string to check |
suffix | string | the suffix |
strIsEmpty
Amibroker function to find whether a string is empty or not. It a string contains only whitespaces, then it is considered as an empty string.
Example
result = strIsEmpty("Apple");
// result will be false or zero
result = strIsEmpty("");
// result will be true or one
result = strIsEmpty(" ");
// result will be true or one
Parameters
Parameter | Type | Description |
---|---|---|
text | string | the string to check |