Share via


OffsetToLineNumber

 

The new home for Visual Studio documentation is Visual Studio 2017 Documentation on docs.microsoft.com.

The latest version of this topic can be found at OffsetToLineNumber.

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

Syntax

  
      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

Customizing C++ Wizards with Common JScript Functions
JScript Functions for C++ Wizards
Creating a Custom Wizard
Designing a Wizard
LineBeginsWith