Skip to content

Category: Tips

sort code tips and tricks

JSON Tree

JSON (JavaScript Object Notation) is a great text-based data format that can be used for files and web services data communication.

The structure is simpler than XML which makes it much smaller and since it does not make use of all the tags you’ll find in XML, it is also significantly easier to read. However, if you open unformatted JSON in a text editor you’ll probably find it a bit dense. Here’s how to get around that.

Comments closed

Binary Magic with Signed Integers

In binary the high bit (the one immediately following the &b in Xojo code) is the “sign bit”. When it’s set to 1, the value is interpreted as “negative” and when it’s set to 0, the value is “positive”. Meaning that bit is not used as part of the “number” itself.

Comments closed

Working with XML

XML can sometimes be a bit confusing, so here are some tips to help you work with XML files.

First, you need to make sure your XML is really XML.

Comments closed

Me vs. Self

When you add a control such as a PushButton to a Window (or a WebButton to a WebPage or an iOSButton to an iOSView), an instance of the control is created for you and added to the layout. Code that is in the event handlers of a control added in this way can refer to both its own properties and methods as well as the properties and methods of the window.

Comments closed

Tip: SQLite in RAM … to improve speed!

It’s very usual to use encrypted SQLite databases in our Xojo projects where we expect to get the maximum read speed from them. But the truth is that encrypting the data in these databases can introduce a penalty in our queries, both from read and writing/updating data to them. How can we improve this? One technique is the creation of a new in-memory based SQLite database, where we will be able to copy the table (or tables) we are interested in getting the maximum speed possible with. Continue reading to see how to do this.

Comments closed

#If vs. If and Conditional Compilation

There was a curious question on the forums about what # meant.

And from the way it was asked I could see the asker was thinking “I know what If means but what about that # in front of it?” And that if they knew what the # meant that the entire thing would make more sense.

And that’s a fair thought – except for one problem. The # by itself doesn’t “mean” anything. It isn’t like *, ^, + or – in that sense. It’s not an operator.

Comments closed

Some Follow-Up Regarding ByRef

A reader asked me to clarify something about my previous post. Their question was:

When MyMethod is written as:

Sub MyMethod( i() as integer )
  i = array(10,20,30)
  system.debuglog CurrentMethodName + " i(0) = " + str(i(0)) + " i(1) = " + str(i(1)) + " i(2) = " + str(i(2))
End Sub

What happens if instead of trying to assign a new array you just alter the values in the array passed in?

Comments closed