Incremental xBrowse-ARRAY-search from GET ?

Incremental xBrowse-ARRAY-search from GET ?

Postby ukoenig » Fri Jun 14, 2013 12:31 pm

Hello,

I have a little problem :
I scan a Array for a result-
The results of Buttonaction and bKeydown are different using the same function.

The first image ( bkeydown is used ) returns the first array-result ( F1 )
The second from buttonaction is OK
Both are using the same function !!!

Image

@ 4, 175 GET oGet1 VAR cGet1 PICTURE "!!!!!!!!!!" ;
SIZE 105, 20 OF oFld:aDialogs[ 2 ] PIXEL FONT oFont3 UPDATE
oGet1:bKeyDown := { | nKey, nFlags | ;
IIF( nKey == 13, ( nKey1 := GET_KEYS(ALLTRIM(cGet1)), oSay[4]:Refresh() ), NIL ) }
oGet1:bGotFocus := {|| cGet1 := SPACE(10), aTable := {}, oGet1:Refresh() }


@ 30, 300 BTNBMP oBtn1 OF oFld:aDialogs[ 2 ] ;
SIZE 28, 40 PIXEL;
NOBORDER ;
PROMPT "&Show" ;
ACTION ( nKey1 := GET_KEYS(ALLTRIM(cGet1)), oSay[4]:Refresh() );
FILENAME c_path1 + "Help.Bmp" ;
FONT oFont2 2007 ;
TOP
oBtn1:lTransparent := .t.
oBtn1:cToolTip = { "Array " + CRLF + "result","nKey", 1, CLR_BLACK, 14089979 }
oBtn1:SetColor( 0, )

Code: Select all  Expand view

FUNCTION GET_KEYS(cGet1)
LOCAL I, nLen := LEN( ALLTRIM( cGet1 ) )

I := 1
nStart := 111 // F1 - 12
FOR I := 1 TO 24
    nStart++
    cNo := LTRIM(STR(I))
    AADD(aTable, { "F" + cNo, nStart })
NEXT

AADD(aTable, { "LBUTTON", 1 })
AADD(aTable, { "RBUTTON", 2 })
AADD(aTable, { "CANCEL", 3 })
AADD(aTable, { "MBUTTON", 4 })
AADD(aTable, { "BACK", 8 })
AADD(aTable, { "TAB", 9 })
AADD(aTable, { "CLEAR", 12 })
AADD(aTable, { "RETURN", 13 })
AADD(aTable, { "SHIFT", 16 })
AADD(aTable, { "CONTROL", 17 })
AADD(aTable, { "MENU", 18 })
AADD(aTable, { "PAUSE", 19 })
AADD(aTable, { "CAPITAL", 20 })
AADD(aTable, { "ESCAPE", 27 })
AADD(aTable, { "SPACE", 32 })
AADD(aTable, { "PRIOR", 33 })
AADD(aTable, { "NEXT", 34 })
AADD(aTable, { "END", 35 })
AADD(aTable, { "HOME", 36 })
AADD(aTable, { "LEFT", 37 })
AADD(aTable, { "UP", 38 })
AADD(aTable, { "RIGHT", 39 })
AADD(aTable, { "DOWN", 40 })
AADD(aTable, { "SELECT", 41 })

AADD(aTable, { "PRINT", 42 })
AADD(aTable, { "EXECUTE", 43 })
AADD(aTable, { "SNAPSHOT", 44 })
AADD(aTable, { "INSERT",  45 })
AADD(aTable, { "DELETE", 46 })
AADD(aTable, { "HELP", 47 })
AADD(aTable, { "NUMPAD0", 96 })
AADD(aTable, { "NUMPAD1", 97 })
AADD(aTable, { "NUMPAD2", 98 })
AADD(aTable, { "NUMPAD3", 99 })
AADD(aTable, { "NUMPAD4", 100 })
AADD(aTable, { "NUMPAD5", 101 })
AADD(aTable, { "NUMPAD6", 102 })
AADD(aTable, { "NUMPAD7", 103 })
AADD(aTable, { "NUMPAD8", 104 })
AADD(aTable, { "NUMPAD9", 105 })
AADD(aTable, { "MULTIPLY", 106 })
AADD(aTable, { "ADD", 107 })
AADD(aTable, { "SEPARATOR", 108 })
AADD(aTable, { "SUBTRACT", 109 })
AADD(aTable, { "DECIMAL", 110 })
AADD(aTable, { "DIVIDE", 111 })
AADD(aTable, { "NUMLOCK", 144 })
AADD(aTable, { "SCROLL", 145 })

nKey1 := 0
I := 1
FOR I := 1 TO LEN( aTable )
    IF SUBSTR(aTable[I][1], 1, nLen ) = cGet1
        nKey1 := aTable[I][2]
        EXIT
    ENDIF   
NEXT

RETURN nKey1
 


Best Regards
Uwe :?:
Last edited by ukoenig on Sun Jun 16, 2013 11:56 am, edited 3 times in total.
Since 1995 ( the first release of FW 1.9 )
i work with FW.
If you have any questions about special functions, maybe i can help.
User avatar
ukoenig
 
Posts: 4043
Joined: Wed Dec 19, 2007 6:40 pm
Location: Germany

Re: Incremental xBrowse-ARRAY-search from GET ?

Postby ukoenig » Sun Jun 16, 2013 9:02 am

I found a working solution to get a result from a GET with incremental ARRAY-search :
Would be nice, to jump to the xBrowse-cell as well.

Image

Image

Image

@ 4, 185 GET oGet1 VAR cGet1 PICTURE "@" ;
SIZE 20, 20 OF oFld:aDialogs[ 1 ] PIXEL FONT oFont3 UPDATE // ;
oGet1:bChange := {|| cKey1 := ASC(cGet1), oSay[6]:Refresh(), ;
oBrw1:Seek( cKey1 ) } //Array-search needed for cell-focus !!!
oGet1:bGotFocus := {|| cGet1 := " ", oGet1:Refresh(), cKey1 := "???", oSay[6]:Refresh() }

@ 30, 25 XBROWSE oBrw1 SIZE 232, 178 PIXEL OF oFld:aDialogs[ 1 ] ;
COLUMNS 1, 2, 3, 4, 5, 6, 7, 8 ;
HEADERS "CHR","ASC", "CHR","ASC", "CHR","ASC", "CHR","ASC" ;
COLSIZES 50, 50, 50, 50, 50, 50, 50, 50 FONT oFont2 ;
ARRAY aPrint1 LINES FASTEDIT CELL

oBrw1:lHScroll := .F.

WITH OBJECT oBrw1
:nEditTypes := EDIT_GET
:CreateFromCode()
END
I := 1
FOR I := 1 to 8
oBrw1:aCols[ I ]:nDataStrAlign := AL_CENTER
NEXT


The xBrowse-array aPrint1 splitted in 4 sections ( each 2 cols ) :

Code: Select all  Expand view

FUNCTION MAKE_ASC( aPrint1 )
LOCAL I, nMaxiArray
LOCAL aArray1 := {}
LOCAL aArray2 := {}
LOCAL aArray3 := {}
LOCAL aArray4 := {}

I := 1
FOR I := 1 TO LEN( cCHAR1)
    AADD(aArray1, { SUBSTR(cCHAR1,I,1), ASC(SUBSTR(cCHAR1,I,1)) })
NEXT
//nMaxiArray := I
I := 1
FOR I := 1 TO LEN( cCHAR2)
    AADD(aArray2, { SUBSTR(cCHAR2,I,1), ASC(SUBSTR(cCHAR2,I,1)) })
NEXT
//nMaxiArray := max( nMaxiArray, I )
I := 1
FOR I := 1 TO LEN( cCHAR3)
    AADD(aArray3, { SUBSTR(cCHAR3,I,1), ASC(SUBSTR(cCHAR3,I,1)) })
NEXT
//nMaxiArray := max( nMaxiArray, I )
I := 1
FOR I := 1 TO LEN( cCHAR4) // <= max String
    AADD(aArray4, { SUBSTR(cCHAR4,I,1), ASC(SUBSTR(cCHAR4,I,1)) })
NEXT

// changes by André Dutheil
// ----------------------------------------
nMaxiArray := LEN( cCHAR4) //  max( nMaxiArray, I )

FOR I := 1 TO nMaxiArray
    IF I <= len( aArray1 )
        aAdd( aPrint1, { aArray1[ I, 1 ], str( aArray1[ I, 2 ], 3 ) } )
    ELSE
        aAdd( aPrint1, { space( 1 ), space( 4 ) } )
    ENDIF
    IF I <= len( aArray2 )
        aAdd( aTail( aPrint1 ), aArray2[ I, 1 ] )
        aAdd( aTail( aPrint1 ), str( aArray2[ I, 2 ], 3 ) )
    ELSE
        aAdd( aTail( aPrint1 ), space( 1 ) )
        aAdd( aTail( aPrint1 ), space( 4 ) )
    ENDIF
    IF I <= len( aArray3 )
        aAdd( aTail( aPrint1), aArray3[ I, 1 ] )
        aAdd( aTail( aPrint1 ), str( aArray3[ I, 2 ], 3 ) )
    ELSE
        aAdd( aTail( aPrint1 ), space( 1 ) )
        aAdd( aTail( aPrint1 ), space( 4 ) )
    ENDIF
    IF I <= len( aArray4 )
        aAdd( aTail( aPrint1 ), aArray4[ I, 1 ] )
        aAdd( aTail( aPrint1 ), str( aArray4[ I, 2 ], 3 ) )
    ELSE
        aAdd( aTail( aPrint1 ), space( 1 ) )
        aAdd( aTail( aPrint1 ), space( 4 ) )
    ENDIF
NEXT

RETURN aTable
 


Best Regards
Uwe :lol:
Since 1995 ( the first release of FW 1.9 )
i work with FW.
If you have any questions about special functions, maybe i can help.
User avatar
ukoenig
 
Posts: 4043
Joined: Wed Dec 19, 2007 6:40 pm
Location: Germany

Re: Incremental xBrowse-ARRAY-search from GET ?

Postby nageswaragunupudi » Mon Jun 17, 2013 3:13 am

Code: Select all  Expand view
  oGet:bChange = { |n,f,oGet| oBrw:Seek( Trim( oGet:oGet:Buffer ) ), .t.  }
 
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10272
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: Incremental xBrowse-ARRAY-search from GET ?

Postby ukoenig » Tue Jun 18, 2013 7:25 am

Mr. Rao,

Thank You very much for the info.
Incremental search inside a array defined from a GET works fine.
To jump to a xBrowse-cell is a little bit more complicated,
because of the array-splitting to display values in different columns.

Image

// Define the complete Array ( aTable2 ) from 3 Groups
GET_KEYS(aArray1, aArray2, aArray3)

IF ( nAt := AScan( aTable2, { | a | ALLTRIM(cKey) == SUBSTR( ALLTRIM( a[ 1 ] ), 1, nLen ) } ) ) != 0
nKey := ALLTRIM( STR( aTable2[nAt][2] ) )
ENDIF


// Jump to the xBrowse Column and Row
IF nAt < 25 // Group1
oBrw2:nColSel := 1
oBrw2:nArrayAt := nAt
ENDIF
IF nAt > 24 .and. nAt < 48 // Group2
oBrw2:nColSel := 3
oBrw2:nArrayAt := nAt - 24
ENDIF
IF nAt > 47 // Group3
oBrw2:nColSel := 5
oBrw2:nArrayAt := nAt - 47
ENDIF
oBrw2:Refresh()

Best Regards
Uwe :lol:
Since 1995 ( the first release of FW 1.9 )
i work with FW.
If you have any questions about special functions, maybe i can help.
User avatar
ukoenig
 
Posts: 4043
Joined: Wed Dec 19, 2007 6:40 pm
Location: Germany


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Google [Bot] and 18 guests