Detecting the first char in a string.
Posted on 2003-11-27
I'm wanting to detect the first character in a string and do different things depending on what it is.
For instance, if the first character is a "/" then I want to do one thing, if it's anything else then do another thing. I actually have my program working, the problem is it doesn't do it if it's ONLY the first string. If a "/" is in the string anywhwere, it still does the string procedure. Here's my code (found on EE btw):
i := Pos('/',MyString);
if i <> 0 then begin
LogMemo1.Lines.Add('This command started with a slash!);
end else begin
LogMemo1.Lines.Add('This command does not begin with a slash.);
Like I said, if it has a slash anywhere in it, it will process the first statement. Please help.