faqts : Computers : Programming : Languages : Tse : Search

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

Entry

TSE: String: Check: How to check if a single character can be found in a string?

Nov 7th, 2006 13:16
Knud van Eeden,


----------------------------------------------------------------------
--- Knud van Eeden --- 07 November 2006 - 09:59 pm -------------------

TSE: String: Check: How to check if a single character can be found in 
a string?

---

Method:

Use e.g. the inbuilt function Pos() you check
if the position of the character in the given string
is not zero (than it is found in that string),
otherwise when the position is zero, that character
is not found.

--- cut here: begin --------------------------------------------------

INTEGER PROC FNStringSearchInstrI( STRING containS, STRING searchS )
 RETURN( Pos( searchS, containS ) )
END

INTEGER PROC FNStringCheckInstrFoundB( STRING containS, STRING 
searchS )
 IF ( FNStringSearchInstrI( containS, searchS ) == 0 )
  RETURN( FALSE )
 ENDIF
 RETURN( TRUE )
END

PROC Main()
 Message( FNStringCheckInstrFoundB( "ABCDFG", "C" ) ) // gives TRUE, 
because the "C" can be found in the string
END

<F12> Main()

--- cut here: end ----------------------------------------------------

===

Internet: see also:

---


----------------------------------------------------------------------