点击或拖拽改变大小

RAt Function

X#
返回子字符串在字符串中最后一次出现的位置。

命名空间:  XSharp.Core
程序集:  XSharp.Core (在 XSharp.Core.dll 中) 版本:2.24 GA
Syntax
 FUNCTION RAt(
	cSearch AS STRING,
	cTarget AS STRING
) AS DWORD
Request Example 查看代码

Parameters

cSearch
类型:String
要搜索的子字符串。
cTarget
类型:String
要在其中搜索的字符串。(要指定偏移量,请使用 RAt3()。)

Return Value

类型:DWord
cSearch 在 cTarget 中的位置。
如果未找到 cSearch,则 RAt() 返回 0。
备注
RAt() 类似于 At(),后者返回子字符串在另一个字符串中第一次出现的位置。
如果您只需要知道一个子字符串是否存在于另一个字符串中,请使用 InStr() 函数或 $ 运算符。 RAt() 和 At() 函数可与 Substr()、Left() 和 Right() 一起使用,以提取子字符串。
Examples
此示例使用 RAt() 创建一个函数 FilePath(),该函数从文件规范中提取路径。
如果未指定路径,FilePath() 返回 NULL_STRING:
X#
 1? FilePath("c:\dbf\sales.dbf")        // c:\dbf\
 2FUNCTION FilePath(cFile AS STRING)
 3    LOCAL nPos AS DWORD
 4    LOCAL cFilePath AS STRING
 5    IF (nPos := RAt("\", cFile)) != 0
 6        cFilePath := Substr(cFile, 1, nPos)
 7    ELSE
 8        cFilePath := NULL_STRING
 9    ENDIF
10    RETURN cFilePath
See Also