Board index » delphi » cursor position goes nuts, what the heck?

cursor position goes nuts, what the heck?

I have a program where a specific time is supposed to be written out to a
specific location.
This write is in a repeat..until loop, and it is performed several (9)
times (the write, not the loop).
What occurs is a blinking cursor that jumps around after every write,
moving to different (unrelated) portions of the screen. Is there a way to
make the cursor disappear? By cursor I mean the little white " _ ". Can
this be solved using the TextColor procedure from the CRT unit? I have
tried doing that, with no success!

Can anyone help me?
Death to the little white Cursor!

-Fare

PS. If you need source code, let me know.

 

Re:cursor position goes nuts, what the heck?


In article <01beab62$81cd1b40$3c83ebd1@bryvkin>,
  "Flare" <bob3...@aol.com> wrote:

Quote
> I have a program where a specific time is supposed to be written out
to a
> specific location.
> This write is in a repeat..until loop, and it is performed several (9)
> times (the write, not the loop).
> What occurs is a blinking cursor that jumps around after every write,
> moving to different (unrelated) portions of the screen. Is there a way
to
> make the cursor disappear? By cursor I mean the little white " _ ".
Can
> this be solved using the TextColor procedure from the CRT unit? I have
> tried doing that, with no success!

> Can anyone help me?
> Death to the little white Cursor!

> -Fare

> PS. If you need source code, let me know.

Hi,

There is no way to do it hi-level, at least with BP/TP. You have to use
interrupt 10h but I can't find the values of registers you need :-( .
Try to find some documentation for BIOS interrupts (you seem to be very
hungry for knowledges, so you will need such a stuff in future anyway :)
and either use DOS-unit's Intr or (better) learn some basics of
assembly. And the little white one will not only die but, if you wish,
even grow.
For this moment I just hope you find somebody who does remember required
values.
BTW, TextColor doesn't help because cursor is not white but _negative_.

--
Best regards,
Ingmar (aka Midag)

Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.

Re:cursor position goes nuts, what the heck?


Quote
Flare (bob3...@aol.com) wrote:

[ snip ]

Quote
> Death to the little white Cursor!

  If I understand your posting correctly, you want to turn off the cursor,
right? It is possibly one of the Frequently Asked Questions, but since I've
never read the TP FAQ file, I don't know for sure. I'll provide you with a
simple, but maybe useful solution. It's more something like a hack, because
you don't really turn off the cursor, but simply hide it:

  Before you make your screen output, insert

    TextColor (0); TextBackGround (0);
    ClrScr;

  into your code. Then, change the text colour back to the setting you want.

  The text screen cursor always appears in the colour of the text cell it is
on. The code above actually fills the whole screen with black-on-black
characters, which are, of course, invisible. So, if the cursor is positioned
on one of these cells, it becomes invisible itself.

  This method, however, will not work if your output reaches the last rows,
because if the screen scrolls upwards, the new line is filled with spaces in
the current text colour, which will possibly not be black on black. If you
are getting into this sort of problems, you have to use BIOS interrupt
calls.

  Cheers, Gero

-----------------------------------------------------------------------------
  Gero Kunter                              kun...@mathematik.uni-marburg.de
-----------------------------------------------------------------------------

Re:cursor position goes nuts, what the heck?


maybe there's a pascal call, but i just use the BIOS interrupts.  this
program will turn off the cursor and then return it to the (typical)
default cursor before finishing:

-----
uses crt;

begin
 clrscr;
 writeln('no cursor');
 asm
  mov ah,0001h
  mov cx,0100h
  int 10h
 end;
 readln;
 writeln('back to normal');
 asm
  mov ah,0001h
  mov cx,0607h
  int 10h
 end;
 readln;
end.
-----

actually, you'd want to use int 10h/AH=3 to read the current cursor
type before turning it off.  then restore that type when you want
the cursor back on.  the above program doesn't do so because i'm
_very_ lazy. :P

-Assassin  assas...@reality.yps.org

=-= Join us in the fight against {*word*267}! =-=

Quote
Flare <bob3...@aol.com> wrote:

: I have a program where a specific time is supposed to be written out to a
: specific location.
: This write is in a repeat..until loop, and it is performed several (9)
: times (the write, not the loop).
: What occurs is a blinking cursor that jumps around after every write,
: moving to different (unrelated) portions of the screen. Is there a way to
: make the cursor disappear? By cursor I mean the little white " _ ". Can
: this be solved using the TextColor procedure from the CRT unit? I have
: tried doing that, with no success!

: Can anyone help me?
: Death to the little white Cursor!

: -Fare

: PS. If you need source code, let me know.

Re:cursor position goes nuts, what the heck?


JRS:  In article <7iucck$em...@surz18.HRZ.Uni-Marburg.DE> of Mon, 31 May
1999 16:12:04 in news:comp.lang.pascal.misc, Gero Kunter

Quote
<kun...@mathematik.uni-marburg.de> wrote:
>  If I understand your posting correctly, you want to turn off the cursor,
>right? It is possibly one of the Frequently Asked Questions, but since I've
>never read the TP FAQ file, I don't know for sure. I'll provide you with a
>simple, but maybe useful solution. It's more something like a hack, because
>you don't really turn off the cursor, but simply hide it:

Those who have not read Timo's FAQ can usually be relied on to give an
unsatisfactory answer.  See TSFAQP #21, via sig.  The matter is also
discussed in my http://www.merlyn.demon.co.uk/pascal.htm.

At least one utility program does not reset the screen attributes of
what it writes, and so will write "blanks" on any parts of the screen
retaining black-on-black.  The standard "empty" screen is full of spaces
of the preferred colours, as can be seen by CLD DEBUG db800:0 100

Mind you, it seems from the description of the original problem that the
cursor may be going to inappropriate positions; and that should be
investigated, rather than masked.

--
 ? John Stockton, Surrey, UK.  j...@merlyn.demon.co.uk   Turnpike v4.00   MIME. ?
  Web <URL: http://www.merlyn.demon.co.uk/> - TP/BP/&c. FAQqish topics & links.
  Timo's TurboPascal <A HREF="ftp://garbo.uwasa.fi/pc/link/tsfaqp.zip">FAQ</A>.
  <A HREF="http://www.merlyn.demon.co.uk/clpb-faq.txt">Mini-FAQ</A> of c.l.p.b.

Re:cursor position goes nuts, what the heck?


Dr John Stockton (j...@merlyn.demon.co.uk) wrote:

Quote
> JRS:  In article <7iucck$em...@surz18.HRZ.Uni-Marburg.DE> of Mon, 31 May
> 1999 16:12:04 in news:comp.lang.pascal.misc, Gero Kunter
> <kun...@mathematik.uni-marburg.de> wrote:

> >  If I understand your posting correctly, you want to turn off the cursor,
> >right? It is possibly one of the Frequently Asked Questions, but since I've
> >never read the TP FAQ file, I don't know for sure. I'll provide you with a
> >simple, but maybe useful solution. It's more something like a hack, because
> >you don't really turn off the cursor, but simply hide it:

> Those who have not read Timo's FAQ can usually be relied on to give an
> unsatisfactory answer.  See TSFAQP #21, via sig.  The matter is also
> discussed in my http://www.merlyn.demon.co.uk/pascal.htm.

  The question was "How can I make the cursor disappear?", and my offered
solution does exactly that. It is not the "clean" version (via the BIOS),
but since the original poster has stated in a different thread that he is
only 14 years old and not used to using pointers and direct memory access I
thought it might be useful to show him a way how to solve that problem
without using concepts he doesn't understand yet. That's why I gave him the
explanation of what these two, three lines of code do.

Quote
> At least one utility program does not reset the screen attributes of
> what it writes, and so will write "blanks" on any parts of the screen
> retaining black-on-black.  The standard "empty" screen is full of spaces
> of the preferred colours, as can be seen by CLD DEBUG db800:0 100

  The solution offered by me does definitely work with FPC, the compiler the
poster is using.

  Cheers, Gero

-----------------------------------------------------------------------------
  Gero Kunter                              kun...@mathematik.uni-marburg.de
-----------------------------------------------------------------------------

Re:cursor position goes nuts, what the heck?


Gero Kunter used chalk and slate for

Quote
>Dr John Stockton (j...@merlyn.demon.co.uk) wrote:

>> Those who have not read Timo's FAQ can usually be relied on to give an
>> unsatisfactory answer.  See TSFAQP #21, via sig.  The matter is also
>> discussed in my http://www.merlyn.demon.co.uk/pascal.htm.

>  The question was "How can I make the cursor disappear?", and my offered
>solution does exactly that. It is not the "clean" version (via the BIOS),
>but since the original poster has stated in a different thread that he is
>only 14 years old and not used to using pointers and direct memory access

Using interrupts is not pointer or direct memory access.

Using your solution on some programs here generates a screen that, at
program end, remains with black on black text. How is that useful.

Quote
>  The solution offered by me does definitely work with FPC, the compiler the
>poster is using.

Which he has not told us in his post.

ISTM that Dr. John, in another post, has hit the nail on the head with:

Quote
>JRS:  In article <7iucck$em...@surz18.HRZ.Uni-Marburg.DE> of Mon, 31 May
>1999 16:12:04 in news:comp.lang.pascal.misc, Gero Kunter
><kun...@mathematik.uni-marburg.de> wrote:

>Mind you, it seems from the description of the original problem that the
>cursor may be going to inappropriate positions; and that should be
>investigated, rather than masked.

Flare:

Post your problematic code here (just the bits where the cursor seems to
fly round during these writes) and we may find a better solution for you

--
Pedt

Never curse the Crocodile's mother before crossing the river

Re:cursor position goes nuts, what the heck?


Yes, I am 14, and thank you all for the help. I also use the FPK-Pascal
compiler (is that FPC?). However, the mystery behind the jumping around of
the cursor was not solved, rather bypassed. I assume that Pascal has no
problems with characters being written to portions of the screen that
already have text, and that computations do not make the cursor go nuts....

Dutifully misspelling my own name in previous posts,
-Flare

Flare <bob3...@aol.com> wrote in article
<01beab62$81cd1b40$3c83ebd1@bryvkin>...

Quote
> I have a program where a specific time is supposed to be written out to a
> specific location.
> This write is in a repeat..until loop, and it is performed several (9)
> times (the write, not the loop).
> What occurs is a blinking cursor that jumps around after every write,
> moving to different (unrelated) portions of the screen. Is there a way to
> make the cursor disappear? By cursor I mean the little white " _ ". Can
> this be solved using the TextColor procedure from the CRT unit? I have
> tried doing that, with no success!

> Can anyone help me?
> Death to the little white Cursor!

> -Fare

> PS. If you need source code, let me know.

Re:cursor position goes nuts, what the heck?


Flare used chalk and slate for

Quote
> I assume that Pascal has no
>problems with characters being written to portions of the screen that
>already have text, and that computations do not make the cursor go nuts....

Indeed. This is why Dr John and myself wondered about your code. Posting
the relevant fragment may help to solve the problem. It does sound like
you have some stray GotoXY statements in the code.
--
Pedt

Never curse the Crocodile's mother before crossing the river

Re:cursor position goes nuts, what the heck?


  First of all, I would like to make something clear: I do know that my
solution is not "by the book". It is, as I said in my original answer, "more
like a hack". But - it also does work, and is very simple. I thought that
the problem of the original poster was that he wanted to make the cursor
disappear. I didn't pay too much attention to his description of "a jumpy
cursor", because I thought it was just a description of the general cursor
movement. If the poster's main problem is, in fact, a text cursor which
moves erratically and unpredictable, then my answer was indeed quite
"unsatisfactory".

Quote
Pedt Scragg (newsmas...@pedt.demon.co.uk) wrote:

[ ... ]

Quote
> Using interrupts is not pointer or direct memory access.

  No, of course not, but using interrupts can be as confusing to a beginner
as using pointers or direct memory access.

Quote
> Using your solution on some programs here generates a screen that, at
> program end, remains with black on black text. How is that useful.

  It depends if it is important that the last text screen is still visible
after program termination. If the last output is not important, you would
just clear the screen at the end of the program with a visible colour.

Quote
> >  The solution offered by me does definitely work with FPC, the compiler
> >the poster is using.

> Which he has not told us in his post.

  That's right, but he said so in a different thread.

  And please - don't take offence by my first posting! I didn't want to
state any disregard for the FAQ or say that my suggestion is the supreme
one, preferable to all other possibilities, just to give a quick
alternative.

  Cheers, Gero

-----------------------------------------------------------------------------
  Gero Kunter                              kun...@mathematik.uni-marburg.de
-----------------------------------------------------------------------------

Re:cursor position goes nuts, what the heck?


The offending code resembles this:
                                repeat
                                        GetTime(v, w, z2, z3);
                                        red;
                                        If z2 = z then
                                                begin
                                                GoToXY(3,3);
                                                write('9');
                                                end;
                                        If z2 > z then
                                                begin
                                                        GoToXY(3,3);
                                                        write(9 - (z2 - z));
                                                        z2 := z2 + 1;
                                                        GoToXY(79,23);
                                                end;
                                        If (9 - (z2 - z)) = -1 then
                                                begin
                                                GoToXY(3,3);
                                                write('0');
                                                timeup := true;
                                                end;
                                until (keypressed) or (timeup = true);

sorry about the indentation, but it is a part of a different program...

this is NOT the optimal code for this situation, but I do not think that
the cursor should jump around anyway....the cursor jumps to positions
around the bottom right corner of the screen, around 79,20 73,24 and other
points

Re:cursor position goes nuts, what the heck?


Flare used chalk and slate for
Quote
>The offending code resembles this:
>                               repeat
>                                       GetTime(v, w, z2, z3);
>                                       red;

                                        ^^^^
You'll probably want to look for any GotoXY statements in this procedure
that are not required as you said you are getting multiple jumps.

<snip>

Quote
>                                                       z2 := z2 + 1;
>                                                       GoToXY(79,23);

                                                        ^^^^^^^^^^^^^^

This is the line to delete to solve your jumping problem in this part of
your program.

The remaining code just moves the cursor back and forth to 3,3 and the
end of the write. This line shoves the cursor to near the bottom right
hand corner.

--
Pedt

If smoking is so bad for you, how come it cures kippers?!

Other Threads