routine is_lower( the_string : String ) : Integer
Const
first_lower 97
last_lower 122
upper_to_lower 32
Var
the_char : String
result : Integer
Begin
the_char = leftstr( the_string , 1 )
if( asc( the_char ) <= last_lower AND asc( the_char ) >= first_lower ) then
result = true
else
result = false
endif
return result
End
routine is_upper( the_string : String ) : Integer
Const
first_upper 65
last_upper 90
upper_to_lower 32
Var
the_char : String
result : Integer
Begin
the_char = leftstr( the_string , 1 )
if( asc( the_char ) <= last_upper AND asc( the_char ) >= first_upper ) then
result = true
else
result = false
endif
return result
End
routine upper( the_string : String ) : String
--Return upper case version of the_string
Const
first_lower 97
last_lower 122
upper_to_lower 32
Var
i : Integer
result , check_char : String
Begin
result = ''
for i = 1 to len( the_string ) do
check_char = substr( the_string , i , 1 )
if( is_lower( check_char ) ) then
check_char = chr( asc( check_char ) - 32 )
endif
result = result + check_char
endfor
return result
End
routine lower( the_string : String ) : String
--Return upper case version of the_string
Const
first_lower 97
last_lower 122
upper_to_lower 32
Var
i : Integer
result , check_char : String
Begin
result = ''
for i = 1 to len( the_string ) do
check_char = substr( the_string , i , 1 )
if( is_upper( check_char ) ) then
check_char = chr( asc( check_char ) + 32 )
endif
result = result + check_char
endfor
return result
End
No comments:
Post a Comment