Jump to content

Drove me silly (Solved)


Go to solution Solved by mikell,

Recommended Posts

Posted (edited)

With this I'm trying to get all lines with "-1," preferably "( -1," or (-1," or with the preceding $var name, starting from the search term line.
hopefully putting it here will help 

Edit: the StringReplace  problem left

Thanks

  Reveal hidden contents

 

Edited by Deye
Updated Code
Posted (edited)

Updated the question: Left with  the StringReplace  part problem

I tried passing the string as with @lf's  and  quotes around the entries  -  dont think i know or remember what to try with this ..

Edit

The silliness has come to an end ;)

updated Code above

Thanks

Deye

Edited by Deye
Posted

Hmm. FYI this can be done in one go using SRER  :)  (hoping that I understood the whole thing correctly)

$sString = @LF & 'Local $idUndo = GUICtrlCreateButton(Chr(76), 359, 44, 25, 24)' & @LF & _
        'GUICtrlSetFont(-1, 13, 601, -1, "WingDings 3")' & @LF & _
        'GUICtrlSetTip($idUndo, "Undo")' & @LF & _
        'Local $idRedo = GUICtrlCreateButton(Chr(80), 386, 44, 23, 24)' & @LF & @LF & _  ;<<<<<
        'GUICtrlSetFont(-1, 13, 602, -1, "WingDings 3")' & @LF & "  " & @LF & _          ;<<<<<
        'GUICtrlSetTip( - 1, "Redo")' & @LF & _                                          ;<<<<<
        'Some other line 1' & @LF & _
        'Local $idtest = GUICtrlCreateButton(Chr(80), 386, 44, 23, 24)' & @LF & _
        'GUICtrlSetFont(-1, 13, 603, -1, "WingDings 3")' & @LF & _
        'GUICtrlSetData( $idtest, "test")' & @LF & _ 
        'GUICtrlSetData( $idRedo, "Redo")' & @LF & _                                     ;<<<<<
        'GUICtrlSetData( -1, "test")' & @LF & _ 
        'Some other line 2'

$sSearch = 'Local $idRedo = GUICtrlCreateButton(Chr(80), 386, 44, 23, 24)'

$var = StringRegExpReplace($sSearch, '.*?(\$[^\h=]+).*', "$1")
;msgbox(0,"", $var)

$pattern = '(\Q' & $sSearch & '\E\s+(.*?\(\h*-\h*1\h*,.*\s+)*)|(.*?\(\h*\Q' & $var & '\E.*\s+)'
$res = StringRegExpReplace($sString, $pattern, "")
msgbox(0,"", $res)

But it probably could be done even simpler

Posted (edited)

mikell,

its funny in the end i forgot that i wanted  it done with SRER  

 preparing the $s string  to go with  stringreplace  got  messy in the end just  didnt do it in some cases ( @lf ,@crlf  .etc), not worth the time in this case, should have known ..

anyways I will next implement what i wanted to get with SRER and will look @ your example

Thanks again

Edit : the pattern needs to include all line dependencies  to the search untill not  "( - 1," And  not  "$var" in expression 

I need that to replace the data that will be saved to a file after that i will take all those lines  remove blank lines between them and keep any commented lines and move them under-to a Tab menu name ..

well done @mikell  Worked as a Charm and as what i needed precisely   :thumbsup:

 

Edited by Deye
Posted (edited)

How in the world you incept  these patterns lol

funny thing :muttley:the last one doesn't work for me like the first 

---------------------------------------------------------------------------------------------|

@mikell To see how this works in action you can run this example 

select one or a few controls by clicking on them (see that they are getting checked in the right control panel)

Holding the SHIFT key drag one of the selected controls on to a tab menu name other then the active selected one

now you can test what precisely works and what wont do and see how multiple controls go into a Tab

the function that i included your solution is Here  : func _ReplacePoints()

 

Deye

 

Edited by Deye
Posted (edited)

ehh, I am still not sure

Can we start with a simpler way  so ill have another way to compare with  as it doesn't always work for me

maybe  with something like this:  First thing is  to make it work .. 

This is good to go, Works perfectly , it was  a line  in _ReplacePoints () that would Return when the tabs control gets checked when it should just ContinueLoop

what seemed to screw up things  @this line  "If StringInStr($search11, "GUICtrlCreateTab") Then Return"

the posted above example  has  a lot of messy stuff - will update it in its thread   with some other fixes when its ready for a bump

Thanks mikell for all the help , your second version seemed to work well as well :D

Edited by Deye

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
  • Recently Browsing   0 members

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