Compartir a través de


OffsetToLineNumber

Called by InsertIntoFunction to convert an index in a function body to a line number.

function OffsetToLineNumber( 
   strString, 
   nPos  
);

Parameters

  • strString
    The string containing the function body. The function body is a multi-line string where its lines are delimited by cr-lf character pairs.

  • nPos
    A position within the string.

Return Value

The line within the body function where nPos is located. The first line in the function is considered to be line 1 (not 0).

Remarks

Finds the line number for a given position in a function body.

This function is called by InsertIntoFunction to convert the index located at nPos in a function body to a line number.

Example

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.

See Also

Tasks

Creating a Custom Wizard

Reference

LineBeginsWith

Concepts

Customizing C++ Wizards with Common JScript Functions

Designing a Wizard

Other Resources

JScript Functions for C++ Wizards