Browse Source

* Delphi compatibility: ListIndexErrorMsg

Michaël Van Canneyt 1 year ago
parent
commit
680c096ac5
2 changed files with 26 additions and 1 deletions
  1. 3 1
      rtl/objpas/sysutils/sysutilh.inc
  2. 23 0
      rtl/objpas/sysutils/sysutils.inc

+ 3 - 1
rtl/objpas/sysutils/sysutilh.inc

@@ -272,7 +272,9 @@ type
    procedure Abort;
    procedure Abort;
    procedure OutOfMemoryError;
    procedure OutOfMemoryError;
    procedure ListIndexError(aIndex,aMax: Integer; aObj: TObject);
    procedure ListIndexError(aIndex,aMax: Integer; aObj: TObject);
-
+   function ListIndexErrorMsg(aIndex, aMaxIndex: SizeInt; const aListObjName: string): string; overload;
+   function ListIndexErrorMsg(aIndex, aMaxIndex: SizeInt; aListObj: TObject): string; overload;
+    
 Type
 Type
    TBeepHandler = Procedure;
    TBeepHandler = Procedure;
 
 

+ 23 - 0
rtl/objpas/sysutils/sysutils.inc

@@ -650,6 +650,29 @@ begin
   Raise OutOfMemory;
   Raise OutOfMemory;
 end;
 end;
 
 
+function ListIndexErrorMsg(aIndex, aMaxIndex: SizeInt; const aListObjName: string): string; overload;
+
+begin
+  if aMaxIndex<0 then
+    Result:=Format(SListIndexErrorEmptyReason,[aListObjName])
+  else
+    Result:=Format(SListIndexErrorRangeReason,[aListObjName]);
+  Result:=Format(SListIndexError, [aIndex])+Result;
+end;
+
+function ListIndexErrorMsg(AIndex, AMaxIndex: SizeInt; AListObj: TObject): string; overload;
+
+Var
+  aName : string;
+
+begin
+  if Assigned(aListObj) then
+   Result:=aListObj.ClassName
+ else
+   Result:='<Nil>';
+  Result:=ListIndexErrorMsg(aIndex, aMaxIndex, aName);
+end;
+
 procedure ListIndexError(aIndex,aMax: Integer; aObj: TObject);
 procedure ListIndexError(aIndex,aMax: Integer; aObj: TObject);
 
 
 var
 var