fnStringCompareAsBase Subroutine

public pure subroutine fnStringCompareAsBase(firstString, secondString, base, output, error)

Compare two strings as integer strings of a numbering system with the radix that is defined by the value of the argument base. There isn't a maximum length for the strings. Nonetheless, the strings can't be empty.

This subroutine support numbering system with radix from 2 to 36. This subroutine evaluates both, negative and positive values.

This subroutine ignores leading and trailing whitespaces.

This subroutine disregards leading zeroes.

Error code:
0 - no error
1 - empty firstString
2 - empty secondString
3 - bad format firstString
4 - bad format secondString
5 - base < 2 or base > 36

Arguments

Type IntentOptional AttributesName
character(len=*), intent(in) :: firstString

A string to be compared to the string secondString.

character(len=*), intent(in) :: secondString

A string to be compared to the string firstString.

integer(kind=k_int32), intent(in) :: base

An int32 value that define the radix.

integer(kind=k_int32), intent(out) :: output

An int32 value of 1 if the firstString is larger than the secondString, 0 if they are both equal, or -1 if the firstString is smaller than the secondString. This value may not be a correct value if an error has occurred during the comparison process.

integer(kind=k_int32), intent(out) :: error

An int32 value of 0 if no error was encountered. Otherwise, a true error code.