Solved

Equavelent to xBase SUBSTR() function?

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

Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Controlled Assessment GCSE - desperate help needed 4 87
Delphi and Access based Enumeration 9 64
RESTRequest Parameter 4 31
Delphi: making a BW image transparent 10 40
A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
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…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

803 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