[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

get 3 character from left

Posted on 2003-12-01
7
Medium Priority
?
231 Views
Last Modified: 2010-04-05
Hi...
does anybody knows how I can get the first 3 character from left of a variable .?

Thanks ^^
0
Comment
Question by:allie910
  • 4
  • 2
7 Comments
 
LVL 26

Accepted Solution

by:
Russell Libby earned 60 total points
ID: 9855091

result:=Copy(variable, 1, 3)


Regards,
Russell
0
 
LVL 2

Expert Comment

by:TheLeader
ID: 9855104
is this variable string !?
ex:
S,T : String;
T := Copy (Length(S)-3,Length(S))
0
 
LVL 2

Expert Comment

by:TheLeader
ID: 9855111
sorry i thought it from right :p
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
LVL 2

Expert Comment

by:TheLeader
ID: 9855124
you can use as "rllibby"
or if you know about this
S : String;
s[1] :=  "1st char"
S[2] := "2nd char"
S[3] := "3rd char"
 and so on

hope it helped ...
0
 
LVL 7

Expert Comment

by:sftweng
ID: 9855274
Be careful using S[i] rather than Copy - there's trouble if I > Length(s). rllibby's approach is safer.
0
 
LVL 26

Expert Comment

by:Russell Libby
ID: 9855287

TheLeader,

You might want to include the check for:

if (length(s) >= required_length) then
begin
  ... // access s[index], ie s[1], s[2], s[3] ...
end;

Just for completness in your example....

Kindest regards,
Russell



0
 
LVL 2

Expert Comment

by:TheLeader
ID: 9855442
yah i know, he must check the length first ofcourse
but i wanted to show him another way.

by the way "rllibby" I didn't see your post til I submit my first comment.
anyway, I get it in reverse :p
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
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…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an anti-spam), the admin…
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …
Suggested Courses

834 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