Source language: Translate to:

search plugin wich authorize only letter A to Z on keyboard

Questions about NeoBook PlugIns

Moderator: Neosoft Support

search plugin wich authorize only letter A to Z on keyboard

Postby mycomenius » Thu Mar 03, 2011 8:44 am

Hello
I search plugin wich authorize only letter A to Z on keyboard or only the numbers 0 to 9 or the letters a b c to z.
I need to lock the other keys
I want to choose the keys authorised on the keyboard.

thanks
didier
User avatar
mycomenius
 
Posts: 78
Joined: Sun Jan 30, 2011 6:15 am
Location: France / Provence

Postby Gaev » Thu Mar 03, 2011 10:00 am

didier:

Are you looking for such restrictions when user is entering data in a NeoBook Text Entry Box ? ... or universally (i.e. in any window open on his/her desktop at the time) ?
User avatar
Gaev
 
Posts: 3737
Joined: Fri Apr 01, 2005 7:48 am
Location: Toronto, Canada

Postby mycomenius » Thu Mar 03, 2011 10:05 am

hello
I want to write some words in a text entry box using the capital letters A to Z and the - and the space key.
in another progran I need to write only 0 to 9.
it's for a program for a school

I'd like to have a plugin where I can write the list of the keys authorised.
thanks
didier
User avatar
mycomenius
 
Posts: 78
Joined: Sun Jan 30, 2011 6:15 am
Location: France / Provence

Postby Gaev » Thu Mar 03, 2011 11:35 am

didier:

If the total number of text/numbers to be entered is not huge (e.g. less than 50 characters), you can do it with native NeoBook commands.

In the StartUp section of your publication, setup a Variable to contain the valid list of characters e.g. ...
Code: Select all
SetVar "[ValidList1]" "!0123456789"
SetVar "[ValidList2]" "!ABCDEFGHIJKLMNOPQRSTUVWXYZ-"


In the Text Change section of the Text Entry Box, you can check for this ...

a) Loop through each character in the Variable (to store Text Entry contents) field ... let us refer to it as [variable] ...
Code: Select all
StrLen "[variable]" "[MaxLoop]"
Loop "1" "[MaxLoop]" "[thisLoop]"
   ...
   ... see (b) below for code here
   ...
EndLoop

b) In each iteration of the Loop ...

- extract the Nth character in this [variable] using SubStr
- see if it is in the [ValidList1] (or [ValidList2]) using SearchStr
- if not, you can delete it from the [variable] using StrReplace (replacement value is specified as "")


If you expect large amounts of characters to be typed in the Text Entry Box, you can do this checking in an event other than Text Change (where your processing must finish before the user types another key).
User avatar
Gaev
 
Posts: 3737
Joined: Fri Apr 01, 2005 7:48 am
Location: Toronto, Canada

Postby mycomenius » Thu Mar 03, 2011 11:55 am

thank you very much
didier
User avatar
mycomenius
 
Posts: 78
Joined: Sun Jan 30, 2011 6:15 am
Location: France / Provence

Postby rishi » Thu Mar 03, 2011 2:26 pm

Didier:

In the Text Change section of the Text Entry Box, you can use:

SetVar "[Temp]" ""
StrLen "[TextEntry1]" "[Len]"
Loop "1" "[Len]" "[Pos]"
SubStr "[TextEntry1]" "[Pos]" "1" "[Char]"
SearchStr "[Char]" "ABCDEFGHIJKLMNOPQRSTUVWXYZ-" "[Found]" "CaseSensitive"
If "[Found]" ">" "0"
SetVar "[Temp]" "[Temp][Char]"
EndIf
EndLoop
SetVar "[TextEntry1]" "[Temp]"



OR
SetVar "[Temp]" ""
StrLen "[TextEntry1]" "[Len]"
Loop "1" "[Len]" "[Pos]"
SubStr "[TextEntry1]" "[Pos]" "1" "[Char]"
SearchStr "[Char]" "abcdefghijklmnopqrstuvwxyz-" "[Found]" "CaseSensitive"
If "[Found]" ">" "0"
SetVar "[Temp]" "[Temp][Char]"
EndIf
EndLoop
SetVar "[TextEntry1]" "[Temp]"


OR
SetVar "[Temp]" ""
StrLen "[TextEntry1]" "[Len]"
Loop "1" "[Len]" "[Pos]"
SubStr "[TextEntry1]" "[Pos]" "1" "[Char]"
SearchStr "[Char]" "0123456789.," "[Found]" ""
If "[Found]" ">" "0"
SetVar "[Temp]" "[Temp][Char]"
EndIf
EndLoop
SetVar "[TextEntry1]" "[Temp]"


Of course, also you can add him a space or to combine them if you need it.

Regards

Gustavo
rishi
 
Posts: 71
Joined: Wed Oct 05, 2005 1:23 pm

Postby mycomenius » Fri Mar 04, 2011 7:57 am

thank you Gustavo
I can do a subroutine with it.

A question:
the program
1 read the variable textentry1
2 correct the variable textentry1 to be used in my program.

Is it possible to write automatically in the text entry box the new Textentry1?

If I write in the box AZerTY the program will change the variable Textentry1 to AZTY but on the screen the user see AZerTY in the textentry box
thanks
didier
User avatar
mycomenius
 
Posts: 78
Joined: Sun Jan 30, 2011 6:15 am
Location: France / Provence

Postby mycomenius » Fri Mar 04, 2011 8:41 am

excuse me
an error in my code textentry2 instead of textentry1

your code is OK, it delete the errors in the text entry box
thanks
didier
User avatar
mycomenius
 
Posts: 78
Joined: Sun Jan 30, 2011 6:15 am
Location: France / Provence


Return to PlugIn Discussions

Who is online

Users browsing this forum: No registered users and 1 guest