Sim0n Posted April 30, 2008 Posted April 30, 2008 Hi. I'm wondering if there is a way to count the number of letters (signs?) in the clipboard. To get: While [number of signs in clipboard] >10 [some lines] WEnd [if less than 10 symbols, it should go here] Should be easy, but I dont know how. Please help...
James Posted April 30, 2008 Posted April 30, 2008 You need to look at ClipGet, then place the data that is found into an array. You can use StringSplit() to then split each character up. Afterwards you can run through the results looking for the characters you want to find. Blog - Seriously epic web hosting - Twitter - GitHub - Cachet HQ
Sim0n Posted April 30, 2008 Author Posted April 30, 2008 No, that's not I want I want just it counts the number of characters no matter if number, space or letter. I don't want to use array, I know that one could count but I just dont want to use that function. If the clipboard has less than 10 characters, it should go further.
James Posted April 30, 2008 Posted April 30, 2008 (edited) Like this: ; Set some variables Global $Numbers, $Symbols, $Characters ; We set $Clip to what is in the clipboard $Clip = ClipGet() ; Output what is in the clipboard ConsoleWrite("Clipboard: " & $Clip & @CRLF) ; The length of the data $Len = StringLen($Clip) ; We split up the string $ClipSplit = StringSplit($Clip, "") ; Lets count the number of characters For $i = 1 To $ClipSplit[0] If StringRegExp($ClipSplit[$i], "\d") Then $Numbers += 1 If StringRegExp($ClipSplit[$i], "\D") Then $Characters += 1 Next ; Output final values ConsoleWrite("Numbers: " & $Numbers & @CRLF) ConsoleWrite("Characters: " & $Characters & @CRLF) ConsoleWrite("Length: " & $Len & @CRLF) First time I have ever used StringRegExp() Now counts the numbers, letters and string length. Edited April 30, 2008 by JamesB Blog - Seriously epic web hosting - Twitter - GitHub - Cachet HQ
smashly Posted April 30, 2008 Posted April 30, 2008 Hi, ClipPut("I don't want, help me! Hmmm if I can't work out an array then maybe I can use StringLen()") MsgBox(0, "Clipboard contains...", StringLen(ClipGet()) & " Characters") Cheers
Sim0n Posted April 30, 2008 Author Posted April 30, 2008 Thanks, with StringLen I could finish my script (at least I hope so)
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