Left(), Right(), SubStr() - Ted Roche
Có thể bạn quan tâm
Left(), Right(), SubStr()
These functions let you pull apart character strings. LEFT() grabs a specified number of characters from the beginning; RIGHT() takes the specified number from the end. SUBSTR() is the most general, but also the most difficult to use; it lets you extract a consecutive string of characters from anywhere in the original string. You can combine these functions with AT() (or similar search functions) to parse a string.| Usage | cReturnValue = LEFT( cString, nCharacters ) |
| Example | ? LEFT("Hacker's Guide", 8) && Returns "Hacker's" |
| Usage | cReturnValue = RIGHT( cString, nCharacters ) |
| Example | ? RIGHT("Hacker's Guide", 5) && Returns "Guide" ? RIGHT("This string has 2 trailing blanks ", 2) && returns " " |
| Usage | cReturnValue = SUBSTR( cString, nStart [ , nLength ] ) |
| Parameter | Value | Meaning |
| cString | Character | The string from which a portion is to be extracted. |
| nStart | Numeric | The position of the first character to extract. |
| nLength | Numeric | The number of characters to extract. If there are fewer than nLength characters from nStart to the end of the string, all remaining characters are returned. |
| Omitted | All characters from nStart to the end of the string are extracted. |
![]() | In versions of VFP through 5.0a, SUBSTR() does one truly odd thing. Its behavior if nStart is greater than the length of the string depends on the current value of SET TALK. Really! With SET TALK OFF, you simply get the empty string. But with SET TALK ON, attempting to start a SUBSTR() after the end of the character string gives an error message of "Beyond String." Try the following in an older version: SET TALK OFF ? SUBSTR('abc', 4) SET TALK ON ? SUBSTR('abc', 4) |
| Example | ? SUBSTR("Visual FoxPro", 9, 2) && Returns "ox" ? SUBSTR("Visual FoxPro", 8) && Returns "FoxPro" * Line below returns "Fox" ? SUBSTR("Visual FoxPro", AT(" ", "Visual FoxPro") + 1,3) |
| See Also | At(), AtC(), LeftC(), Occurs(), RAt(), RightC(), Set Talk, Stuff(), SubStrC(), Trim() |
Back to Table of Contents
Copyright © 2002-2018 by Tamar E. Granor, Ted Roche, Doug Hennig, and Della Martin. Click for license .
Từ khóa » Visual Foxpro At Function
-
AT(), ATC(), RAT(), $ | Hacker's Guide To Visual FoxPro
-
AT() - dexOf() - VFP To Servoy Code Reference
-
ATC( ) Function - Yaldex
-
String Functions (Visual FoxPro ODBC Driver) - Microsoft Docs
-
FoxPro String And Text Functions - Alvechurch Data
-
Visual FoxPro Functions For Processing Text - Alvechurch Data
-
[PDF] FoxPro Functions - NC School Bus Safety
-
String Processing With VFP - CODE Magazine
-
At Function - Microsoft: FoxPro - Tek-Tips
-
Different Type Of Microsoft Visual FoxPro 6.0 Function - Samasto
-
Year Function
-
Functions And Subroutines (Procedures) | Visual FoxPro ...
-
Text And String Handling In VFP | Steven Black Consulting
-
Visual FoxPro/PHP Functions In Lianja
