OffsetToLineNumber

InsertIntoFunction 调用以将函数体中的索引转换为行号。

function OffsetToLineNumber( 
   strString, 
   nPos  
);

参数

  • strString
    包含函数体的字符串。 函数体是多行字符串,其中的行由 cr-lf 字符对分隔。

  • nPos
    在字符串中的位置。

返回值

函数体中 nPos 所在的行。 函数中的第一行被认为是行 1(不是 0)。

备注

查找函数体中给定位置的行号。

该函数由 InsertIntoFunction 调用以将函数体中位于 nPos 处的索引转换为行号。

示例

strString = "function DelFile(fso,
 strWizTempFile)\r\n{\r\n\ttry\r\n\t{\r\nif 
(fso.FileExists(strWizTempFile))\r\nreturn true;\r\n";

nLine =  OffsetToLineNumber(strString, 60);

// The return value for the above is 5, because character 60 in the string 
// occurs in the 5th line within the string.

请参见

任务

创建自定义向导

参考

LineBeginsWith

概念

用公共 JScript 函数自定义 C++ 向导

设计向导

其他资源

用于 C++ 向导的 JScript 函数