OffsetToLineNumber

 

For the latest documentation on Visual Studio 2017 RC, see Visual Studio 2017 RC Documentation.

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.

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

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.

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.  

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

Show: