Jump to content

Read the number of lines entered?


Recommended Posts

How can I read each entered number of lines?

#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <String.au3>
$Form1 = GUICreate("Form1", 475, 285)
$Edit1 = GUICtrlCreateEdit("", 72, 72, 185, 89)
GUICtrlSetData(-1, "")
$Label1 = GUICtrlCreateLabel("", 296, 224, 44, 25)
$Label2 = GUICtrlCreateLabel("Number of lines to be introduced:", 104, 224, 181, 17)
GUISetState(@SW_SHOW)
While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit

                $editread = StringSplit(GUICtrlRead($Edit1, @CRLF)
                If $editread => 0 Then
                  For $say=0 To $editread
                  GUICtrlSetData ($Label1, $say)
                  Next
                  EndIf

    EndSwitch
WEnd

 

Link to comment
Share on other sites

They do not have any number of rows

#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <String.au3>
$Form1 = GUICreate("Form1", 475, 285)
$Edit1 = GUICtrlCreateEdit("", 72, 72, 185, 89)
GUICtrlSetData(-1, "")
$Label1 = GUICtrlCreateLabel("", 296, 224, 44, 25)
$Label2 = GUICtrlCreateLabel("Number of lines to be introduced:", 104, 224, 181, 17)
GUISetState(@SW_SHOW)
While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit

                $editread = StringSplit(GUICtrlRead($Edit1, @CR)
                If $editread => 0 Then
                  For $say= 1 To $editread[0]
                  GUICtrlSetData ($Label1, $editread[$say])
                  Next
                  EndIf
    EndSwitch
WEnd

 

Link to comment
Share on other sites

To read the number of written lines

A sample jquery code

<script src="https://code.jquery.com/jquery-2.2.3.min.js"></script>

<textarea id="article" rows="15" cols="30"></textarea><br>
<span id="line">linage: 0</span>

<script>
$(document).keyup(function (e) {
var text = $("textarea#article").val();   
var lines = text.split(/\r|\r\n|\n/);
var count = lines.length;
$("span#line").text("linage: "+count);
});
</script>

or

http://jsbin.com/xipamoz/1/edit?html,output

Link to comment
Share on other sites

youtuber,

If all you want to do is count the number of lines in the edit control then do something like this...

#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <String.au3>
$Form1 = GUICreate("Form1", 475, 285)
$Edit1 = GUICtrlCreateEdit("", 72, 72, 185, 89)
GUICtrlSetData(-1, "")
$Label1 = GUICtrlCreateLabel("", 296, 224, 44, 25)
$Label2 = GUICtrlCreateLabel("Number of lines to be introduced:", 104, 224, 181, 17)
local $doit = guictrlcreatebutton('Process Text',300,72,150,20)
GUISetState(@SW_SHOW)
While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        case $doit
            guictrlsetdata($label1,StringSplit(GUICtrlRead($Edit1), @CR)[0]) 
    EndSwitch
WEnd

kylomas

Forum Rules         Procedure for posting code

"I like pigs.  Dogs look up to us.  Cats look down on us.  Pigs treat us as equals."

- Sir Winston Churchill

Link to comment
Share on other sites

or like this:

#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <String.au3>
$Form1 = GUICreate("Form1", 475, 285)
$Edit1 = GUICtrlCreateEdit("", 72, 72, 185, 89)
GUICtrlSetData(-1, "")
$Label1 = GUICtrlCreateLabel("", 296, 224, 44, 25)
$Label2 = GUICtrlCreateLabel("Number of lines to be introduced:", 104, 224, 181, 17)
local $doit = guictrlcreatebutton('Process Text',300,72,150,20)
GUISetState(@SW_SHOW)
While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        case $doit
            StringReplace(GUICtrlRead($Edit1),@CR,'')
            guictrlsetdata($label1,@extended)
    EndSwitch
WEnd

 

Link to comment
Share on other sites

thank you

Immediately after the reading of this true?

#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <String.au3>
$Form1 = GUICreate("Form1", 475, 285)
$Edit1 = GUICtrlCreateEdit("", 72, 72, 185, 89)
GUICtrlSetData(-1, "")
$Label1 = GUICtrlCreateLabel("", 296, 224, 44, 25)
$Label2 = GUICtrlCreateLabel("Number of lines to be introduced:", 104, 224, 181, 17)
local $doit = guictrlcreatebutton('Process Text',300,72,150,20)
GUISetState(@SW_SHOW)

While 1
     guictrlsetdata($label1,StringSplit(GUICtrlRead($Edit1), @CR)[0])
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit

    EndSwitch
WEnd

I do not want case $doit

 

 

Link to comment
Share on other sites

?

#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <String.au3>

$Form1 = GUICreate("Form1", 475, 285)
$Edit1 = GUICtrlCreateEdit("", 72, 72, 185, 89)
GUICtrlSetData(-1, "")
$Label1 = GUICtrlCreateLabel("", 296, 224, 44, 25)
$Label2 = GUICtrlCreateLabel("Number of lines to be introduced:", 104, 224, 181, 17)
GUISetState(@SW_SHOW)

Local $lines0
While 1
     $lines = ControlCommand($Form1, "", $Edit1, "GetLineCount")
     If $lines <> $lines0 Then
        guictrlsetdata($label1, $lines)
        $lines0 = $lines
     EndIf

    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit

    EndSwitch
WEnd

 

Edited by mikell
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...