CompareList()

Syntax

Result = CompareList(List1(), List2() [, Flags])
Description
Compare each elements of the two lists for equality. Recursively compares also contents of structured lists with dynamic elements (such as embedded arrays, lists or maps). The two lists are considered the equal if they have the same type and size and if each pair of elements is equal.

Parameters

List1(), List2() The lists to compare.
Flags (optional) Can be a combination of the following values:
  #PB_String_CaseSensitive : String comparison is case sensitive (a=a). (default)
  #PB_String_NoCase        : String comparison is case insensitive(a=A).
  #PB_Memory_FollowPointers: If a structure element is a pointer that is not 0, recursively compare the pointer target. 
                              The default is to compare only the pointer value itself. See remarks below for details.

Return value

Returns nonzero if both lists are the same or zero if they differ.

Remarks

The #PB_Memory_FollowPointers option is for advanced users and requires special care to avoid crashes. If this option is used then all pointer values must point to valid and initialized memory or have the value 0. It is also not allowed to have loops in the pointed elements (a chain of pointers that refers back to itself).

Example

  NewList A$()
  AddElement(A$()) : A$() = "Jim"
  AddElement(A$()) : A$() = "John"
  AddElement(A$()) : A$() = "Jack"
  
  NewList B$()
  AddElement(B$()) : B$() = "JIM"  ; Case differs
  AddElement(B$()) : B$() = "John"
  AddElement(B$()) : B$() = "Jack"
  
  Debug CompareList(A$(), B$())                     ; Not equal
  Debug CompareList(A$(), B$(), #PB_String_NoCase)  ; Equal

See Also

CompareArray(), CompareMap()

Supported OS

All

<- ClearList() - List Index - CopyList() ->