...

View Full Version : Delphi Issues



reley
09-26-2011, 12:00 PM
Hi
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.

Thanks

morongo47
09-29-2011, 03: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:
http://www.delphibasics.co.uk/ByFunction.asp?Main=Strings&Sub=Calcs

reley
09-30-2011, 11:57 AM
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

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

morongo47
09-30-2011, 08: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);
var
result : Integer;
begin


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

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

end;




...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:

http://www.delphipages.com/forum/forumdisplay.php?f=3

http://www.programmersheaven.com/mb/Delphi/Board.aspx
.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum