Home > Archive > FoxPro Help and Support > October 2005 > Why doesn't KEYBOARD work?









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Why doesn't KEYBOARD work?
Jud

2005-10-27, 8:34 am

Hi,
This is VFP6.
I have a form READER which fills it's Edit Box with the contents of a
text file using CREATE CURSOR and filling a memo field with the text
file then making it the Edit Box's CONTROLSOURCE. When everything was
set up the cursor was at the beginning of the file. Since it can get
to be a large file, I wanted the cursor to be at the end of the file
showing the latest additions.
I tried:
KEYBOARD CTRL+END >>> VFP6 wanted to know where the variable "CTRL"
is.
KEYBOARD "CTRL+END" (or "[CTRL+END]" ) >>> printed 'CTRL+END' or
[CTRL+END] at the beginning of the file.

So then, I wrote a little utility that printed out the ASCII value of
any key stroke. Found that CTRL+END is ASCII 23.
So:
KEYBOARD CHR(23) >>> cursor was at beginning of file, nothing
printed.

Thanks for any help,
Jud

Jay B

2005-10-27, 8:34 am

try keyboard "{ctrl+end}"
the magic thing missing is the curly brackets within the quotes!

Jud wrote:

> Hi,
> This is VFP6.
> I have a form READER which fills it's Edit Box with the contents of a
> text file using CREATE CURSOR and filling a memo field with the text
> file then making it the Edit Box's CONTROLSOURCE. When everything was
> set up the cursor was at the beginning of the file. Since it can get
> to be a large file, I wanted the cursor to be at the end of the file
> showing the latest additions.
> I tried:
> KEYBOARD CTRL+END >>> VFP6 wanted to know where the variable "CTRL"
> is.
> KEYBOARD "CTRL+END" (or "[CTRL+END]" ) >>> printed 'CTRL+END' or
> [CTRL+END] at the beginning of the file.
>
> So then, I wrote a little utility that printed out the ASCII value of
> any key stroke. Found that CTRL+END is ASCII 23.
> So:
> KEYBOARD CHR(23) >>> cursor was at beginning of file, nothing
> printed.
>
> Thanks for any help,
> Jud
>

Dan Freeman

2005-10-27, 8:34 am

Why not just set the control's .SelStart property to Len(control.Value)?

Dan

Jud wrote:
> Hi,
> This is VFP6.
> I have a form READER which fills it's Edit Box with the contents of a
> text file using CREATE CURSOR and filling a memo field with the text
> file then making it the Edit Box's CONTROLSOURCE. When everything was
> set up the cursor was at the beginning of the file. Since it can get
> to be a large file, I wanted the cursor to be at the end of the file
> showing the latest additions.
> I tried:
> KEYBOARD CTRL+END >>> VFP6 wanted to know where the variable "CTRL"
> is.
> KEYBOARD "CTRL+END" (or "[CTRL+END]" ) >>> printed 'CTRL+END' or
> [CTRL+END] at the beginning of the file.
>
> So then, I wrote a little utility that printed out the ASCII value of
> any key stroke. Found that CTRL+END is ASCII 23.
> So:
> KEYBOARD CHR(23) >>> cursor was at beginning of file, nothing
> printed.
>
> Thanks for any help,
> Jud



Jud

2005-10-27, 8:34 am

Thank you both. Those little curly brackets worked!
Jay, how did you learn about the curly brackets? I just entered "{"
as the key word in the Index section of Help, and it led me to "\<" for
marking the activating character in a Button Caption! There is no
entry in the Index list for "{", "{}" or "}", they all lead to the "\<"
section! There are too many "magic things" to miss in this system.

Thanks again to you both,
Jud

Dan Freeman

2005-10-27, 8:34 am

From the KEYBOARD help topic:

For a listing of key labels, see ON KEY LABEL.

Dan

Jud wrote:
> Thank you both. Those little curly brackets worked!
> Jay, how did you learn about the curly brackets? I just entered "{"
> as the key word in the Index section of Help, and it led me to "\<"
> for marking the activating character in a Button Caption! There is no
> entry in the Index list for "{", "{}" or "}", they all lead to the
> "\<" section! There are too many "magic things" to miss in this
> system.
>
> Thanks again to you both,
> Jud



Jud

2005-10-27, 8:34 am

Hi Dan,
I had already looked in "ON KEY LABEL". There is no mention of curly
brackets or KEYBOARD in that section (I used Find). I do remember,
that during the hour or 2 I spent looking, I found the "KEYBOARD
"[CTRL+END]" idea. But, it didn't move the cursor it just printed
[CTRL+END] at the beginning of the file.

I also tried your suggestion:
Why not just set the control's .SelStart property to
Len(control.Value)?

I tried:
THISFORM.FILE_TEXT.SELSTART = LEN(FILE_TEXT.VALUE)
Which got an error: "Can' t find variable 'FILE_TEXT'" or something
like that.
I then tried:
THISFORM.FILE_TEXT.SELSTART = LEN(THISFORM.FILE_TEXT.VALUE)
No error, but the cursor didn't move either.

BTW is there a way to search through all of Help in one pass for a
phrase like "{}" or "CTRL+END"?

And why didn't "KEYBOARD CHR(23)" work?

Thanks again,
Jud

Fred Taylor

2005-10-27, 8:34 am

I'd suggest you try the:

THISFORM.FILE_TEXT.SELSTART = LEN(THISFORM.FILE_TEXT.VALUE)
line again as that should work. It may depend on where you put it.

If I put this code in the .Click of some button, it most certainly does move
the cursor:

THISFORM.FILE_TEXT.VALUE = "SomeFileName"
THISFORM.FILE_TEXT.SELSTART = LEN(THISFORM.FILE_TEXT.VALUE)
THISFORM.FILE_TEXT.SETFOCUS()

--
Fred
Microsoft Visual FoxPro MVP


"Jud" <judsonrp@fastmail.fm> wrote in message
news:1129820109.581463.285870@g14g2000cwa.googlegroups.com...
> Hi Dan,
> I had already looked in "ON KEY LABEL". There is no mention of curly
> brackets or KEYBOARD in that section (I used Find). I do remember,
> that during the hour or 2 I spent looking, I found the "KEYBOARD
> "[CTRL+END]" idea. But, it didn't move the cursor it just printed
> [CTRL+END] at the beginning of the file.
>
> I also tried your suggestion:
> Why not just set the control's .SelStart property to
> Len(control.Value)?
>
> I tried:
> THISFORM.FILE_TEXT.SELSTART = LEN(FILE_TEXT.VALUE)
> Which got an error: "Can' t find variable 'FILE_TEXT'" or something
> like that.
> I then tried:
> THISFORM.FILE_TEXT.SELSTART = LEN(THISFORM.FILE_TEXT.VALUE)
> No error, but the cursor didn't move either.
>
> BTW is there a way to search through all of Help in one pass for a
> phrase like "{}" or "CTRL+END"?
>
> And why didn't "KEYBOARD CHR(23)" work?
>
> Thanks again,
> Jud
>



Dan Freeman

2005-10-27, 8:34 am

What Fred said. <g>

As for the braces, here's another quote from the KEYBOARD help topic:

If cKeyboardValue is a key label, it must be enclosed in braces and quotes.
For example:

KEYBOARD '& #123;CTRL+LEFTARROW}
'Dan
Jud wrote:
> Hi Dan,
> I had already looked in "ON KEY LABEL". There is no mention of curly
> brackets or KEYBOARD in that section (I used Find). I do remember,
> that during the hour or 2 I spent looking, I found the "KEYBOARD
> "[CTRL+END]" idea. But, it didn't move the cursor it just printed
> [CTRL+END] at the beginning of the file.
>
> I also tried your suggestion:
> Why not just set the control's .SelStart property to
> Len(control.Value)?
>
> I tried:
> THISFORM.FILE_TEXT.SELSTART = LEN(FILE_TEXT.VALUE)
> Which got an error: "Can' t find variable 'FILE_TEXT'" or something
> like that.
> I then tried:
> THISFORM.FILE_TEXT.SELSTART = LEN(THISFORM.FILE_TEXT.VALUE)
> No error, but the cursor didn't move either.
>
> BTW is there a way to search through all of Help in one pass for a
> phrase like "{}" or "CTRL+END"?
>
> And why didn't "KEYBOARD CHR(23)" work?
>
> Thanks again,
> Jud



Fernando D. Bozzo

2005-10-27, 8:34 am

Hi Jud:

I see various topics on the same thread, and may be better to separate each one.

1) In the "KEYBOARD" help tipoc you have this example:

KEYBOARD '& #123;CTRL+LEFTARROW}
'

So, "ON KEY LABEL" have nothing to do with this, and remember that this command puts this in the keyboard buffer, so this will be executed when all other commands have executed and the application is in IDLE mode.

For example:
KEYBOARD "{Ctrl+End}"
THISFORM.text1.SELSTART = LEN(THISFORM.text1.VALUE)

The Ctrl+End command will be executed after the SelStart assign.


2) This is an example of using SelStart (cut & paste in a new prg):
********************
********************
**********
DEFINE CLASS form1 AS FORM

DOCREATE = .T.
CAPTION = "Form1"
NAME = "Form1"

ADD OBJECT text1 AS TEXTBOX WITH ;
VALUE = "this is some text", ;
HEIGHT = 23, ;
LEFT = 60, ;
TOP = 80, ;
WIDTH = 240, ;
NAME = "Text1"

ADD OBJECT text2 AS TEXTBOX WITH ;
VALUE = "this is more text", ;
HEIGHT = 23, ;
LEFT = 60, ;
TOP = 132, ;
WIDTH = 240, ;
NAME = "Text2"

ADD OBJECT label1 AS LABEL WITH ;
CAPTION = "This textbox should have the cursor on the end", ;
HEIGHT = 17, ;
LEFT = 60, ;
TOP = 60, ;
WIDTH = 256, ;
NAME = "Label1"

PROCEDURE ACTIVATE
THISFORM.text1.SELSTART = LEN(THISFORM.text1.VALUE)
ENDPROC
ENDDEFINE
********************
********************
**********

As you see, this should be used in the Activate event or in a button click event, never in INIT or LOAD (you don't mention when you are using it)


3) CHR(23) is equivalent of:
Alt + i
Ctrl + w
....but it is an ASCII literal, it isn't considered as a *real* Control command like a KEYBOARD "{Ctrl+End}"



Regards,

Fernando D. Bozzo
VFP6/SP5
Madrid/Spain


"Jud" <judsonrp@fastmail.fm> escribió en el mensaje news:1129820109.581463.285870@g14g2000cwa.googlegroups.com...
> Hi Dan,
> I had already looked in "ON KEY LABEL". There is no mention of curly
> brackets or KEYBOARD in that section (I used Find). I do remember,
> that during the hour or 2 I spent looking, I found the "KEYBOARD
> "[CTRL+END]" idea. But, it didn't move the cursor it just printed
> [CTRL+END] at the beginning of the file.
>
> I also tried your suggestion:
> Why not just set the control's .SelStart property to
> Len(control.Value)?
>
> I tried:
> THISFORM.FILE_TEXT.SELSTART = LEN(FILE_TEXT.VALUE)
> Which got an error: "Can' t find variable 'FILE_TEXT'" or something
> like that.
> I then tried:
> THISFORM.FILE_TEXT.SELSTART = LEN(THISFORM.FILE_TEXT.VALUE)
> No error, but the cursor didn't move either.
>
> BTW is there a way to search through all of Help in one pass for a
> phrase like "{}" or "CTRL+END"?
>
> And why didn't "KEYBOARD CHR(23)" work?
>
> Thanks again,
> Jud
>

Jud

2005-10-27, 8:34 am

Hi everyone,

Thanks for your help, I stand corrected:

1) I realize that I put more than one question in the same topic. I
know it is harder for you to find the problems on which you feel you
can offer help, and I'm sorry. I tend to think seeing the problem in
context with some of the rest of the project and some history is
helpful, but I'll try to stay on Topic.

2) I did find KEYBOARD "{Ctrl+End}" in my Help. The font it uses
for commands is very delicate and I thought it said KEYBOARD
"[Ctrl+End]" with my old eyes.

3) I put this code in the form's Activate procedure:
THISFORM.FILE_TEXT.Refresh
THISFORM.FILE_TEXT.SETFOCUS
KEYBOARD "{CTRL+END}" && move to end of file.
and it works.
But, this:
THISFORM.FILE_TEXT.Refresh
THISFORM.FILE_TEXT.SELSTART = LEN(THISFORM.FILE_TEXT.VALUE)
THISFORM.FILE_TEXT.SETFOCUS
*** KEYBOARD "{CTRL+END}" && move to end of file.
does not move the cursor from the beginning of the file in the Edit
Box.

4) This is my first Project in VFP6 (I spent about 12 years using
FoxPro 1.02 DOS before I retired a few years ago). I use the Form
Designer exclusively because I find Object Oriented Programming
extremely difficult to understand.

5) What does <g> mean?

Thanks for putting up with me and for your help,
Jud

Fernando D. Bozzo

2005-10-27, 8:34 am

Hi Jud:

If you want to move the record pointer of a table, there is no need to
Ctrl+End, you can SELECT that table and GO BOTTOM

> THISFORM.FILE_TEXT.SELSTART = LEN(THISFORM.FILE_TEXT.VALUE)
> THISFORM.FILE_TEXT.SETFOCUS

In this example you are using the commands in the wrong orden, because the
control must obtain the focus first then position the cursor. You can think
the focus like a mini-window from wich you can see just one control at a
time. First you move your mini-window on the control you want to work with,
then you alter the cursor position inside that control.
The right order, then, is:
THISFORM.FILE_TEXT.SETFOCUS
THISFORM.FILE_TEXT.SELSTART = LEN(THISFORM.FILE_TEXT.VALUE)

I know that the object oriented programming is a change of mind from
structured programming, but it really makes the programming easier, and you
need programming structured inside OOP methods. There are many documents
(VFP Help is good) and examples in the Visual FoxPro directory (Samples) and
on the web.


Regards,

Fernando D. Bozzo
VFP6/SP5
Madrid/Spain


"Jud" <judsonrp@fastmail.fm> escribió en el mensaje
news:1129916145.670713.317770@g44g2000cwa.googlegroups.com...
> Hi everyone,
>
> Thanks for your help, I stand corrected:
>
> 1) I realize that I put more than one question in the same topic. I
> know it is harder for you to find the problems on which you feel you
> can offer help, and I'm sorry. I tend to think seeing the problem in
> context with some of the rest of the project and some history is
> helpful, but I'll try to stay on Topic.
>
> 2) I did find KEYBOARD "{Ctrl+End}" in my Help. The font it uses
> for commands is very delicate and I thought it said KEYBOARD
> "[Ctrl+End]" with my old eyes.
>
> 3) I put this code in the form's Activate procedure:
> THISFORM.FILE_TEXT.Refresh
> THISFORM.FILE_TEXT.SETFOCUS
> KEYBOARD "{CTRL+END}" && move to end of file.
> and it works.
> But, this:
> THISFORM.FILE_TEXT.Refresh
> THISFORM.FILE_TEXT.SELSTART = LEN(THISFORM.FILE_TEXT.VALUE)
> THISFORM.FILE_TEXT.SETFOCUS
> *** KEYBOARD "{CTRL+END}" && move to end of file.
> does not move the cursor from the beginning of the file in the Edit
> Box.
>
> 4) This is my first Project in VFP6 (I spent about 12 years using
> FoxPro 1.02 DOS before I retired a few years ago). I use the Form
> Designer exclusively because I find Object Oriented Programming
> extremely difficult to understand.
>
> 5) What does <g> mean?
>
> Thanks for putting up with me and for your help,
> Jud
>



Jud

2005-10-27, 8:34 am

Hi Fernando,

Thanks for your quick response.
I know about GO BOTTOM, but this is a text file appended into a Memo
field in a Cursor with only one record.

I will experiment with this code in an effort to keep learning.

Oh, and check out my new Topic "My Form gets 4 pixels wider, by itself,
each time I Modify it."

Thanks again,
Jud

Sponsored Links





Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive | Programming forum archive

Copyright 2008 droptable.com