youtuber Posted May 8, 2016 Posted May 8, 2016 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
InunoTaishou Posted May 8, 2016 Posted May 8, 2016 The same way you would do it in this topic, or this post.
InunoTaishou Posted May 8, 2016 Posted May 8, 2016 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. youtuber 1
youtuber Posted May 8, 2016 Author Posted May 8, 2016 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
Bowmore Posted May 8, 2016 Posted May 8, 2016 Change this line If $editread => 0 Then to If UBound($editread) > 0 Then youtuber 1 "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
AutoBert Posted May 8, 2016 Posted May 8, 2016 What did you excpect that happen in your script after exit? youtuber 1
youtuber Posted May 10, 2016 Author Posted May 10, 2016 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
kylomas Posted May 10, 2016 Posted May 10, 2016 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 youtuber 1 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
AutoBert Posted May 10, 2016 Posted May 10, 2016 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 youtuber 1
youtuber Posted May 10, 2016 Author Posted May 10, 2016 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
mikell Posted May 10, 2016 Posted May 10, 2016 (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 May 10, 2016 by mikell youtuber 1
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now