Jump to content

Read Line Of GUI Edit containing special word..


Recommended Posts

Hi,

I am trying to read GUIEdit control & want to display only line that contain Secial word for example error.

If i save GUIEdit input to text file then its possible but directly from EDIT its not happening.

Please help on it. Script attached

#include <GUIConstants.au3>
#Include <GuiEdit.au3>
GUICreate("My GUI edit") ; will create a dialog box that when displayed is centered

$myedit=GUICtrlCreateEdit ("First line"& @CRLF, -1,-1,400,350,$ES_AUTOVSCROLL+$WS_VSCROLL)

GUISetState ()

; will be append dont' forget 3rd parameter
GUICtrlSetData ($myedit, "error One line"& @CRLF,1)
GUICtrlSetData ($myedit, "Second line"& @CRLF,1)
GUICtrlSetData ($myedit, "error two line"& @CRLF,1)
GUICtrlSetData ($myedit, " Second line"& @CRLF,1)
GUICtrlSetData ($myedit, " Second line"& @CRLF,1)
GUICtrlSetData ($myedit, " Second line"& @CRLF,1)
GUICtrlSetData ($myedit, "error three line"& @CRLF,1)
GUICtrlSetData ($myedit, " Second line"& @CRLF,1)


; Run the GUI until the dialog is closed
While 1
    $msg = GUIGetMsg()
    
    If $msg = $GUI_EVENT_CLOSE Then ExitLoop
Wend

;$FileRead = GUICtrlRead($myedit)

$Count_Live = _GUICtrlEditGetLineCount($myedit)
msgbox(0,"count",$Count_Live)
    $i1 = 1
    Do
        $FileRead = GUICtrlRead($myedit)
    $tmp = StringInStr($FileRead,"Error")
        If $tmp = 0 then
            $i1 = $i1 + 1
    
        Else
        
    
    
        MSGBOX(0,"line",$FileRead)
    
         $i1 = $i1 + 1
        EndIf
    Until $i1 = $Count_Live +1
Link to comment
Share on other sites

u want to read it to a text file or something

#include <GUIConstants.au3>
#Include <GuiEdit.au3>
#include <File.au3>
GUICreate("My GUI edit") ; will create a dialog box that when displayed is centered

$myedit=GUICtrlCreateEdit ("First line"& @CRLF, -1,-1,400,350,$ES_AUTOVSCROLL+$WS_VSCROLL)

GUISetState ()

; will be append dont' forget 3rd parameter
GUICtrlSetData ($myedit, "error One line"& @CRLF,1)
GUICtrlSetData ($myedit, "Second line"& @CRLF,1)
GUICtrlSetData ($myedit, "error two line"& @CRLF,1)
GUICtrlSetData ($myedit, " Second line"& @CRLF,1)
GUICtrlSetData ($myedit, " Second line"& @CRLF,1)
GUICtrlSetData ($myedit, " Second line"& @CRLF,1)
GUICtrlSetData ($myedit, "error three line"& @CRLF,1)
GUICtrlSetData ($myedit, " Second line"& @CRLF,1)


; Run the GUI until the dialog is closed
While 1
    $msg = GUIGetMsg()
    
    If $msg = $GUI_EVENT_CLOSE Then ExitLoop
Wend
_FileCreate("test.txt")
$file = "test.txt"
FileWrite($file,GUICtrlRead($myedit))
For $i = 1 to _FileCountLines($file)
    MsgBox(0,"Lines",FileReadLine($file,$i))
Next
Exit
Link to comment
Share on other sites

u want to read it to a text file or something

#include <GUIConstants.au3>
#Include <GuiEdit.au3>
#include <File.au3>
GUICreate("My GUI edit") ; will create a dialog box that when displayed is centered

$myedit=GUICtrlCreateEdit ("First line"& @CRLF, -1,-1,400,350,$ES_AUTOVSCROLL+$WS_VSCROLL)

GUISetState ()

; will be append dont' forget 3rd parameter
GUICtrlSetData ($myedit, "error One line"& @CRLF,1)
GUICtrlSetData ($myedit, "Second line"& @CRLF,1)
GUICtrlSetData ($myedit, "error two line"& @CRLF,1)
GUICtrlSetData ($myedit, " Second line"& @CRLF,1)
GUICtrlSetData ($myedit, " Second line"& @CRLF,1)
GUICtrlSetData ($myedit, " Second line"& @CRLF,1)
GUICtrlSetData ($myedit, "error three line"& @CRLF,1)
GUICtrlSetData ($myedit, " Second line"& @CRLF,1)
; Run the GUI until the dialog is closed
While 1
    $msg = GUIGetMsg()
    
    If $msg = $GUI_EVENT_CLOSE Then ExitLoop
Wend
_FileCreate("test.txt")
$file = "test.txt"
FileWrite($file,GUICtrlRead($myedit))
For $i = 1 to _FileCountLines($file)
    MsgBox(0,"Lines",FileReadLine($file,$i))
Next
Exit
I dont want to read all lines form edit controll to text file.. i want it should write linses those have some special word like Error in example..

if it works this will write only lines

error One line

error two line

error three line

Link to comment
Share on other sites

Hi,

there are of course better ways, but is that what you wanted?

Hit a while GUI is open to check the func's output.

#include <GUIConstants.au3>
#Include <GuiEdit.au3>
#include<Array.au3>
HotKeySet("a", "a")
GUICreate("My GUI edit"); will create a dialog box that when displayed is centered

$myedit = GUICtrlCreateEdit("First line" & @CRLF, -1, -1, 400, 350, $ES_AUTOVSCROLL + $WS_VSCROLL)

GUISetState()

; will be append dont' forget 3rd parameter
GUICtrlSetData($myedit, "error One line" & @CRLF, 1)
GUICtrlSetData($myedit, "Second line" & @CRLF, 1)
GUICtrlSetData($myedit, "error two line" & @CRLF, 1)
GUICtrlSetData($myedit, " Second line" & @CRLF, 1)
GUICtrlSetData($myedit, " Second line" & @CRLF, 1)
GUICtrlSetData($myedit, " Second line" & @CRLF, 1)
GUICtrlSetData($myedit, "error three line" & @CRLF, 1)
GUICtrlSetData($myedit, " Second line" & @CRLF, 1)


; Run the GUI until the dialog is closed
While 1
    $msg = GUIGetMsg()
    
    If $msg = $GUI_EVENT_CLOSE Then ExitLoop
WEnd

Func a()
    $a = StringSplit(GUICtrlRead($myedit), Chr(13))
    Global $b[1]
    $y = 1
    For $i = 1 To UBound($a) - 1
        If StringInStr($a[$i], "error") <> 0 Then
            _ArrayAdd($b, $a[$i])
            $b[$y] = $a[$i]
            $y += 1
            ConsoleWrite($a[$i])
        EndIf
    Next
    _ArrayDisplay($b, "Error lines")
EndFunc  ;==>a

So long,

Mega

Scripts & functions Organize Includes Let Scite organize the include files

Yahtzee The game "Yahtzee" (Kniffel, DiceLion)

LoginWrapper Secure scripts by adding a query (authentication)

_RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...)

Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc.

MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times

Link to comment
Share on other sites

HI,

something like this?

#include <GUIConstants.au3>
#Include <GuiEdit.au3>
#include<Array.au3>
HotKeySet("a", "a")
GUICreate("My GUI edit"); will create a dialog box that when displayed is centered

$myedit = GUICtrlCreateEdit("First line" & @CRLF, -1, -1, 400, 350, $ES_AUTOVSCROLL + $WS_VSCROLL)

GUISetState()

; will be append dont' forget 3rd parameter
GUICtrlSetData($myedit, "error One line" & @CRLF, 1)
GUICtrlSetData($myedit, "Second line" & @CRLF, 1)
GUICtrlSetData($myedit, "error two line" & @CRLF, 1)
GUICtrlSetData($myedit, " Second line" & @CRLF, 1)
GUICtrlSetData($myedit, " Second line" & @CRLF, 1)
GUICtrlSetData($myedit, " Second line" & @CRLF, 1)
GUICtrlSetData($myedit, "error three line" & @CRLF, 1)
GUICtrlSetData($myedit, " Second line" & @CRLF, 1)


; Run the GUI until the dialog is closed
While 1
    $msg = GUIGetMsg()
    
    If $msg = $GUI_EVENT_CLOSE Then ExitLoop
WEnd

Func a()
    $a = StringSplit(GUICtrlRead($myedit), Chr(13))
    Global $b[1]
    $y = 1
    For $i = 1 To UBound($a) - 1
        If StringInStr($a[$i], "error") <> 0 Then
            _ArrayAdd($b, $a[$i])
            $b[$y] = $a[$i]
            $y += 1
            ConsoleWrite($a[$i])
            GUICtrlSetData($myedit, GUICtrlRead($myedit) & $a[$i] & Chr(13))
        EndIf
    Next
    _ArrayDisplay($b, "Error lines")
EndFunc ;==>a

So long,

Mega

Scripts & functions Organize Includes Let Scite organize the include files

Yahtzee The game "Yahtzee" (Kniffel, DiceLion)

LoginWrapper Secure scripts by adding a query (authentication)

_RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...)

Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc.

MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times

Link to comment
Share on other sites

Thx Its working....

HI,

glad I could help. But the func isn't very well coded. :">

So long,

Mega

Scripts & functions Organize Includes Let Scite organize the include files

Yahtzee The game "Yahtzee" (Kniffel, DiceLion)

LoginWrapper Secure scripts by adding a query (authentication)

_RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...)

Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc.

MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times

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