Page 1 of 1

count character in a text

PostPosted: Tue Dec 06, 2016 3:21 pm
by sune
hey i really need help.
I need to count character in a text. Does anyone have an idea? how to do it.
Thought there was a character count node, but there is no.

hope someone has an idea

Re: count character in a text

PostPosted: Tue Dec 06, 2016 8:45 pm
by chrisr
Sune, is there a max count it could be. For instance, 0-100 characters? Is there an infinite number possibly? Do you need the spaces between the characters counted?

Re: count character in a text

PostPosted: Wed Dec 07, 2016 7:39 pm
by sune
I need to know how many character I have in a live text input, so I can adjust the text size to fill the full screen

Re: count character in a text

PostPosted: Wed Dec 07, 2016 10:30 pm
by justyn roy
Hi Sune,

There is not a Node that can do this, you're right, but there is a script:

VGetStringLength,VarName,String

You can assign your input to a variable with a Node then use this script to count that variable.

I hope this helps.

Justyn

Re: count character in a text

PostPosted: Thu Dec 08, 2016 4:52 pm
by justyn roy
You can write Danish characters Æ Ø Å in the text input box in wd, but they come out as "<?>" PB text layer. can I get around it? so I can write the Danish characters

_________________________________________________________________________________________________________________________________________________


To get 'special characters' from the Widget Designer into Pandoras Box, you can use the "PB Text Unicode" Node.

I just tested this node with your characters and they worked.

Re: count character in a text

PostPosted: Thu Dec 08, 2016 7:46 pm
by chrisr
Justyn,
I have a question. Where is the answer deposited? If the text read "Hello World" that would be 11 characters. I assume if you run the Script, you would end up with an answer of 11, just foggy on where that answer would show itself.

VGetStringLength,VarName,String VarName is the text you want to count, correct? Or is it where the answer of the script is placed. So if Text inside textbox1 how would this script be formulated assuming VarName is the variable

VGetStringLength,VarName,Textbox1 ?

Thanks!

Re: count character in a text

PostPosted: Thu Dec 08, 2016 8:48 pm
by justyn roy
The return is written to what ever Variable you would like - it's written as an Integer.
You can get the value from anywhere in WD - a String Variable or right from a Text Box if you'd like.
Just replace "string" with what ever you'd like to count.
For example:

Code: Select all
VGetStringLength,Length,textbox1.text


This will write an Integer with the number of characters (including spaces) to the Variable "Length" from Textbox 1.

Re: count character in a text

PostPosted: Thu Dec 08, 2016 8:52 pm
by chrisr
I tried a few different things..... forgot to put the .text after the textbox1.... Opps. Thanks for the clarification!!