:bChange := { || cTKeyWord1 := UPPER(ALLTRIM((cFileName)->INFO1)), ;
cTKeyWord2 := UPPER(ALLTRIM((cFileName)->INFO2)), ;
cTopic := ALLTRIM((cFileName)->TOPIC), ;
oTopic:SetText( cTopic ), ;
SHOW_KEYW( oTopic, cTopic, cTKeyWord1, cTKeyWord2 ), ;
cTCode := (cFileName)->CODE, ;
oTCode:SetText( cTCode ), ;
SHOW_KEYW( oTCode, cTCode, cTKeyWord1, cTKeyWord2 ), ;
TCode:GoToLine( 1 ) }
...
...
// ----------------- Check each line -----------
FUNCTION SHOW_KEYW( oCode, cCode, cKeyWord1, cKeyWord2 )
LOCAL nPos := 20, nLen := 50, nLine
FOR nLine := 1 to oCode:GetLineCount() // Scan line by line
THIGHLIGHT( nLine, oCode, cCode, cKeyWord1, cKeyWord2 )
SysRefresh()
NEXT
RETURN NIL
// ----------------- Keyword hightlight ----------
FUNCTION THIGHLIGHT( nLine, oCode, cCode, cKeyWord1, cKeyWord2 )
local cLine := ""
local nAt := 1
local nAt1 := 0
local nAt2 := 0
local nSep := 0
local nLen := 0
local nGetSel := oCode:SendMsg( EM_GETSEL )
oCode:aKeywords1 = { cKeyWord1, cKeyWord2 }
oCode:GoTo( nLine )
oCode:SendMsg( 11, 0, 0 )
// review keywords in current line to highlight them
cLine = StrTran( oCode:GetLine( nLine ), Chr( 13 ), "" ) // result cLine = Linetext
nLen = Len( cLine )
nAt1 := AT( cKeyWord1, UPPER(cLine) )
nAt2 := AT( cKeyWord2, UPPER(cLine) )
IF nAt1 > 0
MsgAlert( cLine, "Line" + " ->> " + ALLTRIM( STR(nLine)) )
MsgAlert( nAt1, "Left 1" )
MsgAlert( LEN( cKeyWord1 ), "Len Keyword 1" )
oCode:Colorize( nAt1, LEN( cKeyWord1 ), 255 )
ENDIF
IF nAt2 > 0
MsgAlert( cLine, "Line" + " ->> " + ALLTRIM( STR(nLine)) )
MsgAlert( nAt2, "Left 2" )
MsgAlert( LEN( cKeyWord2 ), "Len Keyword 2" )
oCode:Colorize( nAt2, LEN( cKeyWord2 ), 255 )
ENDIF
// Let the control be painted
oCode:SendMsg( 11, 1, 0 )
InvalidateRect( oCode:hWnd )
RETURN NIL