1) Install the R-Math plug-in
2) Run your loop for / define your string, e.g. MyString="a,b,c,d";
3) Prepare this string for correct format in R:
StStr="<DQ>";RplStr=StStr+","+StStr;
MyStr = StStr + StrReplace(MyString,",",RplStr)+StStr;
RMathProcedure("RString<-c("+MyStr+")");
Once in R, you can manipulate this string-array any way you like (see below),
and return it, or some element, back to AB.
As I've written in the R-Math manual, and repeated a few times before, if there
are things that AFL cannot do, be it this or matrix calc, or whatever, 99% of
them can now be achieved via R.
PS
More details, see for example Lam (2007), An Introduction to R:
x <- c("a","b","c")
mychar1 <- "This is a test"
mychar2 <- "This is another test"
charvector <- c("a", "b", "c", "test")
The function nchar returns the length of a character object, for example:
nchar(mychar1)
[1] 15
nchar(charvector)
[1] 1 1 1 4
The function substring returns a substring of a character object. For example:
x <- c("Gose", "Longhow", "David")
substring(x,first=2,last=4)
[1] "ose" "ong" "avi"
The function paste will paste two or more character objects. For example, to
create a
character vector with: "number.1", "number.2", ...,"number.10" proceed as
follows:
paste("number",1:10, sep=".")
[1] "number.1" "number.2" "number.3" "number.4"
[5] "number.5" "number.6" "number.7" "number.8"
[9] "number.9" "number.10"
The argument sep is used to specify the separating symbol between the two
character
objects.
paste("number",1:10, sep="-")
[1] "number-1" "number-2" "number-3" "number-4"
[5] "number-5" "number-6" "number-7" "number-8"
[9] "number-9" "number-10"
Use sep="" for no space between the character objects.
--- In [email protected], "Conrad Joach" <consolejo...@...> wrote:
>
> Looking for something akin to a Split() function that is common in most
> languages today.
>
> So for a string:
>
> "a,b,c,d"
>
> It would return an array of length 4, with the string "a", "b", "c", "d".
>
> I don't see anything like this in AFL, has anyone written one with the built
> in string functions that do exist?
>