Solved

get 3 character from left

Posted on 2003-12-01
7
222 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 20 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
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.

 
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

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

Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
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…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…
This is a video describing the growing solar energy use in Utah. This is a topic that greatly interests me and so I decided to produce a video about it.

939 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

6 Experts available now in Live!

Get 1:1 Help Now