Sign in to follow this  
Followers 0
youtuber

Read the number of lines entered?

12 posts in this topic

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

 

Share this post


Link to post
Share on other sites



no, I want to know how many lines entered

Share this post


Link to post
Share on other sites

Yup, and in both of those topics the value from the edit box are split and you can get the line count from the array returned from StringSplit.

And if you'd read the help topic for StringSplit you can see how many lines would be in the edit when you split it.

1 person likes this

Share this post


Link to post
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

 

Share this post


Link to post
Share on other sites

Change this line 

If $editread => 0 Then

to

If UBound($editread) > 0 Then

 

1 person likes this

"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the universe trying to build bigger and better idiots. So far, the universe is winning."- Rick Cook

Share this post


Link to post
Share on other sites

What did you excpect that happen in your script after exit?

 

1 person likes this

Share this post


Link to post
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

Share this post


Link to post
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

1 person likes this

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

Share this post


Link to post
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

 

1 person likes this

Share this post


Link to post
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

 

 

Share this post


Link to post
Share on other sites

#12 ·  Posted (edited)

?

#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
1 person likes this

Share this post


Link to post
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
Sign in to follow this  
Followers 0