Kind of an oxymoron. A constant should be .. well .. constant.
However there are times you want that constant to be permanent, or constant, and unchangeable but it needs to be computed at compile time.
And it turns out that in Xojo you can do that IF you define a constant in code like :
Const foo = 123
Const bar = 345
Const foobar = foo + bar
If you assigned these constants to variables so you could inspect them like
Dim iFoo As Integer = foo
Dim iBar As Integer = bar
Dim iFooBar As Integer = foobar
you would see that iFoo, iBar and iFooBar have the values 123, 345, and 468 as expected.… Read the rest
I read a really good article the other day from a writer who was having issues with their clients and trying to collect on invoices that were overdue.
Now, I haven’t had to do this sort of thing in a very long time, but it seemed to me that I have run into the same sort of pushback this author got about charging lates fees.… Read the rest
A few threads on the forums have commented that the URLConnection isnt quite as easy to use as many might expect. In particular there are comments about having to know what error codes a platform might return makes it harder to use than it should be.
Normally Xojo hides this level of detail from us.
I was thinking about this problem and have come up with something of a solution that makes it possible to both know the specific error code and yet still write code that is portable.… Read the rest
A lot of times people have common code that they want in EVERY application they start working on. And there are a number of ways people achieve this – copy & paste, svn externals, or a whole host of other means.
But there is a much simpler way to start off with all that common code.… Read the rest
App Battles ! Winner takes all. Last man standing and all that !
No – nothing quite so fun (although it can be a lot of fun)
This has to do with the App class at design time vs the App METHOD (yes it’s a method) at runtime.
The app class at design time can be renamed however you want.… Read the rest
When using the “factory” pattern you should only be able to get a valid instance from the factory and NO other way. Thats kind of the point of the pattern – to reduce the number of points at which instances can be created. Normally in Xojo you might have a module with a method that can create instances, and its the only one allowed to do this.… Read the rest
An interesting question came up on the forums the other day about how to mimic “Unions” from C.
Turns out I had answered this some time ago – its close but not exactly the same as in C. But it is close enough to be functional and close enough for most uses.
And it’s not mentioned anywhere in the Xojo docs.… Read the rest
A recent feedback case made me think that there may be a real lack of information about attributes.
A lot of people believe that attributes are key value pairs that must have a valid identifier as the NAME and ALWAYS have a quoted string for a value.
This is incorrect.
Attribute name can be quoted strings – meaning you can, by using a quoted string for the name – have names that include spaces that would normally be invalid.… Read the rest
Thomas Templemann wrote a nice blog post about his preferred coding style guidelines.
And most I absolutely agree with.
His suggested style is to test booleans simply for the value they hold and not to test for TRUE or FALSE explicitly. He considers testing for TRUE or FALSE bad style. Examples of bad style are :
if hidden = true then ...
… Read the rest