For Programmers: Free Programming Magazines  


Home > Archive > Clipper > June 2004 > how to execute inkey() procedure inside get object









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 how to execute inkey() procedure inside get object
Krzysztof Ciura

2004-06-27, 8:55 pm


I've tried to write a simple procedure which allow
during executing get procedure applying a new value to get viriable
depending
on presing key.
I stacked :((
How to reslove this problem please help me...
for example:
I want get "NewVar" viriable (let it be string for ex.)
I start writing string from keyboard and it (string)
is putting into buffer of my viriable but this viriable must be
in range which is stored (for example) in an array and by pressing
a key (F_2) I want have acces to this array and be able to chose
new value for my viriable from this array. Is this procedure possible?
I've tryed something like this but it didn't work:

#include inkey.ch
....
NewVar := GetNew()
NewVar :row := 10
NewVar :col := 10
NewVar :name := "cVar1"
NewVar :block := { |cValue| IF (lastkey()==K_F2,;
cVar1:=func(), cvar1) }
....
function func()
return nValue


Douglas Woodrow

2004-06-27, 8:55 pm

On Sun, 27 Jun 2004 22:36:22 Krzysztof Ciura <chrisk4@wp.pl> wrote
>
>I've tried to write a simple procedure which allow
>during executing get procedure applying a new value to get viriable
>depending
>on presing key.
>I stacked :((
>How to reslove this problem please help me...
>for example:
>I want get "NewVar" viriable (let it be string for ex.)
>I start writing string from keyboard and it (string)
>is putting into buffer of my viriable but this viriable must be
>in range which is stored (for example) in an array and by pressing
>a key (F_2) I want have acces to this array and be able to chose
>new value for my viriable from this array. Is this procedure possible?
>I've tryed something like this but it didn't work:
>
>#include inkey.ch
>...
> NewVar := GetNew()
> NewVar :row := 10
> NewVar :col := 10
> NewVar :name := "cVar1"
> NewVar :block := { |cValue| IF (lastkey()==K_F2,;
> cVar1:=func(), cvar1) }
>...


Hello Krzysztof,

1) Have you considered using the SetKey() function?

2) For the actual example you gave, wouldn't it be better to do
everything in a validation function for that get object?
(i.e. automatically present a picklist of the possible array values if
the user's input is not one of them.)

Regards.
--
Douglas Woodrow

Krzych

2004-06-28, 3:55 am


Uzytkownik "Douglas Woodrow" <doug@nospam.demon.co.uk> napisal w wiadomosci
news:oWB2Tj1kU13AFwWb@acuity-ltd.demon.co.uk...
> On Sun, 27 Jun 2004 22:36:22 Krzysztof Ciura <chrisk4@wp.pl> wrote
>
> Hello Krzysztof,
>
> 1) Have you considered using the SetKey() function?

Yes but it have to send parameter depending on active get into function
launched by pressing key()
> 2) For the actual example you gave, wouldn't it be better to do
> everything in a validation function for that get object?
> (i.e. automatically present a picklist of the possible array values if
> the user's input is not one of them.)
>
> Regards.
> --
> Douglas Woodrow

Yes it's logical (user can't put different value from that in the array) but
I thougt of normal get (could be validated) and during editing pressing key
(F2) would execute function (i.e. display array)

Great thanks Douglas

Regards
Krzych


Douglas Woodrow

2004-06-28, 8:55 am

On Mon, 28 Jun 2004 08:52:13 Krzych <chrisk4@wp.pl> wrote
>
>Uzytkownik "Douglas Woodrow" <doug@nospam.demon.co.uk> napisal w wiadomosci
>news:oWB2Tj1kU13AFwWb@acuity-ltd.demon.co.uk...
>Yes but it have to send parameter depending on active get into function
>launched by pressing key()
>Yes it's logical (user can't put different value from that in the array) but
>I thougt of normal get (could be validated) and during editing pressing key
>(F2) would execute function (i.e. display array)



OK, but I'm not sure what your difficulty with SetKey() is. Try
compiling this test program to see what I mean.

// --------------------------------------------------

#include "inkey.ch"

Procedure Main()
Local GetList := {}
Local cVar1 := "One"
Local cVar2 := "Two"
CLS
@10, 10 SAY "Input 1:" GET cVar1
@12, 10 SAY "Input 2:" GET cVar2
SetKey( K_F2, {|| Special() } )
READ
SetKey( K_F2, NIL )
Return

Procedure Special()
Local oGet := GetActive()
If oGet <> NIL
If oGet:Name == "cVar1"
// (display your array here)
Alert("Input 1")
oGet:VarPut("New")
ElseIf oGet:Name == "cVar2"
Alert("Input 2")
EndIf
EndIf
Return

// --------------------------------------------------

NB You may want to guard against Special() being called recursively.
It can also sometimes be useful to pass the GetList to the Special()
procedure if you need to access any get object other than the active
one.


HTH,
--
Douglas Woodrow

Krzych

2004-06-28, 8:55 am

:))
It is so simple :)
I've worked in clipper 5 y ago and forgot almost everything
thanx
Chris

Uzytkownik "Douglas Woodrow" <doug@nospam.demon.co.uk> napisal w wiadomosci
news:4QPSyEDct+3AFwEF@acuity-ltd.demon.co.uk...
> On Mon, 28 Jun 2004 08:52:13 Krzych <chrisk4@wp.pl> wrote
wiadomosci[color=darkred]
but[color=darkred]
key[color=darkred]
>
>
> OK, but I'm not sure what your difficulty with SetKey() is. Try
> compiling this test program to see what I mean.
>
> // --------------------------------------------------
>
> #include "inkey.ch"
>
> Procedure Main()
> Local GetList := {}
> Local cVar1 := "One"
> Local cVar2 := "Two"
> CLS
> @10, 10 SAY "Input 1:" GET cVar1
> @12, 10 SAY "Input 2:" GET cVar2
> SetKey( K_F2, {|| Special() } )
> READ
> SetKey( K_F2, NIL )
> Return
>
> Procedure Special()
> Local oGet := GetActive()
> If oGet <> NIL
> If oGet:Name == "cVar1"
> // (display your array here)
> Alert("Input 1")
> oGet:VarPut("New")
> ElseIf oGet:Name == "cVar2"
> Alert("Input 2")
> EndIf
> EndIf
> Return
>
> // --------------------------------------------------
>
> NB You may want to guard against Special() being called recursively.
> It can also sometimes be useful to pass the GetList to the Special()
> procedure if you need to access any get object other than the active
> one.
>
>
> HTH,
> --
> Douglas Woodrow
>



Krzysztof Korzeniowski

2004-06-28, 8:55 pm

BTW... how can I display message depending on which get object is currently
active ?
Now I use simple @ get commands and Read.

Chris

Uzytkownik "Douglas Woodrow" <doug@nospam.demon.co.uk> napisal w wiadomosci
news:4QPSyEDct+3AFwEF@acuity-ltd.demon.co.uk...
> On Mon, 28 Jun 2004 08:52:13 Krzych <chrisk4@wp.pl> wrote
wiadomosci[color=darkred]
but[color=darkred]
key[color=darkred]
>
>
> OK, but I'm not sure what your difficulty with SetKey() is. Try
> compiling this test program to see what I mean.
>
> // --------------------------------------------------
>
> #include "inkey.ch"
>
> Procedure Main()
> Local GetList := {}
> Local cVar1 := "One"
> Local cVar2 := "Two"
> CLS
> @10, 10 SAY "Input 1:" GET cVar1
> @12, 10 SAY "Input 2:" GET cVar2
> SetKey( K_F2, {|| Special() } )
> READ
> SetKey( K_F2, NIL )
> Return
>
> Procedure Special()
> Local oGet := GetActive()
> If oGet <> NIL
> If oGet:Name == "cVar1"
> // (display your array here)
> Alert("Input 1")
> oGet:VarPut("New")
> ElseIf oGet:Name == "cVar2"
> Alert("Input 2")
> EndIf
> EndIf
> Return
>
> // --------------------------------------------------
>
> NB You may want to guard against Special() being called recursively.
> It can also sometimes be useful to pass the GetList to the Special()
> procedure if you need to access any get object other than the active
> one.
>
>
> HTH,
> --
> Douglas Woodrow
>



Douglas Woodrow

2004-06-28, 8:55 pm

On Tue, 29 Jun 2004 00:06:21 Krzysztof Korzeniowski <chrisk4@wp.pl>
wrote
>BTW... how can I display message depending on which get object is currently
>active ?


Sorry,

I don't understand the question - can you explain it in more detail?


--
Douglas Woodrow

Stephen Quinn

2004-06-28, 8:55 pm

Krzych

> Yes it's logical (user can't put different value from that in the array) but
> I thougt of normal get (could be validated) and during editing pressing key
> (F2) would execute function (i.e. display array)

It can you need to issue another READ though.
Something along the lines of (check the syntax<g> )
Eg
@ x, y GET xyz ;
WHEN {|| SetKey( K_F2, SomeFunc() ), TRUE }
VALID {|| SetKey( K_F2, NIL ), TRUE }

Function SomeFunc()

LOCAL aGetList := GetList()
LOCAL oGet := GetActive()
LOCAL aList := { // Values to choose from}

LOCAL x, y

x := oGet:Row
y := oGet:Col + 25

@ x, y GET cValue AS COMBOBOX aList // Achoice/Picklist?

READ

oGet:SetValue( cValue )

RETURN TRUE

--
HTH
Steve Quinn


Pete

2004-06-29, 3:55 am


Ï "Krzysztof Korzeniowski" <chrisk4@wp.pl> Ýãñáøå óôï ìÞíõìá
news:cbq4ta$qa5$1@nemesis.news.tpi.pl...
> BTW... how can I display message depending on which get object is

currently
> active ?
> Now I use simple @ get commands and Read.


You can do it either the easy (and ugly) or the difficult (but elegant)
way...

easy things first..
/*code*/
@ nRow, nCol get MyVar when ShowMessage( "A seemly message" )

static func ShowMessage( cMess )
@ maxrow(), 0 say padc( cMess )
return .t.
/*endcode*/

The 'difficult' way is to modify the getsys system (not recommented if you
have no done this before).
I think i 've got somewhere in my disk such a modified getsys.prg (which i
could send but) i think also you could find something similar in the Oasis.

rgrds,

---
Pete



Krzych

2004-06-29, 8:55 am

Situation is somilar to those in previous example. I have cople get-s:
@ say... get
@ say .. get
....
READ

,and want display a mesage (text) when cursor is in get field and field is
active durning executing READ but message should be visible only when
get is active and different for each get object.
I don't know wheter it's possible in this simple way or I have use more
advanced commands (get system??)

Regards
Chris

Uzytkownik "Douglas Woodrow" <doug@nospam.demon.co.uk> napisal w wiadomosci
news:DlzM$7CQJL4AFwph@acuity-ltd.demon.co.uk...
> On Tue, 29 Jun 2004 00:06:21 Krzysztof Korzeniowski <chrisk4@wp.pl>
> wrote
currently[color=darkred]
>
> Sorry,
>
> I don't understand the question - can you explain it in more detail?
>
>
> --
> Douglas Woodrow
>



Krzych

2004-06-29, 8:55 am

Oasis??
What You exactly mean ??

rgrds
Chris

U¿ytkownik "Pete" <caribou-wears@otenet.gr> napisa³ w wiadomo¶ci
news:cbr1hu$i63$1@usenet.otenet.gr...
>
> Ï "Krzysztof Korzeniowski" <chrisk4@wp.pl> Ýãñáøå óôï ìÞíõìá
> news:cbq4ta$qa5$1@nemesis.news.tpi.pl...
> currently
>
> You can do it either the easy (and ugly) or the difficult (but elegant)
> way...
>
> easy things first..
> /*code*/
> @ nRow, nCol get MyVar when ShowMessage( "A seemly message" )
>
> static func ShowMessage( cMess )
> @ maxrow(), 0 say padc( cMess )
> return .t.
> /*endcode*/
>
> The 'difficult' way is to modify the getsys system (not recommented if you
> have no done this before).
> I think i 've got somewhere in my disk such a modified getsys.prg (which

i
> could send but) i think also you could find something similar in the

Oasis.
>
> rgrds,
>
> ---
> Pete
>
>
>



Pete

2004-06-29, 8:55 am

Ï "Krzych" <chrisk4@wp.pl> Ýãñáøå óôï ìÞíõìá
news:cbrb44$hce$1@atlantis.news.tpi.pl...
> Oasis??

Yes! Oasis. ;->

> What You exactly mean ??

Sorry, I arbitrarily made the assumption that being here in CLC, you 'd also
have been there -in Oasis.
Oasis is Cliper-heads "promised land". You can get there this way:
http://www.the-oasis.net/

rgrds,

---
Pete




Stephen Quinn

2004-06-30, 3:55 am

Krzych

> ,and want display a mesage (text) when cursor is in get field and field is
> active durning executing READ but message should be visible only when
> get is active and different for each get object.


When you get to the OASIS make sure you d/l the GrumpFish and SuperLib
libraries, you should find suitable GET commands to satisfy the MESSAGE display
you want.

--
HTH
Steve Quinn


Sponsored Links







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

Copyright 2008 codecomments.com