Hi Oliver,

On Sat, Jan 28, 2012 at 10:57 AM, Oliver Sims <
[email protected]> wrote:

> The ooDialog Reference (build 7341) section 16.41 ~getItemInfo (ListView)
> says::
>    Return value:
>          Returns .true on success and .false on error.
>
> On my ListView, the user selects an item, which enables a pushbutton. On
> pressing the pushbutton, the selected item is actioned. This works fine.
> But
> if I select an item, then de-select it, then press the pushbutton, the
> value
> -1 is returned from ~getItemInfo, and the program closes with an error. I
> expected it to return .false.
>

No that's a misinterpretation of what happened on your part.  Nothing is
returned from getItemInfo(), rather a syntax condition has been raised,
which is not trapped, that causes the interpreter to close.




>
> Is this an error on my part, or is the documentation incomplete? The
> ooDialog Reference also says, under "Details":
>

This is an error on your part, the documentation is complete, (in my
opinion.)


>
>    Raises syntax errors when incorrect arguments are detected.
>


Which is exactly what happened.  -1 is not a valid list item index.


>
>
>
> The console output is:
>
>  CustomerListView-showCustomer-01: item selected = -1
>     202 *-* if lvCustomers~getItemInfo(item, info)
>  Error 88:  Invalid argument
>  Error 88.907:  Argument 1 must be in the range 0 to 4294967295; found "-1"
>

So here, we see exactly what you did wrong, spelled out in detail.  <grin>
Argument 1, which is the item index is incorrect.  It must be in the range
of 0 to 429... and you passed in -1.  -1 is not a valid item index.



>
> The code is:
>
>  ::METHOD showCustomer UNGUARDED
>    expose lvCustomers rootDlg
>    item = lvCustomers~selected
>    say "CustomerListView-showCustomer-01: item selected =" item
>    info=.Directory~new
>    if lvCustomers~getItemInfo(item, info) then do
>      ...
>    end
>    else do
>      say "No item selected!"
>    end
>
>

You just have your logic there a little inverted.  The method should be
something like this:

::METHOD showCustomer UNGUARDED
    expose lvCustomers rootDlg
    item = lvCustomers~selected
    say "CustomerListView-showCustomer-01: item selected =" item

    if item < 0 then do
      say "No item selected!"
    end
    else do
      info=.Directory~new
      if lvCustomers~getItemInfo(item, info) then do
        -- Process the information returned
        ...
      end
    end

The selected() method is what informs you if an item is selected or not.
The getItemInfo() method requires you to pass in a valid index.

Oh - by the way, these are the type of questions that I would prefer to be
on the ooRexx Users list.  I don't see anything wrong with posting them on
the Developers list and will answer questions where ever I see them.

However, very few users read the developers list.  It's true that probably
very few users read the users list either.  <grin>  But, it makes sense to
me to encourage ooDialog users to read the users list, less sense to
encourage them to read the developers list.

--
Mark Miesfeld
------------------------------------------------------------------------------
Try before you buy = See our experts in action!
The most comprehensive online learning library for Microsoft developers
is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
Metro Style Apps, more. Free future releases when you subscribe now!
http://p.sf.net/sfu/learndevnow-dev2
_______________________________________________
Oorexx-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/oorexx-devel

Reply via email to