Jump to content

Remove first few lines from GUICtrlCreateEdit


thexshadow
 Share

Go to solution Solved by MHz,

Recommended Posts

Being on Linux at the moment, I don't have access to the Help file, and I cannot seem to find an online Link to the UDF's (User Defined Functions). It is possible the Edit UDF has what you need, but I cannot remember.

If not, then you can start with the StringSplit function, with the appropriate Carriage Return as divider/separator.

Then do a character count on the first 5 array returns (i.e $cnt = StringLen($array[1]) up to $array[5])

With the total of each five counts, use StringTrimLeft from your full read of the Edit text, then write the result back.

The only obvious problem you will have, is if you don't have the required Carriage Returns.

In that case you are out of luck, though there might be a Function that can just return the string for the width of the Edit (single visible line). Unless of course, you have an idea of what the last few words of line five will be, and they are unique enough to use StringSplit with them.

EDIT

This is just one of a few approaches that could be used. I'm sure that someone will eventually come along with others before too long, but the above should give you some ideas (and a possible solution) to start with.

Edited by TheSaint

Make sure brain is in gear before opening mouth!
Remember, what is not said, can be just as important as what is said.

Spoiler

What is the Secret Key? Life is like a Donut

If I put effort into communication, I expect you to read properly & fully, or just not comment.
Ignoring those who try to divert conversation with irrelevancies.
If I'm intent on insulting you or being rude, I will be obvious, not ambiguous about it.
I'm only big and bad, to those who have an over-active imagination.

I may have the Artistic Liesense ;) to disagree with you. TheSaint's Toolbox (be advised many downloads are not working due to ISP screwup with my storage)

userbar.png

Link to comment
Share on other sites

For the novice user, GUICtrlRead(), StringSplit() (splitting at @CRLF) and _ArrayDelete() should give you an idea.

UDF List:

 
_AdapterConnections() • _AlwaysRun() • _AppMon() • _AppMonEx() • _ArrayFilter/_ArrayReduce • _BinaryBin() • _CheckMsgBox() • _CmdLineRaw() • _ContextMenu() • _ConvertLHWebColor()/_ConvertSHWebColor() • _DesktopDimensions() • _DisplayPassword() • _DotNet_Load()/_DotNet_Unload() • _Fibonacci() • _FileCompare() • _FileCompareContents() • _FileNameByHandle() • _FilePrefix/SRE() • _FindInFile() • _GetBackgroundColor()/_SetBackgroundColor() • _GetConrolID() • _GetCtrlClass() • _GetDirectoryFormat() • _GetDriveMediaType() • _GetFilename()/_GetFilenameExt() • _GetHardwareID() • _GetIP() • _GetIP_Country() • _GetOSLanguage() • _GetSavedSource() • _GetStringSize() • _GetSystemPaths() • _GetURLImage() • _GIFImage() • _GoogleWeather() • _GUICtrlCreateGroup() • _GUICtrlListBox_CreateArray() • _GUICtrlListView_CreateArray() • _GUICtrlListView_SaveCSV() • _GUICtrlListView_SaveHTML() • _GUICtrlListView_SaveTxt() • _GUICtrlListView_SaveXML() • _GUICtrlMenu_Recent() • _GUICtrlMenu_SetItemImage() • _GUICtrlTreeView_CreateArray() • _GUIDisable() • _GUIImageList_SetIconFromHandle() • _GUIRegisterMsg() • _GUISetIcon() • _Icon_Clear()/_Icon_Set() • _IdleTime() • _InetGet() • _InetGetGUI() • _InetGetProgress() • _IPDetails() • _IsFileOlder() • _IsGUID() • _IsHex() • _IsPalindrome() • _IsRegKey() • _IsStringRegExp() • _IsSystemDrive() • _IsUPX() • _IsValidType() • _IsWebColor() • _Language() • _Log() • _MicrosoftInternetConnectivity() • _MSDNDataType() • _PathFull/GetRelative/Split() • _PathSplitEx() • _PrintFromArray() • _ProgressSetMarquee() • _ReDim() • _RockPaperScissors()/_RockPaperScissorsLizardSpock() • _ScrollingCredits • _SelfDelete() • _SelfRename() • _SelfUpdate() • _SendTo() • _ShellAll() • _ShellFile() • _ShellFolder() • _SingletonHWID() • _SingletonPID() • _Startup() • _StringCompact() • _StringIsValid() • _StringRegExpMetaCharacters() • _StringReplaceWholeWord() • _StringStripChars() • _Temperature() • _TrialPeriod() • _UKToUSDate()/_USToUKDate() • _WinAPI_Create_CTL_CODE() • _WinAPI_CreateGUID() • _WMIDateStringToDate()/_DateToWMIDateString() • Au3 script parsing • AutoIt Search • AutoIt3 Portable • AutoIt3WrapperToPragma • AutoItWinGetTitle()/AutoItWinSetTitle() • Coding • DirToHTML5 • FileInstallr • FileReadLastChars() • GeoIP database • GUI - Only Close Button • GUI Examples • GUICtrlDeleteImage() • GUICtrlGetBkColor() • GUICtrlGetStyle() • GUIEvents • GUIGetBkColor() • Int_Parse() & Int_TryParse() • IsISBN() • LockFile() • Mapping CtrlIDs • OOP in AutoIt • ParseHeadersToSciTE() • PasswordValid • PasteBin • Posts Per Day • PreExpand • Protect Globals • Queue() • Resource Update • ResourcesEx • SciTE Jump • Settings INI • SHELLHOOK • Shunting-Yard • Signature Creator • Stack() • Stopwatch() • StringAddLF()/StringStripLF() • StringEOLToCRLF() • VSCROLL • WM_COPYDATA • More Examples...

Updated: 22/04/2018

Link to comment
Share on other sites

Read and store your data in a variable. Remove the useless data, in your case the 5 first lines, using string functions and then set the data back to the edit.

If you are going to supply a simplistic summary (of essentially what I just said), then you should take care to make sure you don't confuse, by using string function, instead of string functions. Because there is a String function.

NOTE - I quite realize you probably didn't see my post until after you did yours. :D

Make sure brain is in gear before opening mouth!
Remember, what is not said, can be just as important as what is said.

Spoiler

What is the Secret Key? Life is like a Donut

If I put effort into communication, I expect you to read properly & fully, or just not comment.
Ignoring those who try to divert conversation with irrelevancies.
If I'm intent on insulting you or being rude, I will be obvious, not ambiguous about it.
I'm only big and bad, to those who have an over-active imagination.

I may have the Artistic Liesense ;) to disagree with you. TheSaint's Toolbox (be advised many downloads are not working due to ISP screwup with my storage)

userbar.png

Link to comment
Share on other sites

GuiCtrlRead the data from the control.

Modify the string with StringRegExpReplace like in this example

Global $lines
For $1 = 1 To 10
    $lines &= 'line ' & $1 & @CRLF
Next
MsgBox(0, 'Step 1', $lines)

$lines = StringRegExpReplace($lines, '.*?[\r\n]+', '', 5)
MsgBox(0, 'Step 2', $lines)

and then GuiCtrlSetData to the control with the new string. :)

Link to comment
Share on other sites

or, maybe this is easier
You can search for the location of the fifth @LF, and if there is, keep only what follows the @LF, in this way:

$fifth_LF = StringInStr(GUICtrlRead($myGUICtrlEdit), @LF, 0, 5) ; find the position of fifth @LF (it mark the end of line 5)
    If $fifth_LF Then ; if there are at least 5 lines then keep only what follow
        GUICtrlSetData($myGUICtrlEdit, StringRight(GUICtrlRead($myGUICtrlEdit), StringLen(GUICtrlRead($myGUICtrlEdit)) - $fifth_LF ))
    EndIf

bye

EDIT:

opss, I missed the previous post
MHz's solution is much better! :)

Edited by PincoPanco

 

image.jpeg.9f1a974c98e9f77d824b358729b089b0.jpeg Chimp

small minds discuss people average minds discuss events great minds discuss ideas.... and use AutoIt....

Link to comment
Share on other sites

If you used the right type of font, then you could always rely on the same number of characters in a line, which would work well enough if carriage returns are missing.

All that said, there appears to be suitable functions in the GuiEdit Management section of the UDF section of th Help file.

Make sure brain is in gear before opening mouth!
Remember, what is not said, can be just as important as what is said.

Spoiler

What is the Secret Key? Life is like a Donut

If I put effort into communication, I expect you to read properly & fully, or just not comment.
Ignoring those who try to divert conversation with irrelevancies.
If I'm intent on insulting you or being rude, I will be obvious, not ambiguous about it.
I'm only big and bad, to those who have an over-active imagination.

I may have the Artistic Liesense ;) to disagree with you. TheSaint's Toolbox (be advised many downloads are not working due to ISP screwup with my storage)

userbar.png

Link to comment
Share on other sites

Ok I got that workign good, is there a better way to do this? This way it scrolls all the way back to the top, which is very inconvienent.

Case $msg = $Exr
            $exrun = Run('"' & @ComSpec & '" /c "' removed, @DesktopDir, @SW_HIDE)
            While 1
               $out = StdoutRead($exrun)
               If @error then exitloop
               GUICtrlSetData($BM,$out,1)
            WEnd
            $Read = GUICtrlRead($BM)
            $StrReplace = StringRegExpReplace($Read, '.*?[\r\n]+', '', 6)
            GUICtrlSetData($BM, $StrReplace)

Also, is there a way to remove "- 1272 files found in 0 seconds
coverage file 0 75% 11547573 15236051" and then add "gutils.lua" back to "00e69000 8567 scriptsutilsaidebu". I dont know if this is possable.

00e57000 453547     scripts\network\wrld.xml
  00e69000 8567       scripts\utils\aidebu
- 1272 files found in 0 seconds
  coverage file 0    75%   11547573   15236051  
gutils.lua
  00e6a000 8778       scripts\utils\containers.lua
Edited by thexshadow
Link to comment
Share on other sites

$text = _
'  00e57000 453547     scripts\network\wrld.xml' & @CRLF & _
'  00e69000 8567       scripts\utils\aidebu' & @CRLF & _
'- 1272 files found in 0 seconds' & @CRLF & _
'  coverage file 0    75%   11547573   15236051  ' & @CRLF & _
'gutils.lua' & @CRLF & _
'  00e6a000 8778       scripts\utils\containers.lua'

$replaced = StringRegExpReplace($text, _
    '- \d* files found in \d* seconds[\r\n]*' & _
    '\s*coverage file \d*\s*\d*%\s*\d*\s*\d*\s*[\r\n]*' _
    , '' _
)
ConsoleWrite($replaced & @CRLF)
MsgBox(0, '', $replaced)

#cs - RegExp pattern
\d*     Any digit, 0 or more
\s*     Any whitespace, 0 or more
[\r\n]* Any CR or LF, 0 or more
The rest are treated as literals
See StringRegExp in help file for concise information
#ce

ConsoleWrite Output

00e57000 453547     scripts\network\wrld.xml
  00e69000 8567       scripts\utils\aidebu
gutils.lua
  00e6a000 8778       scripts\utils\containers.lua

And remember, I am not a pinball table to be bumped. :)

Link to comment
Share on other sites

$text = _
'  00e57000 453547     scripts\network\wrld.xml' & @CRLF & _
'  00e69000 8567       scripts\utils\aidebu' & @CRLF & _
'- 1272 files found in 0 seconds' & @CRLF & _
'  coverage file 0    75%   11547573   15236051  ' & @CRLF & _
'gutils.lua' & @CRLF & _
'  00e6a000 8778       scripts\utils\containers.lua'

$replaced = StringRegExpReplace($text, _
    '- \d* files found in \d* seconds[\r\n]*' & _
    '\s*coverage file \d*\s*\d*%\s*\d*\s*\d*\s*[\r\n]*' _
    , '' _
)
ConsoleWrite($replaced & @CRLF)
MsgBox(0, '', $replaced)

#cs - RegExp pattern
\d*     Any digit, 0 or more
\s*     Any whitespace, 0 or more
[\r\n]* Any CR or LF, 0 or more
The rest are treated as literals
See StringRegExp in help file for concise information
#ce

ConsoleWrite Output

00e57000 453547     scripts\network\wrld.xml
  00e69000 8567       scripts\utils\aidebu
gutils.lua
  00e6a000 8778       scripts\utils\containers.lua

And remember, I am not a pinball table to be bumped. :)

 

Thanks for that, but is there a way to combine this:

00e69000 8567       scripts\utils\aidebu
gutils.lua

So it looks like:

00e69000 8567       scripts\utils\aidebugutils.lua

But its never going to be the same, so next time it could be:

037a9000 816        char\text\i
nvertstripes.dds

Then i would want it to turn to:

037a9000 816        char\text\invertstripes.dds

And, I dont know, but is there a way to combine multiple StringRegExpReplace's?

Edited by thexshadow
Link to comment
Share on other sites

That can be combined. I thought it was a bit odd the gutils.lua line though I could only follow the instruction. The regex pattern does not relate to the other strings so a little variation there does not matter. What matters is what it does match. So, the change you want is to also match the preceding newline characters. This is what [rn]* does so it just needs to be added to the start of the pattern.

$text = _
'  00e57000 453547     scripts\network\wrld.xml' & @CRLF & _
'  00e69000 8567       scripts\utils\aidebu' & @CRLF & _
'- 1272 files found in 0 seconds' & @CRLF & _
'  coverage file 0    75%   11547573   15236051  ' & @CRLF & _
'gutils.lua' & @CRLF & _
'  00e6a000 8778       scripts\utils\containers.lua'

$replaced = StringRegExpReplace($text, _
    '[\r\n]*- \d* files found in \d* seconds[\r\n]*' & _
    '\s*coverage file \d*\s*\d*%\s*\d*\s*\d*\s*[\r\n]*' _
    , '' _
)
ConsoleWrite($replaced & @CRLF)
MsgBox(0, '', $replaced)
00e57000 453547     scripts\network\wrld.xml
  00e69000 8567       scripts\utils\aidebugutils.lua
  00e6a000 8778       scripts\utils\containers.lua

You can have multiple StringRegExpReplace's to reuse the same variable and thus the contents in the variable change.

$var = 'dog and cat'
$var = StringRegExpReplace($var, 'and\scat', '& mouse')
$var = StringRegExpReplace($var, 'dog\s&', 'cat chases')
ConsoleWrite($var & @CRLF)
MsgBox(0, 'dog and cat', $var)
cat chases mouse

The s in the pattern matches whitespace. The rest is literal characters.

:)

Link to comment
Share on other sites

Thanks for that, One question though, If I want to combine these together.

$StrReplace1 = StringRegExpReplace(GUICtrlRead($Output), '.*?[\r\n]+', '', 8)
GUICtrlSetData($Output, $StrReplace1)
$StrReplace2 = StringRegExpReplace(GUICtrlRead($Output), '[\r\n]*- \d* files found in \d* seconds[\r\n]*' & '\s*coverage file \d*\s*\d*%\s*\d*\s*\d*\s*[\r\n]*', '')
GUICtrlSetData($Output, $StrReplace2)

Would I have to go like this, because this only reads the bottom strreplace and not the top one.

$StrReplace = StringRegExpReplace(GUICtrlRead($Output), '.*?[\r\n]+', '', 8)
$StrReplace = StringRegExpReplace(GUICtrlRead($Output), '[\r\n]*- \d* files found in \d* seconds[\r\n]*' & '\s*coverage file \d*\s*\d*%\s*\d*\s*\d*\s*[\r\n]*', '')
GUICtrlSetData($Output, $StrReplace)

Or something like this?

$StrReplace = StringRegExpReplace(GUICtrlRead($Output), '[\r\n]*- \d* files found in \d* seconds[\r\n]*' & '\s*coverage file \d*\s*\d*%\s*\d*\s*\d*\s*[\r\n]*' & '.*?[\r\n]+', '', 8)
GUICtrlSetData($Output, $StrReplace)
Edited by thexshadow
Link to comment
Share on other sites

  • Solution

Removing the 1st 8 lines would best be done in a separate use of StringRegExpReplace as it has little in common with replacing the other strings.

Your 2nd code option is perhaps close with a small change of using $StrReplace from the 1st StringRegExpReplace and using it as the input of the 2nd StringRegExpReplace.

$StrReplace = StringRegExpReplace(GUICtrlRead($Output), '.*?[\r\n]+', '', 8)
$StrReplace = StringRegExpReplace($StrReplace, '[\r\n]*- \d* files found in \d* seconds[\r\n]*' & '\s*coverage file \d*\s*\d*%\s*\d*\s*\d*\s*[\r\n]*', '')
GUICtrlSetData($Output, $StrReplace)

It would the same nesting the function call like this

$StrReplace = StringRegExpReplace( _
    StringRegExpReplace(GUICtrlRead($Output), '.*?[\r\n]+', '', 8), _
    '[\r\n]*- \d* files found in \d* seconds[\r\n]*' & _
    '\s*coverage file \d*\s*\d*%\s*\d*\s*\d*\s*[\r\n]*', '' _
)
GUICtrlSetData($Output, $StrReplace)

:)

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...