Solved

Equavelent to xBase SUBSTR() function?

Posted on 1998-05-05
2
511 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, just open a new email message. In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
Many functions in Excel can make decisions. The most simple of these is the IF function: it returns a value depending on whether a condition you describe is true or false. Once you get the hang of using the IF function, you will find it easier to us…

920 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now