Many years ago when I was programming in Delphi I used to have object arrays of size 2 and referencing to the element index with true and false. This was very very useful.
It was possible since false=0 and true=+1. In Gambas we have false=0 and true=-1. So now I came up with: Dim sMoods As String[] = ["Sad", "Happy"] Dim bHappiness As Boolean Debug CInt(True), Abs(True), Abs(CInt(True)) Debug CInt(False), Abs(False), Abs(CInt(False)) bHappiness = False Debug "bHappiness= "; bHappiness; ": " & sMoods[Abs(CInt(bHappiness))] Debug "bHappiness= "; bHappiness; ": " & sMoods[If(bHappiness, 1, 0)] bHappiness = True Debug "bHappiness= "; bHappiness; ": " & sMoods[Abs(CInt(bHappiness))] Debug "bHappiness= "; bHappiness; ": " & sMoods[If(bHappiness, 1, 0)] 1. Why is Abs(True) True? 2. Which is fastest, Abs(CInt(... or If(... ? I guess that If(... is more future proof. 3. I have a "BoolToIndex" function in a library module but I was thinking if it should not be part of the language, to be able to reference in a _simple_ way to an array element with a boolean. /Patrik ------------------------------------------------------------------------------ HPCC Systems Open Source Big Data Platform from LexisNexis Risk Solutions Find What Matters Most in Your Big Data with HPCC Systems Open Source. Fast. Scalable. Simple. Ideal for Dirty Data. Leverages Graph Analysis for Fast Processing & Easy Data Exploration http://p.sf.net/sfu/hpccsystems _______________________________________________ Gambas-user mailing list Gambas-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/gambas-user