[Gambas-user] Choose and nulls, a bug and a wish for a better way?

Bruce bbruen at ...2308...
Wed Aug 22 05:50:17 CEST 2012


This almost works

        grid[grid.Rows.Max, 15].Background =
        IIf(IsNull(Choose(cs.Result, Color.Yellow, Color.Green,
        Color.Cyan)), Color.Default, Choose(cs.Result, Color.Yellow,
        Color.Green, Color.Cyan))
        
(where grid is a gridview control (which just happens to have a column
15))

cs.result is an integer value between 1 and 10.  As I load each of the
gridview rows I'd like to highlight cells (in column 15) where the
cs.result value is 1 or 2 or 3.

The code is unwieldy because Choose returns a null if the choose value
is not selectable from the list.

        <WISH> It would be nice if there was some way to include a
        default value if the choose value was not indexable.  Something
        like
        
        grid[grid.Rows.Max, 15].Background = Pick(cs.Result,
        [Color.Yellow, Color.Green, Color.Cyan],Color.Default)
        
        ie Pick(Value as Integer,List as Variant[],Optional Default As
        Variant) As Variant
        </WISH>


But I digress.  Today's irk is demonstrated in the attached project that
just loads a sample gridview using the unwieldy code above.  What has
happened when the Choose value is 4????

There are some comments in the code that may provide some insight.

best regards
Bruce


p.s. Sorry, I cant post this to Issues as I am running a huge db re-org
today and starting firefox grabs too much memory and kills the re-org
task.





-------------- next part --------------
A non-text attachment was scrubbed...
Name: Strange "choose" behavior_002.png
Type: image/png
Size: 23769 bytes
Desc: not available
URL: <http://lists.gambas-basic.org/pipermail/user/attachments/20120822/bcb6c3ed/attachment.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 4thplace-0.0.1.tar.gz
Type: application/x-compressed-tar
Size: 5669 bytes
Desc: not available
URL: <http://lists.gambas-basic.org/pipermail/user/attachments/20120822/bcb6c3ed/attachment.bin>


More information about the User mailing list