After playing with php and scar a bit more, I realised that (esecially) when using databases to create pages for scar to then interpret, it became pretty hard to be able to get those values into scar, thus StrToArray was made.
SCAR Code:
Function StrToArray(Var stra: array of String; str,del: String): Boolean;
Var
sx,i: Integer;
Begin
If(Not(Right(str,Length(del)) = del)) Then
str:= str+del;
Repeat
Begin
sx:= Pos(del,str);
SetArrayLength(stra,GetArrayLength(stra)+1);
stra[i]:= Copy(str,1,sx-1);
Delete(str,1,sx+(Length(del)-1));
i:=i+1;
End
Until(str = '')
Result:=True;
End;
It works by finding where the first delmiter is and copying from the start until it gets to the delimiter and puts it into the array. It then deletes the part it has copied and the delimiter before looping again until the string (str) is empty. It makes the array's length 1 larger everytime it loops so there's no out of range errors.
You would then use it as
SCAR Code:
StrToArray(stringArray,String,Delimiter);
or
SCAR Code:
StrToArray(Scripts,'hello. moo. carrot','. ');
With (in the 1st) stringArray being the array it puts all the values in, String being the string it takes the text from before converting it and Delimiter being the characters that separate each different piece of text (normally ', ' or ',').
In the 2nd case, it would assign 'hello' to stringArray[0], 'moo' to stringArray[1] and 'carrot' to stringArray[2].
Feel free to post improvements/questions or anything else.