?
Solved

Equavelent to xBase SUBSTR() function?

Posted on 1998-05-05
2
Medium Priority
?
518 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 5

Accepted Solution

by:
ronit051397 earned 200 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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
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…
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
Suggested Courses
Course of the Month14 days, 1 hour left to enroll

800 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