Problem with get / Tget object

Post Reply
User avatar
eduardofreni
Posts: 12
Joined: Sat Aug 26, 2006 12:27 am
Location: Florence (Italy)

Problem with get / Tget object

Post by eduardofreni »

I use in the get object, bChange for to know step by step the characters typewrite in a variable.
Fivewin report across nkey the chr number of last character typed.
But if i call the VarGet() method for read the total character typed, he not return me, nothing for the first 2 character. After typede 3 character the method return me the first character typed.

I send the code sample, test it. It's Very strange. This limit the use of get system.
I have fivewin 2.7, xHarbour 99.60.
The code:

#include "FiveWin.ch"

function Main()

local oDlg, oGet1, n1 := " "

DEFINE DIALOG oDlg TITLE "Testing Gets"

@ 1, 1 GET oGet1 VAR n1 SIZE 80, 11

oGet1:bChange={ |nkey , nFlag| test(nkey,nFlag,@oGet1)}

@ 3, 11 BUTTON "Ok" ACTION oDlg:End()

ACTIVATE DIALOG oDlg CENTERED

return nil

procedure test(nkey,nFlag,oGet1)
Local CharContainer
CharContainer := oGet1:VarGet()
? CharContainer
? chr(nkey)
msgalert("You Write "+CharContainer,"Write?")
return
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Post by Antonio Linares »

Eduardo,

Try it this way:

Code: Select all

#include "FiveWin.ch" 

function Main() 

local oDlg, oGet1, n1 := Space( 20 ) 

DEFINE DIALOG oDlg TITLE "Testing Gets" 

@ 1, 1 GET oGet1 VAR n1 SIZE 80, 11 

oGet1:bChange={ |nkey , nFlag| test(nkey,nFlag, oGet1, oDlg)} 

@ 3, 11 BUTTON "Ok" ACTION oDlg:End() 

ACTIVATE DIALOG oDlg CENTERED 

return nil 

procedure test(nkey,nFlag,oGet1,oDlg) 
   Local CharContainer 
   CharContainer := oGet1:GetText() 
   oDlg:SetText( CharContainer )
return
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
eduardofreni
Posts: 12
Joined: Sat Aug 26, 2006 12:27 am
Location: Florence (Italy)

the dialog go to error

Post by eduardofreni »

When i test with fwh the sample give an error at this row:
oDlg:SetText( CharContainer )
To me seems that the problem is in the dialog that does not have the method.

But, if i take the character in CharContainer and add chr(nKey) the problem are solved.
Is solvable the problema, for get all character from buffer of keyboard?

I know how this problem more complicated. It is necessary to go to touch the winproc. Excuse me.

Many thanks for your prompt answer.
Best Regards.
Saludos
Eduardo Freni

PS excuse for bad english
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Post by Antonio Linares »

Eduardo,

Please copy and build the entire sample that I have posted. It works fine.

Probably you are missing oDlg in your code.
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
eduardofreni
Posts: 12
Joined: Sat Aug 26, 2006 12:27 am
Location: Florence (Italy)

Ok work

Post by eduardofreni »

Is true, i not have passed, the oDlg at procedure test.
Now i passed and no error in procedure.
But, how to see CharContainer not contain all character typed in the string, but the string with character -1, character captured from nkey

Thanks for all.
Best regards

#include "FiveWin.ch"

function Main()

local oDlg, oGet1, n1 := " "

DEFINE DIALOG oDlg TITLE "Testing Gets"

@ 1, 1 GET oGet1 VAR n1 SIZE 80, 11

oGet1:bChange={ |nkey , nFlag| test(nkey,nFlag,@oGet1,@oDlg)}

@ 3, 11 BUTTON "Ok" ACTION oDlg:End()

ACTIVATE DIALOG oDlg CENTERED

return nil

procedure test(nkey,nFlag,oGet1,oDlg)
Local CharContainer
CharContainer := oGet1:GetText()
oDlg:SetText( CharContainer )
? chr(nkey)
? CharContainer
return
User avatar
James Bott
Posts: 4654
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA
Contact:

Post by James Bott »

Try this:

procedure test(nkey,nFlag,oGet1,oDlg)
Local CharContainer
CharContainer := oGet1:varGet() // changed
msgInfo( charContainer )
oDlg:SetText( CharContainer )
? chr(nkey)
? CharContainer
return
User avatar
Silvio
Posts: 3107
Joined: Fri Oct 07, 2005 6:28 pm
Location: Teramo,Italy

Post by Silvio »

Edo, why this PHOTO ?
<-------------------------<
Best Regards, Saludos

Falconi Silvio
User avatar
eduardofreni
Posts: 12
Joined: Sat Aug 26, 2006 12:27 am
Location: Florence (Italy)

My photo?

Post by eduardofreni »

Hello Silvio, how are you?
My photo?
Becouse is the only in black and white.
For reduce the dimensions of image.

Why not?

Buona vida Silvio.

Eduardo Freni
User avatar
eduardofreni
Posts: 12
Joined: Sat Aug 26, 2006 12:27 am
Location: Florence (Italy)

Estimando James Bott

Post by eduardofreni »

It is one unexpected and appreciate surprised your mail.

I study and appreciate your manual on FiveWin Class. Me has been much profit.

For the procedure the problem is this.
I must extract the characters, who come directly typed, from the buffer of an object get. Possibly the entire string, not a character for time.
I cannot attend the valid, I must make it before.
For this I have made this post.

I have mistaken method?
I do not know, task to have made how much was necessary.
OnChange, would have gives the possibility to me to approach the buffer of the characters written in the get.

Thanks for all James Bott.

Best Regards

Eduardo Freni
User avatar
James Bott
Posts: 4654
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA
Contact:

Post by James Bott »

Eduardo,

Thanks for the kind words.

Here is an example of how to get the contents of a GET including the last keystroke.

James

Code: Select all

// Testing getting GET buffer including lastkeystroke

#include "fivewin.ch"

function main
   local oDlg,oGet,cTest:=space(10)
   define dialog oDlg
   @ 1,1 get oGet var cTest
   oGet:bChange:={|nKey| oDlg:setText(getData(oGet,nKey)) }
   activate dialog oDlg
return nil


Function getData(oGet,nKey)
   Local cBuffer := oGet:oGet:Buffer
   Local cChar:= if(nKey==VK_BACK,"",chr(nKey))

   if nKey<>VK_RETURN
      cBuffer:= Stuff(cBuffer, oGet:nPos, 1, cChar )
   endif

   // Now cBuffer contains the last char typed

return cBuffer
Post Reply