Hi Pablo & Hynan,
The code below works and change the cursor size. The trick is that we need to use the command CLEAR GETS and re-invoke GET OBJECT. It works fine with one READ statement.
The new problem begins with this sample code below. SETKEY() have to be redefined on UDF getMisc() because of parameter changes, it has to call getMisc(). Also you would notice that even if the cursor is set into half block mode on the first getKey() READ, when getMisc() were executed the cursor is set to normal [SETCURSOR(1)] by GT itself?
We need to break the GET objects so that when CLEAR GETS were issued the program won't terminate.
Pablo: Thanks for the READINSERT()
Now, I wonder if it is really the right approach or is it a bug from GT? Because if you look at the code there are two EXIT points that must be taken care off in order to change the cursor size. It will be fine as long as the get*() UDF will always RETURNs NIL.
Regards,
Danny
Code: Select all
REQUEST HB_GT_WIN_DEFAULT
Function Main()
PRIVATE aItems_ := {SPACE(5),SPACE(10), 0}
SETMODE ( 25, 80 )
SETCURSOR(1)
*SET SCOREBOARD OFF
SETCOLOR ( "W+/B, GR+/R, N, GR+/N, GR+/R" )
CLS
getLabels()
getKey()
getMisc()
SETKEY( 22, { || Nil } )
Return Nil
function getLabels()
@ 0,0 SAY "Code:"
@ 1,0 SAY "Description:"
@ 2,0 SAY "Unit Cost:"
RETURN NIL
function getKey()
SETKEY( 22, { || MyIns("CODE") } )
@ 0, 7 get aItems_[ 1 ] PICTURE "@!"
READ
RETURN NIL
function getMisc()
SETKEY( 22, { || MyIns("MISC") } )
@ 24,00 SAY PadC("NO INS-" + HB_NTOS( SETCURSOR() ),80)
@ 1,13 get aItems_[ 2 ] PICTURE "@!"
@ 2,12 get aItems_[ 3 ] PICTURE "@ZB9,999.999"
READ
END SEQUENCE
RETURN NIL
Function MyIns( cMode )
CLEAR GETS
IF READINSERT()
READINSERT(.F.)
SetCursor( 1 )
@ 24,00 SAY PadC("NO INS-" + HB_NTOS( SETCURSOR() ),80)
ELSE
READINSERT(.T.)
SETCURSOR( 2 )
@ 24,00 SAY PadC("INS-" + HB_NTOS( SETCURSOR() ),80)
ENDIF
IF cMode == "CODE"
getKey()
ELSE
getMisc()
ENDIF
Return Nil