[Challenge] Week 5/16/05: Gotcha!
by David Workman
Data Mosaic, Inc
With all of its simplicity, there are times when Servoy can be a bit of a challenge. Unfortunately, sometimes in our brilliance we devise our own challenges without any help from Servoy. Certain challenges happen frequently enough that I like to call them "gotchas." As in: "I GOTCHA AGAIN you stupid idiot."
Here's where I gratuitously plug a service that I offer called Servoy Help-on-demand. Pay me lots of money and I will tell you how stupid you are in MINUTES as opposed to the hours (or days) it can take for you to figure it out all on your own. Ain't that a deal? Your only consolation at getting humbled by me is that I've made all the same mistakes many more times than you.
With that lead in, for this week's challenge I present to you my top five list of "gotchas" from my own experience and that of helping many other Servoy developers. These are so common that it's automatic for me to check them first when someone has a problem (sort of like checking that the power cable is plugged in when someone can't turn on their computer).
Do you know what the problem is with each of these "gotchas?" If you don't, be prepared to waste time on challenges of your own making!
[P.S. Contribute your own gotchas in the comment section and in the wrap up article we can jointly answer them all.]
Gotcha #1: For loop
var loopTimes = 10;
var someArray = new Array;
for ( var i = 1 ; i = loopTimes ; i++ )
{
someArray[i] = i;
}
Gotcha #2: Logical
var someArray = new Array(1,2,3,4,5,6,7,8,9,10);
if (someArray[0] = 1)
{
var newsFlash = "Gotcha!";
}
else
{
var newsFlash = "Servoy meltdown to commence in 10...9...8....";
}
Gotcha #3: showFormInDialog
var myRecord = forms.method_convert.foundset.getRecord(forms.contacts.controller.getSelectedIndex());
application.showFormInDialog( forms.categories );
globals.name_first = myRecord.name_first;
Gotcha #4: Variable scope
loopTimes = 10;
someArray = new Array;
for ( i = 0 ; i < loopTimes ; i++ )
{
someArray[i] = i;
}
Gotcha #5: Covering all conditions
forms.orders.controller.showRecords(forms.customers.customers_to_orders);
Bonus Gotcha: The most misunderstood Servoy concept
Where does Servoy save all of its solution files?
Comments (1)