zfill Interface

public interface zfill

Adds zeros at the beginning of a string.

Syntax

 newStr = zfill(str, l)

Where:

  • str: String that the user wants to fill with leading zeros..
  • l: Integer indicating the length of the resuling string.

If l is greater than the length of str, it returns a string of length l with str padded with zeros at the beginning. If l is lower or equal to the length of str, it returns str.

Example

The following program fills a string with leading zeros:

 PROGRAM zfillExample
    USE FU_Strings, ONLY: zfill
    IMPLICIT NONE
    WRITE(*,*) zfill('myStr', 12)
 END PROGRAM zfillExample

Contents


Module Procedures

private pure function zfill_i8(str, l) result(res)

Arguments

Type IntentOptional Attributes Name
character(len=*), intent(in) :: str

String that the user wants to fill with leading zeros.

integer(kind=i8), intent(in) :: l

Integer indicating the length of the resuling string.

Return Value character(len=MAX)

If l is greater than the length of str, it returns a string of length l with str padded with zeros at the beginning. If l is lower or equal to the length of str, it returns str.

private pure function zfill_i16(str, l) result(res)

Arguments

Type IntentOptional Attributes Name
character(len=*), intent(in) :: str

String that the user wants to fill with leading zeros.

integer(kind=i16), intent(in) :: l

Integer indicating the length of the resuling string.

Return Value character(len=MAX)

If l is greater than the length of str, it returns a string of length l with str padded with zeros at the beginning. If l is lower or equal to the length of str, it returns str.

private pure function zfill_i32(str, l) result(res)

Arguments

Type IntentOptional Attributes Name
character(len=*), intent(in) :: str

String that the user wants to fill with leading zeros.

integer(kind=i32), intent(in) :: l

Integer indicating the length of the resuling string.

Return Value character(len=MAX)

If l is greater than the length of str, it returns a string of length l with str padded with zeros at the beginning. If l is lower or equal to the length of str, it returns str.

private pure function zfill_i64(str, l) result(res)

Arguments

Type IntentOptional Attributes Name
character(len=*), intent(in) :: str

String that the user wants to fill with leading zeros.

integer(kind=i64), intent(in) :: l

Integer indicating the length of the resuling string.

Return Value character(len=MAX)

If l is greater than the length of str, it returns a string of length l with str padded with zeros at the beginning. If l is lower or equal to the length of str, it returns str.