From 22429ef7d9f1857eef60f0eabfa2a85fd0e470a4 Mon Sep 17 00:00:00 2001 From: Viktor Szakats Date: Mon, 25 Mar 2013 21:42:48 +0100 Subject: [PATCH] 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. --- ChangeLog.txt | 7 +++++ tests/achoice3.prg | 70 ++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 77 insertions(+) create mode 100644 tests/achoice3.prg diff --git a/ChangeLog.txt b/ChangeLog.txt index 4deed86ebf..5e27e56f78 100644 --- a/ChangeLog.txt +++ b/ChangeLog.txt @@ -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 diff --git a/tests/achoice3.prg b/tests/achoice3.prg new file mode 100644 index 0000000000..6431523a56 --- /dev/null +++ b/tests/achoice3.prg @@ -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