Jump to content

Detect string at start of line in SciTE


Recommended Posts

Please consider a case:

  • My script has many lines starting with ;- test
  • It also has a few lines starting with test

How can I search one of the few lines starting with test ? I assume that I should check regular expression in the Find dialog. I have done so, and entered the Find What string as \ntest but test is not found. I also tried $test ^test

Edited by c.haslam
Corrected error in what I tried
Spoiler

CDebug Dumps values of variables including arrays and DLL structs, to a GUI, to the Console, and to the Clipboard

 

Link to comment
Share on other sites

  • Developers

Just select the "Search only in this style" option and specify the appropriate style for AutoIt as defined in au3.properties.

I have BOLD the first few style numbers and the description is in the line above it. :)
In this case you need style 0.

Jos

Quote

# White space
style.au3.0=fore:#000000
# Comment line
style.au3.1=fore:#008000,italics
# Comment block
style.au3.2=fore:#008000,italics
# Number
style.au3.3=fore:#0000FF
# Function
style.au3.4=fore:#000090
# Keyword
style.au3.5=fore:#0000FF
# Macro
style.au3.6=fore:#808000
# String
style.au3.7=fore:#FF0000
# Operator
style.au3.8=fore:#FF8000
# Variable
style.au3.9=fore:#5A5A5A
# Send keys in string
style.au3.10=fore:#808080
# Pre-Processor
style.au3.11=fore:#808000
# Special
style.au3.12=fore:#DC143C
#Abbrev-Expand
style.au3.13=fore:#FF0000
# COM Objects
style.au3.14=fore:#993399
#Standard UDF's
style.au3.15=fore:#0080FF
#User UDF's
style.au3.16=$(style.au3.15)

 

Edited by Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

The regular expression to find "Test" at the start of the line would be "^Test" not "$Test".

Edited by TheXman
Link to comment
Share on other sites

Quote

Just select the "Search only in this style" option and specify the appropriate style for AutoIt as defined in au3.properties.

This seems to need Match whole words only to be checked. With this checked, Jos' method works AOK.

Spoiler

CDebug Dumps values of variables including arrays and DLL structs, to a GUI, to the Console, and to the Clipboard

 

Link to comment
Share on other sites

  • Developers
2 hours ago, c.haslam said:

This seems to need Match whole words only to be checked

Don't think that is related to my solution unless that is also what you want! ;) 

Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

I am now confused!

I am actually looking for calls to a function called guidebug which have not been commented out.

I enter guidebug in the Find what input box, uncheck Match whole words only, check Search only in this style, and (if its input box does not contain 0), I enter 0, then click on Find Next.

SciTE moves the cursor to the next occurrence of guidebug and highlights it. This occurrence is not the next line starting with guidebug when the next line containing guidebug begins with other characters.

My work-around is to check Match whole words only. With this checked, SciTE always moves the cursor to the next line that starts with guidebug.

So it appears that my copy of SciTE4AutoIt is defective. SciTE > Help says that it is v. 3.7.3.

Spoiler

CDebug Dumps values of variables including arrays and DLL structs, to a GUI, to the Console, and to the Clipboard

 

Link to comment
Share on other sites

  • Developers

I am fine if it works for you and am unsure whether you found a bug or not, but I am using the current Alpha version of SciTE V 4.0.2 and don't see this behavior.
Example:

Json_Dump($data)
;~ ConsoleWrite("!== Json_TokenDumpTest ============================================================================================================" & @CRLF)
;~ Json_DumpTest($data)

;[0].id

Func Json_DumpTest($Json, $InitTokenCount = 1000)
  • Open the Find window
  • Find what: Json_Dump
  • uncheck "Match whole word only"
  • Check "Search only in this style" 0

It will find the occurrence in line 1 and 7,  where this first is a whole word match and the second a partial match.
Line 3 isn't found as that is a linecomment style

Jos

 

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

On my PC, your example works as you say, but my need is to "Detect string at start of line"  (I am quoting the title of this thread).

It also works for me to find _guidebug in a short-ish script (166 lines) which has lines up to 115 characters.

The script where I am encountering a problem is about 3000 lines which has lines up to about the same length, with guidebug occurring many times.

I have excerpted a few lines of my long script:

;~ If $debugging Then guidebug(@ScriptLineNumber&'c','$name,VarGetType($val)',$name,VarGetType($val))
guidebug(@ScriptLineNumber&'c','$name,$curlvl,$g_cDebug_nMultiLevels,$name,VarGetType($val)', _
$name,$curlvl,$g_cDebug_nMultiLevels,$name,VarGetType($val))
;~ guidebug(@ScriptLineNumber&'c','StringLen($indent),$p,name,$restName,$g_cDebug_bMultiLevel', _
;~ StringLen($indent),$p,$name,$restName,$g_cDebug_bMultiLevel)
; A partial vector, array or map has [ ]s in $name
    Local $brsVec = StringSplit($name,'[]',0+2)     ; char,0-based  [0]: name, [1] ist subscript, [3] 2nd
    Local $qNameDims = Floor(UBound($brsVec)/2)
    If $qNameDims>2 Then
        _cDebug_ReportErrorAndExit('Name '&$name&' has more than 2 dimensions')
    EndIf

Local $sub
If $debugging Then guidebug(@ScriptLineNumber&'c','$name,VarGetType($val),$qNameDims',$name,VarGetType($val),$qNameDims)

Doing:

  • Open the Find window
  • Find what: Json_Dump
  • uncheck "Match whole word only"
  • Check "Search only in this style" 0

finds guidebug on the second and last lines. So this too works as it does on your test script -- but this is not what I asked for in starting this script (but I do have a work-around!)

My thinking is that your method works, but may fail on long scripts.

 

 

Edited by c.haslam
Spoiler

CDebug Dumps values of variables including arrays and DLL structs, to a GUI, to the Console, and to the Clipboard

 

Link to comment
Share on other sites

  • Developers

You could also try the Regular Expression option and add ^ infront of the string to find.

Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...