Skip to content

StartsWith EndsWith

Dionisis Pettas edited this page Dec 4, 2017 · 1 revision
  Program Main 
    Use fString 
    Implicit None 
    Type(Str) :: MyStr
    Integer   :: Num
    
    !<><><><><><><><><><><><><><><><><><><><><><><><><><><><><>
    !StartsWith : True if the String starts with the substring 
    !EndsWith   : True if the String ends   with the substring 
    !<><><><><><><><><><><><><><><><><><><><><><><><><><><><><>

    Print*, 'Test 1: '
    Print*,''
    MyStr = "Datafile.csv"

    Print*, MyStr%StartsWith("Data") !True
    Print*, MyStr%StartsWith("Dat" ) !True
    Print*, MyStr%StartsWith("dat" ) !False

    !<><><><><><><><><><><><><><><><><><><><><><><><><><><><><>
    ! Check the extension of the file
    !<><><><><><><><><><><><><><><><><><><><><><><><><><><><><>

    Print*, 'Test 2: '
    Print*,''

    Print*, MyStr%EndsWith(".csv") !True
    Print*, MyStr%EndsWith("v"   ) !True
    Print*, MyStr%EndsWith("Dat" ) !False

  End Program Main 

Clone this wiki locally