Board index » delphi » turning off case sensitivity

turning off case sensitivity

is there any way that i can turn off case sensitivity in my programs,
without having to write an algorith to accept both cases when i want input?

eg, instead of writing:

uses crt;

var userinput : char
      userisright : boolean;

begin
userisright := false;
   while userisright = false do
      begin
         clrscr;
         writeln('DO YOU WISH TO CONTINUE? [Y/N] : ');
         userinput := readkey;
         if (userinput = 'y') or (userinput = 'Y') then
            begin
               userisright := true;
               continue;
            end;
         if (userinput = 'n') or (userinput = 'N') then
            begin
               userisright := true;
               donotconitnue;
            end;
         if (userinput <> 'y') and (userinput <> 'Y') and (userinput <> 'n')
and (userinput <> 'N') then
            begin
               clrscr;
               writeln('NOT CORRECT CHOICE');
               readln;
               userisright := false;
            end;
      end;
end;

i could write the same, but without having to account for both upper and
lower case 'n's and 'y's.

any help appreciated.

thank you

craig hennessey
cr...@hennessey.club24.co.uk
http://www.geocities.com/craighennessey17/index2.html

 

Re:turning off case sensitivity


Quote
In article <977318731.597...@news.tibus.net>, Craig Hennessey wrote:
>is there any way that i can turn off case sensitivity in my programs,
>without having to write an algorith to accept both cases when i want input?

>eg, instead of writing:

Yes and no. There is no such thing in general, but you can of course capture
all keyboard strokes, and then uppercase/lowercase to what you want
yourself.

Examples of how to capture keyboard input are probably in Swag
(www.gdsoft.org), the source code for the Crt unit might also help.

Re:turning off case sensitivity


Quote
Craig Hennessey wrote:

> is there any way that i can turn off case sensitivity in my programs,
> without having to write an algorith to accept both cases when i want input?

> eg, instead of writing:

> uses crt;

> var userinput : char
>       userisright : boolean;

> begin
> userisright := false;
>    while userisright = false do
>       begin
>          clrscr;
>          writeln('DO YOU WISH TO CONTINUE? [Y/N] : ');
>          userinput := readkey;

instead use userinput := UpCase (readkey)or
after reading it in use userinput := UpCase (userinput).

Quote
> ...

> thank you

> craig hennessey
> cr...@hennessey.club24.co.uk
> http://www.geocities.com/craighennessey17/index2.html

Regards Hanford

Re:turning off case sensitivity


RE: turning off case sensitivity
BY: "Craig Hennessey" <cr...@hennessey.club24.co.

Quote
><977318731.597...@news.tibus.net>
>is there any way that i can turn off case sensitivity in my programs,
>without having to write an algorith to accept both cases when i want input?
>eg, instead of writing:
>i could write the same, but without having to account for both upper and
>lower case 'n's and 'y's.
>any help appreciated.

     Use:

"function UpCase(ch: Char): Char"

Convert all of the user's input to upper case.  It is the only resolution that
I am aware of.

Art Johnston

--- Gated via The Abyss BBS -*n...@filenet.wwiv.net*-
    (714) 903-9920 -* Westminster, California*-

Re:turning off case sensitivity


In article <977318731.597...@news.tibus.net>,

Quote
Craig Hennessey <cr...@hennessey.club24.co.uk> wrote:
>is there any way that i can turn off case sensitivity in my programs,
>without having to write an algorith to accept both cases when i want input?

>eg, instead of writing:

>uses crt;

>var userinput : char
>      userisright : boolean;

>begin
>userisright := false;
>   while userisright = false do
>      begin
>         clrscr;
>         writeln('DO YOU WISH TO CONTINUE? [Y/N] : ');
>         userinput := readkey;

Not the answer  question but you must add

if userinput=#0 then [dummyvariable:=]readkey;

To flush the scan code if the user presses a function or cursor key.

Also have you heard of sets. If userinput in ['Y','N'] then...

Osmo

Re:turning off case sensitivity


On Wed, 20 Dec 2000 13:08:47 -0000, "Craig Hennessey"

Quote
<cr...@hennessey.club24.co.uk> wrote:
>is there any way that i can turn off case sensitivity in my programs,
>without having to write an algorith to accept both cases when i want input

..................snip...........

Quote
>i could write the same, but without having to account for both upper and
>lower case 'n's and 'y's.

>any help appreciated.

>thank you

>craig hennessey
>cr...@hennessey.club24.co.uk
>http://www.geocities.com/craighennessey17/index2.html

Program IgnoreSingleCharInputCase;
uses crt;

var userinput : char;
    userisright : boolean;

Procedure continue;
Begin
     Writeln('You have elected to continue.');
End;

begin
   clrscr;
   Repeat
         Repeat
              write('DO YOU WISH TO CONTINUE? [Y/N] : ');
              userinput := UpCase(readkey);
              userisright := userinput in ['N', 'Y'];
              If not userisright then writeln('NOT CORRECT CHOICE');
         Until userisright;
         if userinput = 'Y' then continue;
    Until userinput = 'N';
    ClrScr;
end.

Re:turning off case sensitivity


is there any way that i can turn off case sensitivity in my programs,
without having to write an algorith to accept both cases when i want input?

eg, instead of writing:

uses crt;

var userinput : char
      userisright : boolean;

begin
userisright := false;
   while userisright = false do
      begin
         clrscr;
         writeln('DO YOU WISH TO CONTINUE? [Y/N] : ');
         userinput := readkey;
         if (userinput = 'y') or (userinput = 'Y') then
            begin
               userisright := true;
               continue;
            end;
         if (userinput = 'n') or (userinput = 'N') then
            begin
               userisright := true;
               donotconitnue;
            end;
         if (userinput <> 'y') and (userinput <> 'Y') and (userinput <> 'n')
and (userinput <> 'N') then
            begin
               clrscr;
               writeln('NOT CORRECT CHOICE');
               readln;
               userisright := false;
            end;
      end;
end;

i could write the same, but without having to account for both upper and
lower case 'n's and 'y's.

any help appreciated.

thank you

craig hennessey
cr...@hennessey.club24.co.uk
http://www.geocities.com/craighennessey17/index2.html

Re:turning off case sensitivity


Quote
Hanford Carr <l...@mediaone.net> wrote in message

news:3A40C715.D535EE12@mediaone.net...

Quote

> Craig Hennessey wrote:

> > is there any way that i can turn off case sensitivity in my programs,
> > without having to write an algorith to accept both cases when i want
input?

> > eg, instead of writing:

> > uses crt;

> > var userinput : char
> >       userisright : boolean;

> > begin
> > userisright := false;
> >    while userisright = false do
> >       begin
> >          clrscr;
> >          writeln('DO YOU WISH TO CONTINUE? [Y/N] : ');
> >          userinput := readkey;

> instead use userinput := UpCase (readkey)or
> after reading it in use userinput := UpCase (userinput).

what does that do? ensure that it is in uper case? i might give that a go.
thank you

craig hennessey

- Show quoted text -

Quote

> > ...

> > thank you

> > craig hennessey
> > cr...@hennessey.club24.co.uk
> > http://www.geocities.com/craighennessey17/index2.html

> Regards Hanford

Re:turning off case sensitivity


"Craig Hennessey" <cr...@hennessey.club24.co.uk> schrieb im Newsbeitrag
news:977425798.315652@news.tibus.net...
Quote

> > instead use userinput := UpCase (readkey)or
> > after reading it in use userinput := UpCase (userinput).

> what does that do? ensure that it is in uper case? i might give that a go.
> thank you

Yes, it makes every lower case letter to an upper case letter, but leaves
other characters alone... Therefore, even if you type in 'y', you'll get
'Y' in UserInput and you only have to check for upper case letters...

Martin
--
E-Mail: Martin_B...@t-online.de
Homepage: http://DarkSpix.home.pages.de/

Re:turning off case sensitivity


If upcase(userinput)='Y' then go_do_this
If upcase(userinput)='N' then go_do_that

On Wed, 20 Dec 2000 13:08:47 -0000, "Craig Hennessey"

Quote
<cr...@hennessey.club24.co.uk> wrote:
>is there any way that i can turn off case sensitivity in my programs,
>without having to write an algorith to accept both cases when i want input?

Other Threads