View Full Version : Delphi Issues

09-26-2011, 01:00 PM
I am making a log on system in delphi as part of a larger database project and ive run into a bit of an issue.
I have made a log on system which recalls information from a text file into a memo box and compares information from 2 edit boxes on forename and surname with the contense of the memo box.
Here is where my problem lies, I have absolutely no idea how to compare the 2 fields. So far I have recalled all the data from the text file to the memo but can't sort it or search it. Later on I will need to use a similar piece of code for my database so any information is much appreciated. Could someone please post some sample code or at least give me an idea of what to do.


09-29-2011, 04:07 AM
I don't do Delphi, but does it have an analog to C's strcmp() or stricmp()?

The first is a case-sensitive string compare, the second is a case-insensitive string compare, I think you could compare the two fields with a similar function in Delphi.

Here, look at the first two functions listed on this page, they seem to be what you need:

09-30-2011, 12:57 PM
Cheers for the link but I need someone who knows delphi inside out to full explain what to do. I've been researching it for weeks and I still cant find anything thats any help, and no it doesnt have any script like that (or not that ive seen anyway) Thanks all!

By the way any pascal responses will be useful aswell

09-30-2011, 08:46 PM
oops, double-posted, see below...

09-30-2011, 09:20 PM
The example they give seems pretty straightforward, pass the two strings you're interested in to this procedure and 'result' will be 0 if they match and something else if they don't (in this case Tform1 is just an example class that uses CompareStrings as a method):

procedure TForm1.CompareStrings(const string1, string2: string);
result : Integer;

//uncomment if case-sensitive:
result := AnsiCompareStr(string1, string2);

//uncomment to ignore case:
// result := AnsiCompareText(string1, string2);


...and no it doesnt have any script like that...

Well it won't, until you edit it in. Have you tried compiling it 'as-is' to make sure you have all your unit-code in-place (your build environment is valid) and it will actually re-compile?

In any event, if no actual Delphi programmers respond to this post and you need more in-depth explanations, you might try a more delphi-specific board such as these: