2013-03-25 21:41 UTC+0100 Viktor Szakats (harbour syenar.net)

+ tests/achoice3.prg
    + added another AChoice() TOFIX demonstration.
      Sent by Tony
    ! code adatped to Harbour stds, some formatting
      for hbformat misses.
This commit is contained in:
Viktor Szakats
2013-03-25 21:42:48 +01:00
parent 6df8ec3b5d
commit 22429ef7d9
2 changed files with 77 additions and 0 deletions

View File

@@ -10,6 +10,13 @@
* Change, ! Fix, % Optimization, + Addition, - Removal, ; Comment
*/
2013-03-25 21:41 UTC+0100 Viktor Szakats (harbour syenar.net)
+ tests/achoice3.prg
+ added another AChoice() TOFIX demonstration.
Sent by Tony
! code adatped to Harbour stds, some formatting
for hbformat misses.
2013-03-25 21:33 UTC+0100 Viktor Szakats (harbour syenar.net)
* utils/hbmk2/hbmk2.prg
! corrected a few spelling subtleties

70
tests/achoice3.prg Normal file
View File

@@ -0,0 +1,70 @@
#ifndef __HARBOUR__
#include "clipper.ch"
#endif
#include "achoice.ch"
#include "inkey.ch"
/* TOFIX: Code below demonstrates an AChoice() difference between Harbour
and Clipper it is called with the number of items in the array is
less than number of rows determined by ( nBottom - nTop + 1 ),
and a user function is specified for cUserFunction. In the attached
example, a box is drawn around the area used by AChoice() to make
it easier to see the difference in action. When cUserFunction is
not specified, the bottom line of the box is not overwritten.
In Clipper, the bottom line of the box is not overwritten, but
in Harbour it is. */
MEMVAR m_aItems
PROCEDURE Main()
LOCAL nResult
PRIVATE m_aItems := { ;
"Apple", ;
"Blueberry", ;
"Cashew", ;
"Grape", ;
"Hazelnut", ;
"Jackfruit", ;
"Kumquat", ;
"Mulberry" }
CLS
@ 7, 25 TO 8 + Len( m_aItems ), 57
nResult := AChoice( 8, 26, 8 + Len( m_aItems ), 55, m_aItems,, "HotChoice" )
IF nResult > 0
Alert( m_aItems[ nResult ] + " selected" )
ENDIF
RETURN
FUNCTION HotChoice( nStatus, nCurrent, window_pos )
LOCAL nKey, cKey
HB_SYMBOL_UNUSED( nCurrent )
HB_SYMBOL_UNUSED( window_pos )
DO CASE
CASE nStatus == AC_EXCEPT
nKey := LastKey()
cKey := Upper( hb_keyChar( nKey ) )
DO CASE
CASE AScan( m_aItems, {| c | Left( c, 1 ) == cKey } ) > 0
hb_keyPut( K_ENTER )
RETURN AC_GOTO
CASE nKey == K_ENTER
RETURN AC_SELECT
CASE nKey == K_ESC
RETURN AC_ABORT
OTHERWISE
?? Chr( 7 )
ENDCASE
CASE nStatus == AC_NOITEM
RETURN AC_ABORT
ENDCASE
RETURN AC_CONT