Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

all I want is part of a string!!!!!!!!!!!!!!!!

Status
Not open for further replies.

ffej2ffej

Programmer
Oct 8, 2005
9
US
I'm using Borland Delphi 6. I have a string that I only want part of. Since the string is always the same length and the info I want is always in the same position, it seemed I could use a function like sub, substr or substring. Even though these functions are listed in the Delphi help, none of them work. The compiler thinks sub(stringname,12,11), SUB(stringname,12,11), substr(stringname,12,11), Substr(stringname,12,11), SUBSTR(stringname,12,11), substring(stringname,12,11), SUBSTRING(stringname,12,11) etc. are IDENTIFIERS and not functions.
Is there a working function that will extract part of a string? What is it called? I've spent the better part of a day on this and I'm really getting sick of it.

Thank you
 
Have you carefully checked the help files? There are several units you can include that have functions of these types.

The basic function available in ALL flavours of Delphi/Pascal is the [tt]COPY[/tt] function in the [tt]SYSTEM[/tt] unit:
[tt]function Copy(S; Index, Count: Integer): string;[/tt]
where S is the string, Index is the starting position, and Count is how many characters.
Thus [tt]NewString := COPY(MyString,FirstChar,NumChars);[/tt]

There are also many other more sophisticated versions of this (eg MIDSTR, LEFTSTR), in the [tt]STRUTILS[/tt] unit.

Cheers,
Chris [pc2]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top