Post Reply 
Bug in CHOOSE (10637)
11-06-2016, 02:22 PM (This post was last modified: 11-06-2016 04:06 PM by slawek39.)
Post: #1
Bug in CHOOSE (10637)
CHOOSE command CHOOSE(var, ..., ...) when you press the Esc should save 0 to var, but the variable var is left unchanged.


Attached File(s)
.zip  TEST_CHOOSE.zip (Size: 7.86 KB / Downloads: 10)
Find all posts by this user
Quote this message in a reply
11-06-2016, 04:59 PM
Post: #2
RE: Bug in CHOOSE (10637)
(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).
Find all posts by this user
Quote this message in a reply
11-06-2016, 05:08 PM
Post: #3
RE: Bug in CHOOSE (10637)
(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?
Find all posts by this user
Quote this message in a reply
11-06-2016, 06:46 PM (This post was last modified: 11-06-2016 06:49 PM by compsystems.)
Post: #4
RE: Bug in CHOOSE (10637)
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
Find all posts by this user
Quote this message in a reply
11-06-2016, 06:58 PM
Post: #5
RE: Bug in CHOOSE (10637)
(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.
Find all posts by this user
Quote this message in a reply
11-07-2016, 07:54 AM
Post: #6
RE: Bug in CHOOSE (10637)
Hello,

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

Cyrille

Although I work for the HP calculator group, the views and opinions I post here are my own. I do not speak for HP.
Find all posts by this user
Quote this message in a reply
11-16-2016, 04:21 PM (This post was last modified: 11-16-2016 04:52 PM by StephenG1CMZ.)
Post: #7
RE: Bug in CHOOSE (10637)
(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.

Stephen Lewkowicz (G1CMZ)
https://my.numworks.com/python/steveg1cmz
Visit this user's website Find all posts by this user
Quote this message in a reply
Post Reply 




User(s) browsing this thread: 1 Guest(s)