Microsoft Knowledge Base Article
This article contents is Microsoft Copyrighted material.
©2005-©2007 Microsoft Corporation. All rights reserved.
Terms
of Use |
Trademarks
Article ID: 114498 - Last Review: March 3, 2005 - Revision: 2.2
INFO: Transposing First Character w/ Last Character in a Field
This article was previously published under Q114498
The code in this article describes how to switch the first character with the last character in a field for all records.
The following code demonstrates an easy way to do this:
* Replaces the field for each record
REPLACE <fieldname> WITH RIGHT(TRIM(<fieldname>),1)+;
SUBSTR(<fieldname>,2,LEN(TRIM(<fieldname>))-2)+LEFT(<fieldname>,1) ;
FOR LEN(TRIM(<fieldname>))>1
Before the commands are executed, a sample table may look similar to the
following:
<FIELDNAME>
-----------
A-0000-Z
B-0-Y
C-000000-X
D-00000-W
After the commands are executed, the table looks as follows:
<FIELDNAME>
-----------
Z-0000-A
Y-0-B
X-000000-C
W-00000-D
The REPLACE command concatenates the original rightmost character with the a substring of the original value, which omitts the first and last characters, and appends the original leftmost character to that string.
This command works with variable-length character fields. With a few
modifications, this code can be quite flexible and useful for string-
manipulation purposes and can be adapted to work with other types of fields.
"Commands & Functions," version 2.0 (MS-DOS), pages C3-701 to C3-704,
and C3-659 to C3-660
"Language Reference," version 2.5 (MS-DOS and Windows), pages L3-862
to L3-866, and L3-816 to L3-818
APPLIES TO
- Microsoft Visual FoxPro 3.0 Standard Edition
- Microsoft Visual FoxPro 5.0 Standard Edition
- Microsoft Visual FoxPro 6.0 Professional Edition
- Microsoft FoxPro 2.0
- Microsoft FoxPro 2.6a Professional Edition for Macintosh
Community Feedback System
Very often, it takes hours to solve a problem. Very often, you've looked high
and low, and have tried a lot of solutions. When you finally found it, chances
are, it was because someone else helped you. Here's your chance to give back.
Use our community feedback tool to let others know what worked for you and what
didn't.
Please also understand that the community feedback system is not warranted to be
correct, it's simply a system that we've built to let people try and help each
other. If something in a feedback response doesn't make sense to you, or you're
not comfortable making changes that the feedback talks about (like registry
edits), please consult a professional.
Thank you for using kbAlertz.com Feedback System.
-- Scott Cate
Be the first to leave feedback, to help others about this knowledge base
article.
(Optional) Name
(Optional)
Public URL Or Email
Comments
No
HTML -- Text Only Please