Skip to content

vsFindOptions is undefined #37

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
CGB0 opened this issue Nov 23, 2016 · 1 comment
Open

vsFindOptions is undefined #37

CGB0 opened this issue Nov 23, 2016 · 1 comment

Comments

@CGB0
Copy link

CGB0 commented Nov 23, 2016

/// <reference path="C:\Users\<user>\AppData\Local\Microsoft\VisualStudio\14.0\Macros\dte.js" />


debugger;
dte.SuppressUI = true
var objSelection  = dte.ActiveDocument.Selection
objSelection.StartOfDocument()
While(objSelection.FindText("#region",   vsFindOptions.vsFindOptionsMatchInHiddenText))
   alert ( " found something")
Loop
objSelection.StartOfDocument()
dte.SuppressUI = false

This code gives the error vsFindOptions is undefined. How do we match lines?

My goal here is to run though the active document and collapse any line that has the text "#region" or "function" in the line

Any help appreciated.

Thanks
Colin

@daiplusplus
Copy link

daiplusplus commented Aug 12, 2023

vsFindOptions is an enum - there's no equivalent in JScript 3 so you'll need to use named values:

var vsFindOptions_MatchInHiddenText = 512; // https://learn.microsoft.com/en-us/dotnet/api/envdte.vsfindoptions?view=visualstudiosdk-2022

do {
    var findResult = objSelection.FindText("#region", vsFindOptions_MatchInHiddenText  );
    if( findResult.Etc ) break;
}
while( true );

// etc

Also, your code as-posted is won't work:

  • the debugger; statement isn't supported by IActiveScript (JScript 3),
  • you're mixing VBScript and JScript syntaxes (e.g. there is no While.. Loop structure, in JS it's do { } while( expr ): or while( expr ) { }.
  • there is no alert() function (that's from HTML's DOM, not JScript itself).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants