HP Forums
Bug in CHOOSE (10637) - Printable Version

+- HP Forums (https://www.hpmuseum.org/forum)
+-- Forum: HP Calculators (and very old HP Computers) (/forum-3.html)
+--- Forum: HP Prime (/forum-5.html)
+--- Thread: Bug in CHOOSE (10637) (/thread-7187.html)



Bug in CHOOSE (10637) - slawek39 - 11-06-2016 02:22 PM

CHOOSE command CHOOSE(var, ..., ...) when you press the Esc should save 0 to var, but the variable var is left unchanged.


RE: Bug in CHOOSE (10637) - slawek39 - 11-06-2016 04:59 PM

(11-06-2016 04:44 PM)moonbeam Wrote:  
(11-06-2016 02:22 PM)slawek39 Wrote:  CHOOSE command CHOOSE(var, ..., ...) when you press the Esc should save 0 to var, but the variable var is left unchanged.

It's not a bug. A return value of zero indicates that the user cancelled and while the docs don't specify what happens to var in this case, it makes sense to leave it unchanged.

In the version of the system (8151) behavior was different. Additionally Help in the calculator is consistent with the (8151) instead of (10637).


RE: Bug in CHOOSE (10637) - slawek39 - 11-06-2016 05:08 PM

(11-06-2016 04:42 PM)compsystems Wrote:  If the variable 'a' must be reassigned to zero when press [ESC] key, indicating that not chose anything

PHP Code:
export test_choose()
begin
 local a
;
 
a:=123;
 
choose(a,"test choose output",{"a","b","c"});
 return(
a); 
end

out:
0 for [ESC] key (not selection) and not 123,
1 or 2 or 3 for selection "a" or "b" or "c" respectively, and
"Program interrupted" for [on] key (abort)
.
What is your operating system (10637) or maybe older?


RE: Bug in CHOOSE (10637) - compsystems - 11-06-2016 06:46 PM

you are agree with my correction help?


ORIGINAL CHOOSE HELP (wrong )
Quote:Syntax:
CHOOSE(var, “title”, “item1”, “item2”,[…"item14"]) or
CHOOSE(var,"title",{"item1"..."itemN"})

Displays a choose box with the given "title" and containing items with the strings "item1", etc.

If the user chooses an object, var will be updated to contain the number of the selected object (an integer, 1, 2, 3, …); otherwise, stores zero in var if the user exits without choosing.

Returns true (non zero) if the user selects an object, otherwise returns false (0).

best
Quote:Syntax:
CHOOSE(PosIdentifier, “title”, “item1”, “item2”,[…"item14"]) or
CHOOSE(PosIdentifier,"title",{"item1"..."itemN"})

Displays a choose box with the given "title" and containing items with the strings "item1", etc., the item is placed in the position specified in the variable (PosIdentifier)

If the user chooses an item [OK/Enter], PosIdentifier will be updated to contain the number of the selected object (an integer, 1, 2, 3, …); also returns true (non zero) as out, otherwise if the user press [ESC] key returns false (0) and PosIdentifier will be not updated



RE: Bug in CHOOSE (10637) - slawek39 - 11-06-2016 06:58 PM

(11-06-2016 06:46 PM)compsystems Wrote:  you are agree with my correction help?


ORIGINAL CHOOSE HELP (wrong )
Quote:Syntax:
CHOOSE(var, “title”, “item1”, “item2”,[…"item14"]) or
CHOOSE(var,"title",{"item1"..."itemN"})

Displays a choose box with the given "title" and containing items with the strings "item1", etc.

If the user chooses an object, var will be updated to contain the number of the selected object (an integer, 1, 2, 3, …); otherwise, stores zero in var if the user exits without choosing.

Returns true (non zero) if the user selects an object, otherwise returns false (0).

best
Quote:Syntax:
CHOOSE(PosIdentifier, “title”, “item1”, “item2”,[…"item14"]) or
CHOOSE(PosIdentifier,"title",{"item1"..."itemN"})

Displays a choose box with the given "title" and containing items with the strings "item1", etc., the item is placed in the position specified in the variable (PosIdentifier)

If the user chooses an item [OK/Enter], PosIdentifier will be updated to contain the number of the selected object (an integer, 1, 2, 3, …); also returns true (non zero) as out, otherwise if the user press [ESC] key returns false (0) and PosIdentifier will be not updated

I agree, but for this change, I have to modify my old program to work properly.


RE: Bug in CHOOSE (10637) - cyrille de brébisson - 11-07-2016 07:54 AM

Hello,

The doc seems to be incorrect.
The variable is not updated if the user cancels...

Cyrille


RE: Bug in CHOOSE (10637) - StephenG1CMZ - 11-16-2016 04:21 PM

(11-06-2016 06:46 PM)compsystems Wrote:  you are agree with my correction help?


ORIGINAL CHOOSE HELP (wrong )
Quote:Syntax:
CHOOSE(var, “title”, “item1”, “item2”,[…"item14"]) or
CHOOSE(var,"title",{"item1"..."itemN"})

Displays a choose box with the given "title" and containing items with the strings "item1", etc.

If the user chooses an object, var will be updated to contain the number of the selected object (an integer, 1, 2, 3, …); otherwise, stores zero in var if the user exits without choosing.

Returns true (non zero) if the user selects an object, otherwise returns false (0).

best
Quote:Syntax:
CHOOSE(PosIdentifier, “title”, “item1”, “item2”,[…"item14"]) or
CHOOSE(PosIdentifier,"title",{"item1"..."itemN"})

Displays a choose box with the given "title" and containing items with the strings "item1", etc., the item is placed in the position specified in the variable (PosIdentifier)

If the user chooses an item [OK/Enter], PosIdentifier will be updated to contain the number of the selected object (an integer, 1, 2, 3, …); also returns true (non zero) as out, otherwise if the user press [ESC] key returns false (0) and PosIdentifier will be not updated

Just a minor documentation improvement: "Posidentifier" is not the best name to choose ... Users learning this might wonder whether the identifier is POSitive if a choice has been made and negative otherwise.
I would suggest
"CHOOSE(choice"...for selecting a single item, or
"CHOOSE(selection"...for selecting a list of items

(CHOOSE cannot select more than one item from a list - this is instead done using INPUT - but perhaps it will).

Also, the documentation could document how many items can be chosen from.