Returns a zero-indexed array which contains nTimes the given item.
Code...Code...
item:=%0;
nTimes:=%1;
itemType:=VarType(item);
if itemType=258 then itemType:=8; // VarArrayCreate cannot handle UnicodeString
result:=VarArrayCreate(0,nTimes-1,itemType);
for i:=0 to nTimes-1 do
result[i]:=item;
Example...Example...RepeatItem("abc", 5); // generates an array of type OleString containing ("abc", "abc", "abc", "abc", "abc")
RepeatItem(3.14, 2); // generates an array of type Double containing (3.14, 3.14)
Returns a zero-indexed string array containing the strings
baseString + IntToStr(suffixStart), ..., baseString + IntToStr(suffixEnd)
Code...Code...
baseString:=%0;
suffixStart:=%1;
suffixEnd:=%2;
highBound:=suffixEnd - suffixStart;
result:=VarArrayCreate(0, highBound, 8);
for i:=0 to highBound do
result[i]:=baseString + IntToStr(i+suffixStart);
Example...Example...
SuffixArray("prod", 3, 6); // generates an array of type OleString containing ("prod3", "prod4", "prod5", "prod6")
Returnes a new array containing all elements of array1 and array2.
If the two arrays have different types, null is returned.
Code...Code...
result:=null;
array1:=%0;
array2:=%1;
if(IsNull(array1) AND NOT IsNull(array2)) then
result:=array2
else if(NOT IsNull(array1) AND IsNull(array2)) then
result:=array1
else if (not VarIsArray(array1)) OR (not varIsArray(array2)) then
ShowMessage("At least one of the variable is no array!")
else if(NOT IsNull(array1) AND NOT IsNull(array2)) then
begin
type1:=VarType(array1);
type2:=VarType(array2);
if(type1 <> type2) then
ShowMessage("Array types do not match.")
else
begin
low1:=VarArrayLowBound(array1,1);
high1:=VarArrayHighBound(array1,1);
low2:=VarArrayLowBound(array2,1);
high2:=VarArrayHighBound(array2,1);
newHighBound := 1 + high1 + high2 - low1 - low2;
if (high1-low1 >= 0 and not IsNull(array1[0])) then
baseType:=VarType(array1[0])
else if(high2-low2 >= 0 and not IsNull(array2[0])) then
baseType:=VarType(array2[0])
else
baseType:=8;
result:=VarArrayCreate(0, newHighBound, baseType);
for i:=low1 to high1 do
result[i]:=array1[i];
for i:=low2 to high2 do
result[high1+i+1]:=array2[i];
end;
end;
Example...Example...
a:=VarArrayOf("a", "b", "c");
b:=VarArrayOf("y", "z");
array:=JoinArrays(a, b); // generates an array of type OleString containing ("a", "b", "c", "y", "z")
Returns a three letter string describing the day of the week for the given timeStamp (in DateTime format).
Code...Code...
DayNames:=VarArrayCreate(0,8,8);
DayNames[0]:="Mon";
DayNames[1]:="Tue";
DayNames[2]:="Wed";
DayNames[3]:="Thu";
DayNames[4]:="Fri";
DayNames[5]:="Sat";
DayNames[6]:="Sun";
timeStamp := %0;
weekDay := CIP_ExtractDayOfTheWeek(timeStamp);
result := DayNames[weekDay-1];
Example...Example...
GetDayOfWeekString(41632) // returns "Tue" since 24.12.2013 is a Tuesday
Returns a string containing all the elements of the given array, separated by the given separator.
Code...Code...
array:=%0;
separator:=%1;
nHigh:=VarArrayHighBound(array,1);
nLow:=VarArrayLowBound(array,1);
n:=nHigh-nLow;
result:=array[nLow];
if n>1 then
begin
result:=array[nLow];
for i:=(nLow+1) to nHigh do
result := result + separator + array[i];
end;
Example...Example...
a:=VarArrayOf("a", "b", "c");
ArrayToJoinedString(a, "-"); // generates the string "a-b-c"
Asks the user whether he or she wants to clear the table of the current object and proceeds after confirmation.
Code...Code...
nRec:=cip_sql("", "SELECT COUNT(*) FROM " + Get_Table_Of_Object());
result:=MessageDlg("Are you sure you want to delete all " + vartostr(nRec) + " records?", 3, 3, 0);
if result=6 then
cip_sql("", "delete FROM " + Get_Table_Of_Object());
Example...Example...
This function can be used in any object simply by calling it in a user script.
ClearTable();