Strings

Hi, i have a routine that goes like this,

//---
S:=list.Strings[I];
If (Pos('astring', S) = 0) Then
do something
//---

How can i tell if the pos ('astring') is uppercase or lowersase in  S?
herd_boneAsked:
Who is Participating?
 
esoftbgConnect With a Mentor Commented:
I think it is not necessary:

if ( ( Pos('ASSTRING', UpperCase(S))=0) or ( Pos('astring', LowerCase(S))=0)) then

it is enough:

if  ( Pos('ASSTRING', UpperCase(S))=0) then

let see an example:

var
  BUpp:  Boolean;
  BLow:  Boolean;
begin
  BUpp := ( Pos('KYLIE', UpperCase(Kylie Minogue))=0);  // BUpp := False;
  BLow := ( Pos('kylie', LowerCase(Kylie Minogue))=0);  // Blow := False;
end;

It is not necessary the check both of variants because they are equal.
0
 
Mohammed NasmanSoftware DeveloperCommented:
Try

  if Pos('ASSTRING', UpperCase(S))=0) then

0
 
herd_boneAuthor Commented:
thanks, will that still exclude lowercase strings, i need to exclude both in my routine.
without doing this for example for every string:
 if Pos('ASSTRING', UpperCase(S))=0) then
 if Pos('astring', lowerCase(S))=0) then
 
0
 
Jase-CoderCommented:
try doing

if( ( Pos('ASSTRING', UpperCase(S))=0) or ( Pos('astring', lowerCase(S))=0)) then
0
 
Wim ten BrinkSelf-employed developerCommented:
And what's wrong with:

 if Pos(UpperCase('AsString'), UpperCase(S))=0) then

Hmmm???
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.