Sunday, May 8, 2011

Eliminating Type Clutter in RealBasic

RealBasic is a great no-nonsense platform for writing personal software that can run with very minor modifications on Windows, Mac OSX and Linux. Its coding language is very close to the Basic in Microsoft's Visual Basic and different from Javascript or C in that each command cannot extend multiple lines.

So, for example, what in Actionscript 3 can be written as:

var a:Number = aClass.myFunction(myVariable1,
myVariable2);


in RealBasic has to be written as:

Dim a As Double = AClass.MyFunction(MyVariable1,MyVariable2)

A problem is that if the line becomes too long, it will extend beyond the width of the editor and be harder to read. Many times this occurs because you have to add CType tags to avoid compilation warnings. For example, if MyFunction accepts only Single type variables and MyVariable1 and MyVariable2 are Double type variables, your line will look like:

Dim a As Double = AClass.MyFunction(CType(MyVariable1,Single),CType(MyVariable2,Single))

which makes the code slightly less readable.

Hence, a solution is to modify AClass adding an intermediate function that accepts Double variables and then calls the original function.

Sunday, September 26, 2010

Collection result contains a duplicate item

Got this error today using Flash Builder 4, Coldfusion 9 and a CallResponder.

Fix:

As the error reads, the ArrayCollection that was returned by the ColdFusion server contained two items with the same index. I first tried to see if I could process it within FB4 and remove the extra item. However, the solution was in looking at the source and finding out that a SQL JOIN I made was delivering duplicates because two tables were joined on only one variable. I added the second variable and the problem was fixed. End of story.

Hope it helps.