HELP! how to filter the input of the users
kindly help me..
i have this idea that the user can only type letters from a-z / A-Z
if the user type other character besides the given from the permitted characters the computer will ask again for the input it will only stop when the user have the right input.
then if the user type letter "D" (for example) then the screen will display D-Z characters. or example the input is "r" then the screen will display r-z letters..
i'm using the dos command can u help me with my prob? i have a sample program but it allows the user from entering special characters. which is my prob.. it shouldn't allow the user...
0AEE:0100 mov ah,07
0AEE:0102 int 21
0AEE:0104 mov ah,02
0AEE:0106 mov dl,al
0AEE:0108 int 21
0AEE:010A inc dl
0AEE:010C cmp dl,5a
0AEE:010F jle 108
0AEE:0111 cmp dl,5b
0AEE:0104 jz 011f
0AEE:0106 int 21
0AEE:0108 inc dl
0AEE:010A cmp dl,7a
jle 0116
int 20
>>> hope you can help thanks ^_^
[1079 byte] By [
creamoreo] at [2007-11-20 9:44:15]

# 1 Re: HELP! how to filter the input of the users
What assembler you are using for DOS?
Turbo Assembler (TASM), Macro Assembler (MASM), FASM, DOS Debug?
I could post the solution but whats the point if i dont know what you are using.
# 2 Re: HELP! how to filter the input of the users
Hi,
Creamoreo is using DOS DEBUG, so TASM is not needed. In this posting I'm sticking to DEBUG app.
Here's the solution:
;;;;;;;;;;;;;;;;;;;; See note below source code
0BBC:0100 MOV AH,07
0BBC:0102 INT 21
;;;;;;;;;;;;;;;;;;;; Settings
0BBC:0104 MOV DL,AL ;
0BBC:0106 MOV AH,02 ; DOS char-print service
0BBC:0108 MOV CL,5A ; Set parameter to know when to stop
0BBC:010A CMP DL,61 ; Is input lower-, uppercase?
0BBC:010D JB 0112
0BBC:010F ADD CL,20 ; Modify stop-param. if lowercase
;;;;;;;;;;;;;;;;;;;;; Printing loop
0BBC:0112 CMP DL,CL ; Beyond stop-parameter?
0BBC:0114 JA 011C ; Then exit pgm.
0BBC:0116 INT 21 ; Else print value in DL
0BBC:0118 INC DL ; Take next char
0BBC:011A JMP 0112
;;;;;;;;;;;;;;;;;;;;; End of printing loop
0BBC:011C MOV AX,4C00 ; Exit pgm.
0BBC:011F INT 21
Note: Before Settings section, you should include code to validate that input really is a-z/A-Z. In Hex-ASCII this means that AL is
1) between 0x41 and 0x5A (including both)
or
2) between 0x61 and 0x7A (including both).
When you add that code, offsets in Jump opcodes would also change.
Hope that helps.
Iaki Viggers