TextEntry string count and expand

Questions about using NeoBook's scripting language

Moderator: Neosoft Support

Locked
User avatar
Dudus
Posts: 120
Joined: Wed Sep 07, 2005 12:15 pm
Location: Hungary, Budapest

TextEntry string count and expand

Post by Dudus »

Hi,

i have a Text Entry with 20 char place, I need to count the entered words and if the word is less than 20 char for example only 5 char
than word+15char with space like this:

Yesss_______________ (ofcourse _ now is space)

How to do that?
Thanks!
Dudus
User avatar
Gaev
Posts: 3782
Joined: Fri Apr 01, 2005 7:48 am
Location: Toronto, Canada
Contact:

Re: TextEntry string count and expand

Post by Gaev »

Dudus:

Try this ...

Code: Select all

... append with spaces to make length of 20 characters
... assumes that string will always be <= 20

... calculate required spaces
StrLen "[TextEntry20]" "[TextEntry20Len]"
Math "20-[TextEntry20Len]" "0" "[RequiredSpaces]"

... make string of required spaces
SetVar "[TwentySpaces]" "                    "
...SetVar "[TwentySpaces]" "12345678901234567890"
SubStr "[TwentySpaces]" "1" "[RequiredSpaces]" "[RequiredSpacesText]"

... append
SetVar "[RequiredText]" "[TextEntry20][RequiredSpacesText]"

... verify
StrLen "[RequiredText]" "[RequiredTextLen]"
AlertBox "Results" "[TextEntry20Len] ... [RequiredSpaces] ... [RequiredTextLen] ... <[RequiredText]>"
User avatar
Dudus
Posts: 120
Joined: Wed Sep 07, 2005 12:15 pm
Location: Hungary, Budapest

Re: TextEntry string count and expand

Post by Dudus »

Hello Gave!

Works perfect... :) Thank you verry much!

Dudus
Locked