Jump to content
Sign in to follow this  
Sim0n

Another question

Recommended Posts

Sim0n

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

Share this post


Link to post
Share on other sites
Sim0n

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.

Share this post


Link to post
Share on other sites
James

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() :D

Now counts the numbers, letters and string length.

Edited by JamesB

Share this post


Link to post
Share on other sites
smashly

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

Share this post


Link to post
Share on other sites
Sim0n

Thanks, with StringLen I could finish my script (at least I hope so)

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  

×