Solved

Equavelent to xBase SUBSTR() function?

Posted on 1998-05-05
2
515 Views
Last Modified: 2010-04-06
I hate to post these no-brainer questions, but I find the Delphi help to be less than helpful.  For instance, I see no listing of built in functions anywhere, and there are rarely an examples in the Help files...

What I am trying to do is so utterly simple.  Here the way it would be in xBase:

MyVar := "MARY"
SecondPos = SUBSTR(MyVar,2,1)          && SecondPos now contains "A"

Thanks...  



0
Comment
Question by:roncm
2 Comments
 
LVL 5

Accepted Solution

by:
ronit051397 earned 50 total points
ID: 1341475
Use the Copy function. From Delphi Help file:

Copy returns a substring of a string.

Unit

System

Category

string handling routines

function Copy(S: string; Index, Count: Integer): string;

Description

The Copy function returns a substring of a string.
S is a string-type expression. Index and Count are integer-type expressions. Copy returns a string containing Count characters starting at S[Index].
If Index is larger than the length of S, Copy returns an empty string.
If Count specifies more characters than are available, the only the characters from S[Index] to the end of S are returned.

Example:

 var S: string;

begin
  S := 'ABCDEF';
  S := Copy(S, 2, 3);      { 'BCD' }
end;
0
 

Author Comment

by:roncm
ID: 1341476
Thanks, Ron, I never would have though to look under COPY()...

With the help of this forum, I just might be able to finish this project...:)

0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

860 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question