several questions about GET class

several questions about GET class

Postby plantenkennis » Fri Jun 22, 2018 9:16 am

I have a few questions about the GET class.

How do I set the numeric format
Can I detect if the ENTER key is pressed in a GET, so I can perform an action on this
How do I detect a change of GET, like every key-stroke and perform an action.

I have a window with several GETs but don't get the desired result

Code: Select all  Expand view


#DEFINE m1 CHR(109) + CHR(0185)
#DEFINE m2 CHR(109) + CHR(0178)

FUNCTION RK_InputPlantMaat(aMaat)

*to change plantsizes
*date: 20-06-2018

LOCAL oDlg, oGet1, oGet2, oGet3, oGet4, oCbxPer, oBtnOk
LOCAL nKey := 13
LOCAL aAantalPer[0]
AADD(aAantalPer, m1)
AADD(aAantalPer, m2)

/*aMaat contains the next values:
aMaat[1] > text
aMaat[2] > numeric "23.45"
aMaat[3] > text
aMaat[4] > numeric "123"
aMaat[5] > numeric "1"
*/

    DEFINE DIALOG oDlg TITLE 'Plantsizes' SIZE 500, 210
   
    @ 140, 10 SAY 'maat:' OF oDlg SIZE 100, 20
        oSay:SetAlign( 2 )
    @ 110, 10 SAY 'prijs:' OF oDlg SIZE 100, 20
        oSay:SetAlign( 3 )
    @  80, 10 SAY 'opmerking:' OF oDlg SIZE 100, 20
        oSay:SetAlign( 1 )
    @  50, 10 SAY 'plantafstand:' OF oDlg SIZE 100, 20
        oSay:SetAlign( 1 )
    @  50, 225 SAY 'per:' OF oDlg SIZE 25, 20
        oSay:SetAlign( 1 )
   
    @ 140, 115 GET oGet1 VAR aMaat[1] OF oDlg TOOLTIP "tik hier in" SIZE 200, 25
        oGet1:KeyDown( nKey )             && how can I make this work, what does it do?
    @ 110, 115 GET oGet2 VAR aMaat[2] OF oDlg TOOLTIP "tik hier in" SIZE 100, 25
        oGet2:SetNumeric()
        oGet2:SetNumFormat(9999.99)    &&this does not work correct, if I enter something and then a dot everything disappears
    @  80, 115 GET oGet3 VAR aMaat[3] OF oDlg TOOLTIP "tik hier in" SIZE 380, 25
    @  50, 115 GET oGet4 VAR aMaat[4] OF oDlg TOOLTIP "tik hier in" SIZE 100, 25
        oGet4:SetNumeric()
        oGet4:SetNumFormat("0")
    @ 50, 255 COMBOBOX oCbxPer VAR aMaat[5] SIZE 50, 25 ITEMS aAantalPer
        IF aMaat[5] > 0
            oCbxPer:SELECT(aMaat[5])
        ENDIF

    @ 10, 150 BUTTON oBtnOk PROMPT "Ok" OF oDlg ACTION (aMaat[1] := oGet1:GetText, aMaat[2] := oGet2:GetText,aMaat[3] := oGet3:GetText, aMaat[4] := oGet4:GetText, oDlg:End())
    oBtnOk:SetFocus()      &&I don't get a focus on this button, How can I make this button allways focussed?
   
   ACTIVATE DIALOG oDlg CENTERED

RETURN aMaat
Kind regards,

René Koot
User avatar
plantenkennis
 
Posts: 166
Joined: Wed Nov 25, 2015 7:13 pm
Location: the Netherlands

Re: several questions about GET class

Postby mastintin » Sun Jun 24, 2018 10:37 am

The get problem is large to solve , the initial code used the style let's say "textbox".
oGet2:SetNumFormat("###0.##")

Then he has tried to use the GEt style with pictures, but correct operation has not been achieved ..

this code
@ 110, 115 GET oGet2 VAR aMaat[2] OF oDlg TOOLTIP "tik hier in" SIZE 100, 25
oGet2:SetNumFormat("###0.##")
change to

@ 15, 90 GET oget2 VAr aMaat[2] PICTURE "9999.99" OF oDlg TOOLTIP "a number" SIZE 100, 25

Now neither one nor the other works. :-(
A ver si conseguimos que funcione ...

//-----------------
oGet1:KeyDown( nKey ) && how can I make this work, what does it do?

is not correcto to load keydown method ....

use this :

oget1:bKeyDown := { |nkey| if ( nkey == asc( "A"), msginfo( "A"), ) }

keydown method eval( bkeydown ) for nkey value ...
User avatar
mastintin
 
Posts: 1516
Joined: Thu May 27, 2010 2:06 pm

Re: several questions about GET class

Postby plantenkennis » Wed Jun 27, 2018 5:28 am

Hello Manuel,

Thanks for the information. I hope you can solve this. Maybe we/you can create a diffent GET class for numeric input like GETNUM?

I think it is importent to have a class that accepts numeric input.

The bKeydown METHOD works perfect. I looked into SOURCES and found METHOD KeyDown, but not bKeydown. How do I know when to use what name of the METHOD, because SetNumeric() is used as this and not with a 'b' in front.

There are a lot more METHODS in the GET class. Where can I find information on how to use them? Isa there more usable info in the FiveWin documentation?
Kind regards,

René Koot
User avatar
plantenkennis
 
Posts: 166
Joined: Wed Nov 25, 2015 7:13 pm
Location: the Netherlands

Re: several questions about GET class

Postby plantenkennis » Thu Jun 28, 2018 5:36 am

Hello Manuel,

I have made a little sample for a workaround with Numeric Gets. It is not so beautiful, but effective at this moment. See code:
Code: Select all  Expand view

#include "FiveMac.ch"

function Main()

   local oDlg, oGet1
   local cText1 := ""
     
   DEFINE DIALOG oDlg TITLE "TestGetNum" SIZE 400, 100 FLIPPED
   
   @ 40, 30 SAY "Number:" OF oDlg
   
   @ 40, 90 GET oGet1 VAR cText1 OF oDlg TOOLTIP "only numbers" SIZE 250, 25
        oGet1:bKeyDown := { |nkey| if ( nkey >= ASC("0") .AND. nKey <= ASC("9") .OR. nKey == ASC("."), ,( cText1 := oGet1:GetText, cText1 := oGet1:GetDelSel(LEN(cText1),LEN(cText1)))) }

   @ 10, 150 BUTTON "Ok" OF oDlg ACTION MsgInfo( cText1 )
   
   ACTIVATE DIALOG oDlg CENTERED
         
return nil
 

Now the GET only accepts numeric input and a dot as devider.
I hope this is helpfull
Kind regards,

René Koot
User avatar
plantenkennis
 
Posts: 166
Joined: Wed Nov 25, 2015 7:13 pm
Location: the Netherlands

Re: several questions about GET class

Postby mastintin » Thu Jun 28, 2018 8:48 am

Ok. Is a good solutión.
I will try to implement it in the keydown of the class and that acts if the get is of numeric type.
I'll tell you something when I have it so they can do tests.
User avatar
mastintin
 
Posts: 1516
Joined: Thu May 27, 2010 2:06 pm

Re: several questions about GET class

Postby mastintin » Thu Jun 28, 2018 3:18 pm

ok. I have tried, but is not good solution ...
If the character inserted in the middle of " numeric string" It does not work as it should.
It does not work with pulsations of keys like enter , down arrow, up arrow, etc.

I'm going to try to change how the pre-validation is done to see if we fix it a bit..
regards
User avatar
mastintin
 
Posts: 1516
Joined: Thu May 27, 2010 2:06 pm

Re: several questions about GET class

Postby plantenkennis » Thu Jun 28, 2018 6:13 pm

Hello Manuel,

I have done some more testing, and with a function I think we can make this work. For now I will post the function for as far as I am, but I think I can make the function more functional with SetPos and GetPos Methods. I will work on this tomorrow and let you know the result.
Code: Select all  Expand view

#include "FiveMac.ch"

function Main()

   local oDlg
   local cText1 := ""
   public oGet1
     
   DEFINE DIALOG oDlg TITLE "TestGetNum" SIZE 400, 100 FLIPPED
   
   @ 40, 30 SAY "Text1:" OF oDlg
   
   @ 40, 90 GET oGet1 VAR cText1 OF oDlg TOOLTIP "a string with cross" SIZE 250, 25
        oGet1:bKeyDown := { |nkey| RK_SetNum(nKey, 2) }

   @ 10, 150 BUTTON "Ok" OF oDlg ACTION MsgInfo( cText1 )
   
   ACTIVATE DIALOG oDlg CENTERED
         
return nil

FUNCTION RK_SetNum(nKey, nDec)

LOCAL cTekst := oGet1:GetText

IF nDec > 0
    if nkey >= ASC("0") .AND. nKey <= ASC("9") .OR. nKey == ASC(".")
        if AT(".", cTekst) > 0
            IF LEN(cTekst) > AT(".", cTekst) + nDec
                cTekst := SUBSTR(cTekst, 1,LEN(cTekst)-1)
            ENDIF
        endif
    ELSE
        cTekst := SUBSTR(cTekst, 1,LEN(cTekst)-1)
    ENDIF
ELSE
    if nkey >= ASC("0") .AND. nKey <= ASC("9")
    ELSE
        cTekst := SUBSTR(cTekst, 1,LEN(cTekst)-1)
    ENDIF
ENDIF
    oGet1:SetText(cTekst)   && I will put this in the oGet1:bKeyDown method

RETURN
 
Kind regards,

René Koot
User avatar
plantenkennis
 
Posts: 166
Joined: Wed Nov 25, 2015 7:13 pm
Location: the Netherlands

Re: several questions about GET class

Postby plantenkennis » Fri Jun 29, 2018 8:35 am

Hello Manuel,

I have changed the code a bit and now it looks like it is working correct. You can use the backspace, arrows left and right and enter key. Can you please revice this if it is helpfull.
Code: Select all  Expand view

#include "FiveMac.ch"

function Main()

   local oDlg,oGet1
   local cNumText := ""
   local cTekst
     
   DEFINE DIALOG oDlg TITLE "TestGetNum" SIZE 400, 100 FLIPPED
   
   @ 40, 30 SAY "Text1:" OF oDlg
   
   @ 40, 90 GET oGet1 VAR cNumText OF oDlg TOOLTIP "a string with cross" SIZE 250, 25
        oGet1:bKeyDown := { |nkey| IF (nKey < 127 .AND. nKey <> 13, (cTekst := RK_SetNum(nKey, 3, oGet1:GetText), oGet1:SetText(cTekst)), ) }
        oGet1:SetFocus()

   @ 10, 150 BUTTON "Ok" OF oDlg ACTION MsgInfo( oGet1:GetText )
   
   ACTIVATE DIALOG oDlg CENTERED
         
return nil

FUNCTION RK_SetNum(nKey, nDec, cTekst)

IF nDec > 0
    if nkey >= ASC("0") .AND. nKey <= ASC("9") .OR. nKey == ASC(".")
        if AT(".", cTekst) > 0
            IF LEN(cTekst) > AT(".", cTekst) + nDec
                cTekst := SUBSTR(cTekst, 1,LEN(cTekst)-1)
            ENDIF
        endif
    ELSE
        cTekst := SUBSTR(cTekst, 1,LEN(cTekst)-1)
    ENDIF
ELSE
    if nkey >= ASC("0") .AND. nKey <= ASC("9")
    ELSE
        cTekst := SUBSTR(cTekst, 1,LEN(cTekst)-1)
    ENDIF
ENDIF

RETURN cTekst
 
Kind regards,

René Koot
User avatar
plantenkennis
 
Posts: 166
Joined: Wed Nov 25, 2015 7:13 pm
Location: the Netherlands

Re: several questions about GET class

Postby Antonio Linares » Fri Jun 29, 2018 9:53 am

René,

Very good :-)

Glad to see that with your great feedback and Manuel's expertise, FiveMac is moving ahead ;-)
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42097
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: several questions about GET class

Postby plantenkennis » Fri Jun 29, 2018 4:24 pm

Hello Antonio,
Thank you, In my opinion FiveMac is a very good tool to build apps with. Specialy because one can use a lot of code used with FiveWin. :D

The example I posted is not completely working correct. :( When a user puts in some digits and than move back with the left arrow, he can put in alphanumeric char's. But I think that this is solvable in the function. I will make some adjustments in the next days and let you know. :D
Kind regards,

René Koot
User avatar
plantenkennis
 
Posts: 166
Joined: Wed Nov 25, 2015 7:13 pm
Location: the Netherlands

Re: several questions about GET class

Postby plantenkennis » Tue Jul 03, 2018 8:52 pm

Hello Antonio and Manuel,

I have addapted the function for the numeric input in a get. Now it works pretty good. One can put only numeric values into get and a point if specified. Also one can go back with the arrow-left and put alphanumeric values wich are not excepted. For my use it is enough, hope other users find it usefull.
Code: Select all  Expand view

#include "FiveMac.ch"

function Main()

   local oDlg,oGet1
   local cNumText := ""
   local cTekst
     
   DEFINE DIALOG oDlg TITLE "TestGetNum" SIZE 400, 100 FLIPPED
   
   @ 40, 30 SAY "Text1:" OF oDlg
   
   @ 40, 90 GET oGet1 VAR cNumText OF oDlg TOOLTIP "a string with cross" SIZE 250, 25
        oGet1:bKeyDown := { |nkey| IF (nKey < 127 .AND. nKey <> 13, (cTekst := RK_SetNum(nKey, 2, oGet1:GetText), oGet1:SetText(cTekst)), ) }
        oGet1:SetFocus()

   @ 10, 150 BUTTON "Ok" OF oDlg ACTION MsgInfo( oGet1:GetText )
   
   ACTIVATE DIALOG oDlg CENTERED
         
return nil

FUNCTION RK_SetNum(nKey, nDec, cNumString)

LOCAL nPlace := AT(CHR(nKey), cNumString)

    IF nDec > 0
        IF nkey >= ASC("0") .AND. nKey <= ASC("9") .OR. nKey == ASC(".")
            IF AT(".", cNumString) > 0
                cNumString := STRTRAN(cNumString, "..", ".")
                IF LEN(cNumString) > AT(".", cNumString) + nDec
                    cNumString := SUBSTR(cNumString, 1,LEN(cNumString)-1)
                ENDIF
            ENDIF
        ELSE
            IF nPlace == LEN(cNumString)
                cNumString := SUBSTR(cNumString, 1,LEN(cNumString)-1)
            ELSE
                cNumString := SUBSTR(cNumString, 1, nPlace-1) + SUBSTR(cNumString, nPlace+1, LEN(cNumString))
            ENDIF
        ENDIF
    ELSE
        IF nkey >= ASC("0") .AND. nKey <= ASC("9")
            *do nothng
        ELSE
            IF nPlace == LEN(cNumString)
                cNumString := SUBSTR(cNumString, 1,LEN(cNumString)-1)
            ELSE
                cNumString := SUBSTR(cNumString, 1, nPlace-1) + SUBSTR(cNumString, nPlace+1, LEN(cNumString))
            ENDIF
        ENDIF
    ENDIF

RETURN cNumString
 
Kind regards,

René Koot
User avatar
plantenkennis
 
Posts: 166
Joined: Wed Nov 25, 2015 7:13 pm
Location: the Netherlands

Re: several questions about GET class

Postby mastintin » Thu Jul 05, 2018 1:31 pm

new libs for test ( copy old libs ) . Changes for numeric gets . ( in test )
https://www.dropbox.com/s/oqwygwfuao1ta ... s.zip?dl=0

use :

local nNum := 0 // nNum -> valtype numeric
@ 40, 90 GET oGet1 VAR nNum OF oDlg PICTURE "9999.99" TOOLTIP "a string with cross" SIZE 250, 25

Not use pictures "999,999.99" only digit and decimals expresion.
User avatar
mastintin
 
Posts: 1516
Joined: Thu May 27, 2010 2:06 pm

Re: several questions about GET class

Postby plantenkennis » Thu Jul 05, 2018 6:29 pm

Hello Mauel,

Thank you, this works perfect as far as I can see now.
Kind regards,

René Koot
User avatar
plantenkennis
 
Posts: 166
Joined: Wed Nov 25, 2015 7:13 pm
Location: the Netherlands

Re: several questions about GET class

Postby Rick Lipkin » Sat Jul 07, 2018 2:54 pm

Manuel

I have been thinking about testing FiveMac and just curious if FiveMac will only run on OSX, Siera, High Siera ? .. What choice of back end's do we have ? just DBFCDX ? of can we implement ADO ( ole ) to create a client\server to a Sql Server database ?

Thanks for your feedback!
Rick Lipkin
User avatar
Rick Lipkin
 
Posts: 2665
Joined: Fri Oct 07, 2005 1:50 pm
Location: Columbia, South Carolina USA

Re: several questions about GET class

Postby mastintin » Sun Jul 08, 2018 3:09 pm

Began to develop in Leopard , It has been renewed functions deprecated until the last version Hight Sierra .
My computer is from last 2009 ( 10 years old ) and the last system can run. I think you do not have to have problems with Sierra.
I think there's a development for mysql ( Dolpin ) viewtopic.php?f=5&t=19442
Exist ODBC For Mac but I've never used it and there's no development.

Fivemac has limited functions with respect to Fivewin and its code is not 100% compatible, but it allows to do small development for Mac using Harbour.

Saludos.
User avatar
mastintin
 
Posts: 1516
Joined: Thu May 27, 2010 2:06 pm


Return to FiveMac / FivePhone (iPhone, iPad)

Who is online

Users browsing this forum: No registered users and 2 guests