Link to home
Start Free TrialLog in
Avatar of eNarc
eNarcFlag for United Kingdom of Great Britain and Northern Ireland

asked on

Return a Char at position

Hi, I'd like to know how I could get a Char from a string at a length


for example.

string:='Happy days';

function >>> GetChar(string,3);

results >>> p

then I can move forward.

if GetChar(string,3) = 'p' then
//..
else
//..
ASKER CERTIFIED SOLUTION
Avatar of cyberkiwi
cyberkiwi
Flag of New Zealand image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
A more complete example

var
 s: string;
begin
 s := 'Happy days';
 if (Length(s) >= 3) and (s[3]='p') then

Test for length first to prevent index out of bounds.  And note that the Delphi string index starts at 1.
Avatar of eNarc

ASKER

oh for!!!! I had a blond moment here! I totally knew, I totally knew this, wow!! Thankyou, HighFive!