Jump to content

The number of words in the text


Recommended Posts

hi

The number of words in the text

but gives the number of words incorrectly

#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("[#] words count [#]", 1151, 675, 126, 31)
$Edit1 = GUICtrlCreateEdit("", 32, 24, 1081, 553)
GUICtrlSetData(-1, "")
$Button1 = GUICtrlCreateButton("account", 464, 592, 137, 73)
$Button2 = GUICtrlCreateButton("Clear", 688, 592, 121, 73)
$Input1 = GUICtrlCreateInput("", 608, 608, 65, 21)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
While 1
 $nMsg = GUIGetMsg()
 Switch $nMsg
  Case $GUI_EVENT_CLOSE
   Exit
Case $Button1
$AD=GUICtrlRead($Edit1)
Local $line = StringSplit(($AD), ' ', 1)
GUICtrlSetData($Input1,$line[0])
Case $Button2
GUICtrlSetData($Edit1,"")
GUICtrlSetData($Input1,"")
 EndSwitch
WEnd

thank you now

Link to comment
Share on other sites

What do you mean by "incorrectly"? No number, wrong number? If it's the wrong number, "how wrong"? Means: If the correct number is 11 it shows 9?

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

Replace

$AD = GUICtrlRead($Edit1)
with
$AD = StringReplace(GUICtrlRead($Edit1), @CRLF, " ")
so a new line control character is treated like a word separator.

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

I wrote something a while back that you could look at if you want:

Edit: I think a line in one of the functions became garbled. I don't rememebr what it was either.

Edit: Fixed.

Edited by LaCastiglione
Link to comment
Share on other sites

You had two problems in your script:

1) Line feeds didn't count as word separators

2) Multiple spaces were counted as multiple words

This should work now:

#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#region ### START Koda GUI section ### Form=
$Form1 = GUICreate("[#] word count [#]", 1151, 675, 126, 31)
$Edit1 = GUICtrlCreateEdit("", 32, 24, 1081, 553)
GUICtrlSetData(-1, "")
$Button1 = GUICtrlCreateButton("Count", 464, 592, 137, 73)
$Button2 = GUICtrlCreateButton("Clear", 688, 592, 121, 73)
$Input1 = GUICtrlCreateInput("", 608, 608, 65, 21)
GUISetState(@SW_SHOW)
#endregion ### END Koda GUI section ###
While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $Button1
            $AD = GUICtrlRead($Edit1)
            $AD = StringReplace($AD, @CRLF, " ")
            $AD = StringStripWS($AD, 7)
            Local $line = StringSplit(($AD), ' ', 1)
            GUICtrlSetData($Input1, $line[0])
        Case $Button2
            GUICtrlSetData($Edit1, "")
            GUICtrlSetData($Input1, "")
    EndSwitch
WEnd
Edited by water

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

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