Quantcast
Channel: Xojo Programming – BKeeney Briefs
Viewing all 119 articles
Browse latest View live

A Xojo Existential Crisis:  When Self is Nil

$
0
0

A couple of Formatted Text Control users found an interesting bug in the Xojo Windows 64-bit compiler.  If the user pasted anything into the control it would hard crash the Windows application.  I spent a couple of days trying to find a workaround and was flummoxed on how to fix.  Thankfully there’s an easy workaround thanks to Team Xojo.

In the Open event of the FTC control we create a new FTCUndoManager instance.  When the user pastes something into the control we pass the existing text into the Undo Manager so it can properly save the before state and allow an undo of the paste.

Pasting text calls the SavePaste method of the FTCUndoManager class.  This is where things start to go wrong.  This method passes Self into the constructor for the FTCUndoPaste class.  Stopping the debugger in this method shows us that self is nil!  What’s odd is several other passed in class objects are nil too (even though they are not at the control level).  That self is nil is indeed a problem since FTCUndoPaste needs the reference to the UndoManager for a variety of reasons.

How can self be nil?  After all this is a method in the class.  By definition self should be non-nil.  I think this would fall under ‘compiler problem’.  I submitted a private Feedback report to Xojo (53967)  and thankfully Xojo reviewed it quickly and were intrigued enough to look into it.  It was verified and a workaround was quickly found.

William from Xojo wrote this:  

There seems to be an issue with passing byval structure parameters (for 64-bit Window build), as a workaround you can pass these byref instead, i.e. MyFunction(…, Byref firstPa as ParagraphAttributes)

So I was able to change two methods, FTCUndoManager.savePaste and FTCUndoPaste.constructor, by using byRef for each object we pass into the Undo Manager into and in the Undo Paste class.  Voila!  Problem solved.

I suspect that FTC is big enough and complex enough to manifest some edge case for the 64-bit compiler.  If you run into an issue like this try this workaround.  And don’t forget to submit a Feedback report to Xojo since the more edge cases they can find the more likely it is they can determine the cause.

Happy Coding!


What Topics Do You Want Covered?

$
0
0

One of the joys of doing a blog for close to eleven years is that I feel like I’ve talked about a lot of topics and people ‘know me’ fairly well.  I always get a thrill when people tell me they’ve read this blog.  That is so cool and I thank you for your valuable time!

As many of you know I do a quick review of every Xojo release.  I often do a blurbs about updates to our own products.  Occasionally I even rant about things (you should see the posts where I never hit the Publish button!).

When I had a column in Xojo Developer magazine this blog was a convenient place to discuss the ideas from the column.  But writing a reoccurring column is tough.  Keeping a blog going for eleven years seems to be even harder.  I’ve been writing fewer and fewer posts and I’d like to change that trend.

At one point I thought about taking a topic in the Xojo Forums and talking about it in-depth  here.  We’ve been busy doing consulting work so I spend far less time on the forums than I used to but it might be an interesting way to generate new posts.

So, my fellow Xojo developers, what topics would you like to see me tackle?  Topics can include my opinions on the future of Xojo, how’s the 3rd party market doing, why did we choose <x> or <y> over <z>, or anything in between.  I’ll let you be in the drivers seat for while.

Some ground rules:

  • If you’re rude to me, my staff, or Xojo staff I’ll just delete the comment, ban you, and move on.
  • Keep it simple – this is a blog and not a magazine.  Though that doesn’t mean I can’t do a multi-part blog post.
  • I reserve judgement to make more rules as I think of them.  😉

So what topics do you have?

XDC 2019 Session List

$
0
0

The session list for the 2019 Xojo Developers Conference (XDC) was released today at https://www.xojo.com/xdc/sessions/.  Take a look at this interesting list.

I’ve been attending Xojo developer conferences for twelve plus years (don’t remember what my first XDC was – maybe 2004?).  Each one is unique and the topics are usually interesting but do tend to be repetitive from year to year at times.  The session topics for XDC 2019 seem to be more unique than past years.

Obviously Geoff will do his keynote address and talk about what they’ve done in the past year, what they’re currently working, and what’s coming up (sometime) in the future.  There is a session each for Android, Web 2.0, API 2.0, beyond Linux, everything MS Windows, and more by the Xojo staff.

What’s left is an intriguing list of sessions that will be tough to figure out what I want to attend and which ones I can wait to see recorded (assuming they’re recorded again).  I can’t remember an XDC I’ve looked forward to more.

Carol is doing a session on Database Topics for Programmers and I’m doing one called “Xojo Mistakes We All Regret Later”.  My alternative title is “Thankfully time travel doesn’t exist otherwise my future self will no doubt come back to murder me for these stupid programming mistakes I’ve done.”

If you’ve never been to an XDC I highly recommend it.  You will get to meet some of the best Xojo developers on the planet, talk Xojo non-stop for 3 (or more) days on end, talk to Xojo staff, and have fun.  Of course that last point is mostly because of the first three.  You won’t find a bigger concentration of Xojo developers on the planet!

I hope to see you all in Miami in the first week of May.  What sessions are you excited about?

Xojo 2018 Release 4

$
0
0

Xojo 2018 Release 4 hit the internet this week.  This relatively small (84 bug fixes, 21 changes, 5 new items, and 11 doc and example changes) update is a nice end of year release that may or may not satisfy your Xojo dreams.  Let’s get into the highlights.

Of the new items list the big one is the new URLConnection class.  The URLConnection class works with the HTTP 1.1+ protocol and works with http and https connections.  This is a replacement for the Xojo.Net.HTTPSocket and brings back one of the things many developers missed about the old HTTPSocket class – Synchronous communications – using the SendSync method.  

SendSync is a concession by Xojo with the caveat that the application may appear to freeze while running this method.  The regular, and probably the better, Send method is asynchronous and does not freeze the app.  Admittedly the async way is the better way but for many developers the synchronous method is easier to implement and ‘good enough’ for their use.  Still, consider using the async method.

The Screen class now has the ScaleFactor property.  There are two new global constants: AppSupportsDarkMode and AppSupportsHiDPI  that are pretty self explanatory.

iOS builds now use the iOS 12.1 SDK.  macOS builds now use the 10.14 SDK for 64-bit builds.

There are couple of changes that are noteworthy.  The first being that the Windows IDE can now successfully build large projects for Linux 64-bit and ARM targets (frankly I didn’t know this was a problem but I bet that ‘large’ is the key word).  Any remaining threads are now killed after the app.close event (possibly a reason why some apps in macOS crash after they quit?).  EnableMenuItems no longer fires needlessly on every keypress in Windows.  Lingua and Remote Debugger Stub have been updated to work with Dark Mode on macOS.

There are 84 bug fixes in this release.  The more important ones (at least in my opinion):  The Build folder is properly emptied between build runs.  Remote Debugging to a Raspberry Pi no longer randomly crashes when stopping at a breakpoint.  Browsers that have disconnected from the web app will now reload the web app so they don’t appear frozen.  There are also a couple dozen IDE bug fixes to the Inspector, Navigator, Find & Replace and a number of the editors.

As with any new release you need to thoroughly test your projects before doing a public release.  It was noted during the beta period that the Einhugur Search Control didn’t work properly in Mojave but has since been fixed.  We had one large project not work when remote debugging from Mac to Windows but I haven’t had time to track it down.  If you have found any new issues with R4 please submit a Feedback report right away!

Happy coding!

2018 Was a Weird Year

$
0
0

I hope everyone’s holiday season was good.  We’re approaching the end of 2018 and I find it nice to reflect on what’s happened and what we’ve accomplished this year.

Looking Back

Let’s start off with the blog posts.  I did 41 (well now 42) blog posts in 2018.  Five were about Xojo releases.  Four were BKeeney Software product releases.  Four posts were about the Xojo Developers Conference.  The rest were a variety of Xojo related topics.

The most highly commented blog post was from June called Chasing Xojo where I lamented that Xojo, at least until that point, seemed to be a less stable when it came to Windows and Linux due to major revamping of the drawing systems on both platforms.  In Windows, Xojo doesn’t flicker as much but the struggle to get speed was a concern for all of 2018.  In Linux, the switch to GTK 3 wasn’t as smooth as we could have hoped.

The most viewed blog post was from August called Xojo 2018 Release 2 where I did my usual review of the most recent release of Xojo.  I heavily criticized Xojo for their poor documentation in that release.  I received plenty of blowback on that one.  But I think the end result is that R3 and R4 documentation was much better.

We released two new products with BKS Report Studio and BKS Tab Control.  Report Studio is our reporting utility meant for end-users for macOS and Windows and it was built using the award winning Shorts reporting classes (also a blog post).  The Tab Control is a canvas subclass that replaces, and extends, the built-in Xojo tab control in many ways and was our attempt at replaced the old CustomTabControl that many use but is unusable for HiDPI apps.

The other major release of the year was ARGen 3.0.  ARGen is our utility to create Xojo projects that creates ActiveRecord objects.  Among the many changes was the ability to generate ActiveRecord objects for iOS projects, supporting GUID primary keys, and the ability to include Audit Trail, Localization, and Database Update modules that help in many products.  We use ActiveRecord in practically every project and having the ability to generate some basic desktop and web UI is a huge time saver.

2018 sure seemed like a mixed bag for Xojo.  The Windows drawing issues took up a good chunk of the year and I think R4 was the first solid Windows release (although I still have 2 client apps that won’t remote debug in R4).  I can’t imagine the amount of effort that Xojo and the community put into getting Windows drawing fixed.

64-bit remote debugging became a reality for all targets this year.  64-bit compiling isn’t the huge gain that many in the community hoped for but then we always want more.  We just have to remember that 64-bit doesn’t necessarily mean ‘faster’.  At least the debugger works and that’s not nothing.

Dark Mode came soon after the release of Mojave.  The IDE works in Dark Mode and we were given many of the tools to implement it in our own projects.  Dark Mode only works in MacOS but some are already clamoring for it in Windows too.  It’s still to early to tell if Dark Mode is a hit on Mojave much less in xojo.

Looking Forward

What is 2019 going to bring us?  For one, we’re almost finished with a fairly significant update to Formatted Text Control and after that’s released we’ll start with an even bigger version 4 update to the venerable word processing control to bring it up to date and extend its capabilities to make it even more powerful.

We have a number of large consulting projects that have been in gestation for many months and years.  It will be nice to have a big project or two to keep us busy.

With the release of Web 2.0 I will redo all of our Xojo training videos related to web.  They’ve been outdated for a while but it’s not worth redoing the videos until Xojo releases Web 2.0.  If they release Android I’ll start on at least some intro videos for that too.  This might finally be the year that I redo the remaining Real Studio videos.  No doubt I’ll redo them just before a major IDE change.  🙂

What do I expect from Xojo?  That’s a tough question to answer since they’re so damn secretive now.  I expect Web 2.0 to show up in time for XDC (so maybe release 2?).  I think it will be pretty solid in the first release but it wouldn’t expect it to be good until the following release.

I also think that at XDC we’ll get an alpha of InterOps but not anything other than another dog and pony show for Android.  Targeting another platform is long and tedious process and involves some serious IDE work.  How much of the iOS editors can they use?  I can only guess but at first blush I say not much.

Some of Android’s success may hinge on getting iOS to use the global framework and away from the Xojo Framework.  Nothing like rewriting an entire framework while keeping backwards compatibility.  The more I think about it the more I think the iOS rework is put on hold until Android is released.  

Which leads to API 2.0 in general.  We’ve already seen some of the first new controls to use API 2.0.  URLConnection was introduced in 2018 R4 with mixed success.  I would expect more API 2.0 controls to show up.

So what do you think?  Was 2018 a successful year for Xojo?  What do you see happening in 2019?

Nil Recordset

$
0
0

The question on how to deal with nil RecordSets is OFTEN asked in the Xojo forums.  Either the original poster or a well meaning responder will do something like this:

dim rs as recordset 
rs = db.sqlselect(sql)
If rs <> Nil Then
     If Not rs.EOF Then
       // No Records in Table or bad querry?
     End If
End If

It works, but it only masks the real issue.  Why is rs nil in the first place?  The answer is because the SQL statement to get the RecordSet had an error!  What is that error?  We have no idea because the code doesn’t ask for the error.

Most of the time the database will give you an error message that will point you in the right direction.  How do you tell that the database had an error?  You check the Error property.

dim rs as recordset 
rs = db.sqlselect(sql)
if db.error then
     //Do something
end


The database can give you an error code but this varies from database to database so I don’t find it exceptionally useful.  However, there is an ErrorMessage property that gives you a human readable message.  

dim rs as recordset 
rs = db.sqlselect(sql)
if db.error then
     MsgBox “DB Error: “ + db.ErrorMessage
     Return
end


In this example I’m showing this to the user but this is probably not a great idea for most uses because you don’t want the average user to know what happened.  However, it’s great while debugging.

The error you get back might be a little mysterious.  SQL is a language specific to databases and the error message returned expects you know a little bit about databases.

The second part of my message to you is that if you’re using SQLSelect or SQLExecute in your code you should look at PreparedStatements.  They’re safer in that PreparedStatement have some security features and does the heavy lifting of taking the input data and putting it into the right format.  What do I mean by this?

In a normal SQL statement you would have an SQL statement like this:

dim sql as string
sql = “Select * from users where last_name = ‘Keeney’;”


This selects all users whose last name is ‘Keeney’.  If you were going to allow the user to search for whatever name they want you would end up doing something like this:

dim sName as string
sName = txtSearchField.Text
sql = “Select * from users where last_name = '“ + sName + “’;”


Note that I had to manually put the single quotes in before and after the name since the database column is text.  This works great until you enter an Irish name like O’Neil.  The database will choke on this because it has an extra apostrophe in the statement.  You can escape this data yourself but what a pain.  Instead, use a PreparedStatement.

dim ps as SQLitePreparedStatement
dim sql as string
sql = “Select * from users where last_name = ?”
ps = db.prepare(sql)
ps.bindtype(0, SQLitePreparedStatement.SQLITE_TEXT
ps.bind(0, txtSearch.text)
dim rs as Recordset
rs = ps.SQLSelect
if db.error then
     MsgBox db.errormessage
     return
end


Nowhere in the code do I have to put in apostrophe’s or escape any data.  It’s just handled and this is true if you have database columns that are text, date, or numeric.

PreparedStatements have a number of advantages besides the automatic formatting.  They help with security and SQL Injection attacks.  If you don’t know what those are just do a web search to learn more.  You can reuse PreparedStatements in code but in my testing it doesn’t save much time as it appears as if the database plugin saves them internally.  Regardless, there are so many reasons to be using PreparedStatements over straight SQL.

To recap:  A nil recordset always mean a database error has happened.  You need to check for for the error after every operation whether that be a Select, Insert, Update, or Delete statement.  Basically after every SQLSelect and SQLExecute statement.  Ideally you want to start moving all of your code to use PreparedStatements because of all of its advantages.

BKS Shorts 2.0.9

$
0
0

Today we released BKeeney Shorts 2.0.9.  This is a free update to all version 2.0.x users.  

Shorts is the award winning reporting tool for Xojo applications.  Shorts allows a Xojo developer to embed a report designer inside in a desktop application, view reports in any resolution on desktop or web applications, save report files to file or to a database, and to export reports to HTML, CSV, and PDF (requires the DynaPDF plugin from MBS).  Shorts works with SQLite, CubeSQL, PostgreSQL, MySQL, MS SQL Server, ODBC, and Informix (requires the SQL plugin from MBS).     Shorts comes as 100% unencrypted Xojo source code.    

New:

  • Align: Justify text! (#3627)
  • Report Designer can now copy and paste! (#3691)
  • Method to tell the DynaPDF renderer where to look for custom fonts
  • Report Designer bands with a Band Script now offer an indication in the designer (#3701)
  • Schema Zapper will remove the DB schema from the JSON for manual template changes (#3632)

Changes:

  • Running in HiDPI in Windows using Xojo 2018 R3 now shows report preview in proper clarity
  • Report Designer no longer nags about deleting items that can be undone
  • Designer window positioning suggested by container event for better scoping
  • Standardized naming on winReportDesigner
  • DesignCanvas.GetUniqueName is now more smart
  • DBWrapper.DatabaseFile is now DBWrapper.SQLiteDatabaseFile for consistency
  • ReportBKS no longer redundantly loads styles to the global styles dictionary
  • PAF_PrintKit.DictStyles is now protected for clarity in code

Fixes:

  • PreviewCC Mojave / 2018R3 & R4 graphical glitch workaround
  • Reports where the page header is empty no longer have multiple page positioning issues
  • Added Numeric and Decimal datatypes for PostgreSQL, maps to Double
  • Views now show up in the Manual Relations editor (#3731)
  • Designer window will no longer reposition if the report template positioning doesn’t fit onscreen (#3651)
  • Fixed localization mismatch in the navigator (#3851)
  • DBWrapper no longer assumes SQLite databases have a database file (#3694)

Removed:

  • PAFConfirm function, please use the modGlobals.Alert function instead
  • winReportDesigner no longer has a Placard control
  • PAF_DatabaseKit.CreateDatabaseFile function, it served no purpose in the Shorts project

For more pricing, demo versions, and training videos please visit http://www.bkeeney.com/allproducts/bkeeney-shorts/

modGtk3 for Xojo

$
0
0

Linux has always been kind of an odd duck when it comes to Xojo.  If you create Linux applications with the IDE running in Linux the default sizes for controls is 26 which is different than MacOS or Windows since their default control height is 22.  See the initial screenshot:  the controls in Linux just don’t look right at the default Mac/Win control height.

The standard answer for many years was to subclass your controls and modify the height of the controls in Linux.  This was okay but it hard to make your UI look good on all three target platforms.

Xojo 2017 R2 changed the drawing system it uses.  The switch to GTK3 made it possible to modify the CSS of your application theoretically making it possible to make all platforms look and behave the same.

Just because you can modify the CSS means it’s a trivial task.  Several long time Xojo community members Jim McKay and Jürg Otter stepped up to the plate and put in the time to figure it out.  The result is at https://bitbucket.org/pidog/modgtk3/src/master/.

In this screenshot you can see that everything looks as you’d expect.

Implementing this in your own project is simple.  Download the BitBucket repository, open the project in Xojo and copy the GTK3 folder into  your own project.  Then in the App.Open event put these three lines in:

modGTK3.initGtkEntryFix
modGTK3.initGtkWidgetHeightFix
modGTK3.InitGlobalGTK3Style

That’s it.  Voila!  Now your app looks better in Linux and there’s no need to subclass your controls.  I realize this isn’t magic but it sure seems like it.


BKS Tab Control – Drag Rearrange Tabs!

$
0
0

Lenexa, KS (February 8th 2019) — BKS Tab Control update can now drag rearrange

BKeeney Software releases a minor update for BKS Tab Control enabling users to drag and drop to rearrange tabs. Developers can enable or disable this feature using a switch in the Xojo IDE. A new event, TabOrderChanged, is raised when the user performs a drag-rearrange.

The BKS Tab Control is a set of classes that offer developers a classic “tabs control” for Xojo Desktop applications. The Tab Control can attach to any RectControl or Window, and will maintain a relationship to this parent control if and when it changes size. Tabs can be displayed in one of four directions (North, South, East, West) and individually offer options like a close button, an icon, a background color, and can be disabled.

Other features:
  • Optional CloseBox can be positioned on the left of right
  • If the CloseBox is selected a CancelClose event is fired
  • Optional Icon can be positioned on the left or right
  • Each tab can be independently styled (colors, fonts, text decorations)
  • Each tab can be disabled
  • Tabs that overflow may be accessed with an overflow popup menu
  • Works in HiDPI, non-HiDPI, and dark modes

BKS Tab Control has been tested in macOS, Windows, and several varieties of Linux with Xojo 2018 R4 and back to Xojo 2017 R1. The control may work unchanged in older versions of Xojo.

BKS Tab Control is sold as unencrypted source code and costs $75 USD. Existing customers can download the update with the original link on their sales receipt. More information and a demo project are available at: https://www.bkeeney.com/allproducts/bks-tab-control/

Formatted Text 3.2

$
0
0

Lenexa, KS (February 12th 2019) — BKeeney Software Inc. releases a major update to Formatted Text Control. Developers can now implement tab leaders, change character spacing, implement text drop shadows, and use standard keyboard handling in their applications that require a robust word processing control. This version contains dozens of new, changed, and updated items.

Formatted Text Control (FTC) is a set of classes that offer developers word processing capabilities for their Mac and Windows desktop applications. FTC has several viewing modes that gives users a choice of Page View, Edit View, or Single Line view. FTC supports inline graphics, hyperlinks, and text formatting that the built-in Xojo TextArea control just can’t do. Users can import and save text, RTF, and XML format documents.

FTC version 3.2.0 is a free update to all 3.x users and is recommended. Existing users should be notified via FileShare but can contact BKeeney Software at support@bkeeney.com if they have any questions.

FTC is sold as unencrypted source code and costs $150 USD. More information and demo projects are available at https://www.bkeeney.com/formatted-text-control/ .

Complete change list:
New Items:

  • Contains code from the ImagePlay Effects Library – http://imageplay.sourceforge.net 
  • Tab Leaders implemented
  • Issue #3832: Implement Control + Up/Down Arrow Key Handling
  • Issue #3833: Implement paragraph moving via keyboard handling
  • Issue #3700: Drop Shadow available on Windows and Linux
  • Issue #3795: The FTDocument properties characterStyles and paragraphStyles need to be accessible to subclasses.

Added CharacterStyles and ParagraphStyles getter/setters so developers can create their own style editor.
* Character Spacing implemented (requires Xojo >= 2015.4)

Bug Fixes:

  • Issue #3650: CustomObjects Demo: Added FTFile.Clone method so it works with FTIterator propertly.
  • Issue #3653: macOS: “getDoubleClickTime” – Cocoa replacement for old CarbonLib call
  • Issue #3699: Add Win64 Declares
  • Issue #3654: Hi-DPI Mode: FTPicture – Handles drawn incorrect and matches wrong.
  • Issue #3702: DragRect is half height in HiDPI
  • Fixed an issue with FTParagraph clones that have a different ID after going through the FTIterator
  • Issue #2007/3605: Candidate Window Shows up in Wrong Location
  • Issue #3646: FTParagraph.getXML saves wrong TabStop Properties
  • Issue #3709: FTPicture ignores Nudge property
  • Issue #3748: FTDocument.selectionBold,Italic, shadow, strikethrough, subscript, superscript, underline now works properly
  • Issue #3752: FTRBScript: Fix for printing line numbers
  • Issue #3763: RTFReader/FtcRtfReader ignored the left/right margin and first indent of paragraphs.
  • Issue #3764: RTFReader ignored “\sb” SpaceBefore of paragraphs.
  • Win64 Issue: Modified FTCUndoPaste.constructor and FTCUndoManager.savePaste to allow pasting (Xojo Compiler Issue. Feedback 53967)
  • Issue #3750: Suggestion & comparison of the Office applications for the display optimization of the paragraph background color
  • Issue #3775: Implement Corner Color Property in Formatted Text (Switch between Light/DarkMode – Xojo Version >= 2018.3)
  • Issue #3777: Implement Page Shadow Property in Formatted Text (Switch between Light/DarkMode – Xojo Version >= 2018.3)
  • Issue #3755: Printing has the side-effect of scrolling the editing window to the top
  • Issue #3794: FTDocument.getSelectedParagraphs returns first paragraph of multi-paragraph doc regardless of insertion point
  • Issue #3796: FTStyleRun.copyStyleData does not copy background color
  • Issue #3820: RTFWriter missed “\par” after the last Paragraph
  • Issue #3774: FormattedText — changeParagraphMargins method name changeParagraphMarigns
  • Issue #3762: FTDocument.selectionFontColor returns sameColor false when it should be true
  • Issue #3842: FTStyleRun.updateWith Style sets textColor black when undefined
  • Issue #3806: FTDocument.addParagraphStyle and addCharacterStyle bypassed by insertXML and cannot be overridden in subclass
  • Issue #3818: Print RB Code Editor: Unwanted positive y-offset of the content compared to its line number
  • Issue #3637: FTCParagraphStyle.backgroundColor won’t set correctly
  • Issue #3910: RTF-Reader ignores local value for first line indent in paragraphs
  • Issue #3914: First Paragraph on Page with Background Color ignores Before Space
  • Issue #3917: Paragraphs Background Color ignores Hanging Indent

Changes:

  • Renamed FormattedText.xDisplayPosition to FormattedText.hScrollValue to better reflect what it is.
  • Renamed FormattedText.lastXDisplayPosition to FormattedText.lastHScrollValue
  • Renamed FormattedText.yDisplayPosition to FormattedText.vScrollValue to better reflect what it is.
  • Renamed FormattedText.lastYDisplayPosition to FormattedText.lastVScrollValue
  • Renamed FormattedText.GetResolution to FormattedText.GetMonitorPixelsPerInch to better reflect what it does.
  • Renamed FTDocument.SetResolution to FTDocument.setMonitorPixelsPerInch
  • Renamed FTDocument.GetResolution to FTDocument.getMonitorPixelsPerInch
  • Renamed FTDocument.Resolution to FTDocument.MonitorPixelsPerInch
  • FormattedText.DISPLAY_ALIGN_CENTER/LEFT/RIGHT replaced with Display_Alignment enum
  • FormattedText.MODE_PAGE/NORMAL/EDIT/Single replaced with Display_Mode enum
  • FTLine.FIRST_LINE/MIDDLE/LAST/BOTH replaced with Line_Type enum
  • FTPicture.Handle constants converted to FTPicture.Handle_Type enum
  • FTParagraph.Alignment constants converted to FTParagraph.Alignment_Type enum
  • Removed Alignment constants from RTFConstants module
  • Changed how hyperlinks are drawn in FTObject.drawHyperLink
  • Changed how the gradient shadow is drawn in FTPage.drawPageViewMode
  • Changed how strikethroughs are drawn in FTObject.drawStrikethrough
  • Changed how underline is drawing in FTObject.drawUnderline
  • Can now read/write shadow properties from/to RTF Documents
  • Added AcceptFileDrop to test window for testing custom objects. Added FTFile into project.
  • Changed how Styles are saved and read in XML format.
  • Issue #3802/1456: Command + (Shift Key) + Arrow Keys doesn’t move insertion point correctly
  • Changed RB Script classes to Xojo Script.
  • Now have TabLeaders (WORK IN PROGRESS)
  • Embedded FTC demo now does text formatting with keyboard shortcuts.
  • Removed unused FTDocument.DocOffset method.
  • Fixed TargetCocoa and TargetWin32 constants with more appropriate ones for 2018 R4.
  • Removed duplicated code line in RTFReader.SetupKnownCommands
  • Updated ParagraphWindow to easy format First Line and Hanging Indents

PARTIAL IMPLEMENATION:
* Issue #3753: PageBreaks won’t load from RTF

Database Transactions in Xojo

$
0
0

Every now and then someone on the Xojo forum wonders why inserting data into an SQLite database is so slow.  Databases are designed to hold billions of records and do it fast, right?  So why is their application so slow?  The answer is they are relying upon the built-in transaction in Xojo.

By default SQLite databases do an automatic transaction for you.  This means that as soon as you attempt to insert, update, or delete data the work to write that change to disk happens as soon as possible.

For example, let’s take the following bit of code to insert data into a table:

For i As Integer = 1 To kMax
   Dim dbr As New DatabaseRecord
   dbr.Column("Name") = GetName
   dbr.IntegerColumn("Age") = GetAge
   dbr.DateColumn("TheDate") = New date
   db.InsertRecord "t_table", dbr
   If db.Error Then
      MsgBox "DB Error: " + db.ErrorMessage
      Return
   End
Next

GetName gets a random name from an array that has 26 names in it and adds a random integer between 1000 and 10000.  GetAge returns a random integer between 1 and 74. 

This is pretty simple insert and if you run this 10,000 times it takes roughly 49 seconds saving to a desktop SQLite file on my 5k iMac.  And in so doing the application is locked up for that entire time because I’m in the tight loop.  This is simply unacceptable.

I’m sure someone is screaming why are you using the DatabaseRecord!  It’s slow!  It’s inefficient!  You should be using PreparedStatement’s!  Okay, so using pretty much the same logic:

Dim sql As String = "Insert into t_table (Name, Age, TheDate) Values(?, ?, ?);"
Dim ps As SQLitePreparedStatement = db.Prepare(sql)
ps.BindType(0, SQLitePreparedStatement.SQLITE_TEXT)
ps.BindType(1, SQLitePreparedStatement.SQLITE_INTEGER)
ps.BindType(2, SQLitePreparedStatement.SQLITE_TEXT)
For i As Integer = 1 To kMax
   ps.Bind(0, GetName)
   ps.bind(1, GetAge)
   ps.Bind(2, New Date)
   ps.SQLExecute
   If db.Error Then
      MsgBox "DB Error: " + db.ErrorMessage
      Return
   End
Next

This takes about 48 seconds.  No big time savings there.  Obviously that’s not the improvement we need.

What we need to do is put these inserts in a database transaction using the following bit of code before the loop starts:

db.SQLExecute("BEGIN TRANSACTION")
If db.Error Then
   MsgBox "DB Error: " + db.ErrorMessage
   Return
End

And then at the end use:

db.Commit

Using the DatabaseRecord method takes a whopping 1 second with 10,000 records.  Using the prepared statement is so fast that my measured elapsed time in seconds is effectively 0.  

If I up the number of records inserted to 1,000,000 I get an interesting result.  The DatabaseRecord method takes 27 seconds where the PreparedStatement method takes 47 seconds.  And if I declare the PreparedStatement inside the loop it now takes 55 seconds.

What have we learned in this blog post?  First, using a database transaction is considerably faster than using the default transaction behavior.  Second, using DatabaseRecord is pretty fast and depending upon the number of record inserted it might be considerably faster.  Honestly, I didn’t expect this.  

In the next blog post I’ll look at Record updates and what are the best methods.

Updating Records with Transactions

$
0
0

In my last blog post I talked about inserting records into a SQLite database and found that using transactions makes them incredibly fast.  Does the same hold true for updating an existing record?  We’ll find out.

In this set of tests I inserted 100,000 records and then randomly selected 10,000 records to update with our same random name, age, and date values.  In theory this means I have records distributed all over the range of the database.

In the first test we use a simple RecordSet which means we have to query for it first.  Then call its Edit method, change the values and call update.  It’s a two step process.

For i As Integer = 0 To ari.Ubound
   Dim rs As recordset
   rs = db.SQLSelect("Select * from t_table where table_id = " + Str(ari(i)))
   If db.error Then
      If db.Error Then
         MsgBox "DB Error: " + db.ErrorMessage
         Return
      End
   End
   rs.edit
   rs.Field("Name").stringvalue = GetName
   rs.Field("Age").integervalue = GetAge
   rs.Field("TheDate").DateValue = New date
   rs.Update
   If db.Error Then
      MsgBox "DB Error: " + db.ErrorMessage
      Return
   End
Next

Unsurprisingly, this method took about 49 seconds for 10,000 records.

In test two I switched to using a PreparedStatement to update the record.

Dim sql As String = "Update t_table Set Name = ?, Age=?, TheDate =? WHERE table_id = ?"
Dim ps As SQLitePreparedStatement = db.Prepare(sql)
ps.BindType(0, SQLitePreparedStatement.SQLITE_TEXT)
ps.BindType(1, SQLitePreparedStatement.SQLITE_INTEGER)
ps.BindType(2, SQLitePreparedStatement.SQLITE_TEXT)
ps.BindType(3, SQLitePreparedStatement.SQLITE_INT64)
For i As Integer = 0 To ari.Ubound
   ps.Bind(0, GetName)
   ps.bind(1, GetAge)
   ps.Bind(2, New Date)
   ps.bind(3, ari(i) )
   ps.SQLExecute
   If db.Error Then
      MsgBox "DB Error: " + db.ErrorMessage
      Return
   End
Next

When run for 10,000 records this takes about 47 seconds so there is a little bit of time savings by not querying the database for the data to begin with.  It’s also possible that the PreparedStatements aren’t nearly as efficient as one would hope.

I then repeated the same tests within a Transaction.  In both cases updating records effectively took no time at all!  If I increase the number of Updates to 10,000 both the RecordSet update and the PreparedStatement takes about 8 seconds.  

I’m surprised at these results because you would think that doing the query required for the RecordSet would take more time but it’s no different than using the PreparedStatement SQL Update.  Why is that?  I have a couple of theories.  First, the table isn’t very complex with only 4 columns and I’m only ever querying and updating based on the primary key.  I’m sure a more complex query would slow things down.  We also have no indexes on any the columns which can cause the database to do more work behind the scenes.

Regardless, we learned a few things today.  First, database transactions are critical to large scale database manipulation in a timely manner.  Second, it doesn’t matter if you use RecordSet Edit/Update or if you use PreparedStatements as either one is fast enough.

What sorts of questions do you have about databases that I can test for you?

Evaluating A Xojo Consultant

$
0
0

We had an interesting conversation with a prospective client last week.  Well, I should back up and say this isn’t the first time we talked to them as we were a finalist for a project of theirs two years ago.  Turns out their Xojo consultant is having a hard time completing the work and not giving them deliverables in a timely manner.  This is for a project we estimated at less than six months worth of work.

The client is looking for someone that could come in and complete the project for them.  They were hoping that a large majority of the work could be reused.  My response was that this was unlikely for several reasons.  The first being that they used their own kit which means a set of classes, subclasses, and libraries that we are unfamiliar with and for me to use them without serious investigation (i.e. time and money) would be less than ideal.  Plus, if I’m the developer for the project I’m now responsible for it working and I’m taking a gamble on code that I don’t know and haven’t vetted.  

My second thought was wondering if their overall design had been the cause for some of the delay.  Perhaps they coded themselves into a corner.  It’s an awkward conversation to have with a client – especially after they’ve spent a boatload of money.

Regardless, I’m sure our conversation was not what the client was looking for.  They wanted a project savior because their consultants had deceived them in their capabilities and in their ability to deliver.  

We politely asked who their consultant was and they told us.  A brief internet search pulled up the company website and their *one* Xojo related post.  Everything else on their website is hardware and .NET related.  If I was evaluating a Xojo consultant that would give me some pause for concern.  You really want a consultant that does a lot of Xojo projects.  Xojo is not like .NET or Java or any other language.  It has its own set of strengths and weaknesses (just like every other language) and I’ve seen it all too often where a developer tries to make Xojo do what <insert language here> does.  It’s almost always a disaster.

We’ve been using Xojo for over 16 years.  If I’m not friends with most of the Xojo consultants out there I at least know of them and their reputation.  I have lost bids to my competitors and if the prospective client will tell us who they chose I can at least give a thumbs up to those that I know and trust since I know the client will be in good hands.  For those that I don’t know I don’t give any opinion.  But it’s also been my experience that those consultants that stick around are good and are active in the community.

If you’re hiring a Xojo consultant you should always ask for references.  If you’re going to spend tens of thousands of dollars (or more) with them you should do a little homework.  Don’t buy their assurances.  If they are really reliable then they will find references for you to check out.  This will let you know if they do good work, are on time, and on budget.  Are they reliable?  Are they hard to work with?

If you’re new to Xojo consulting that’s okay too – we were all new once.  Be honest with the client and do your best to prove to them that you’re up to the challenge.  

The Xojo community is very accepting and the forum is filled with developers that have provided answers to newbies, provided source code examples, and even established public repositories to share their code.  Have they spoke at any Xojo developers conferences?  Written for Xojo Developer magazine?  This public work can, and should be, part of the reference list.  This shows the prospective client that you really know and work with Xojo.

Hiring a Xojo consultant isn’t that difficult.  There are a number of qualified consultants that will create a great project for you.  The first step is to fill out the form at Find a Developer page on the Xojo website at https://www.xojo.com/resources/consultants.php.  This will get your project in front of everyone looking for work.  Then it’s up to you.

Ask about their Xojo work they’ve done in the public.  Ask for their references.  Heck, ask them what they love and hate about Xojo (that might be a long conversation).  If you don’t do your homework you might be wasting an opportunity in not getting your project to market, or waste tends of thousands of dollars for work that doesn’t get delivered.

ARGen 3.0.3

$
0
0

BKeeney Software Inc. is proud to announce an update to ARGen, our ActiveRecord Generator utility for Xojo developers. This minor update includes dark mode support, speed improvements, and important updates for generated projects. Updating to 3.0.3 is recommended for all ARGen users.

ARGen is available for macOS and Windows. It can be used for free in limited mode, and is priced at $99.95 to unlock all features. Existing version 2.x users will automatically be provided an upgrade opportunity when launching version 3.

3.0.3 Release Notes:

Changes:

  • Added Dark Mode support
  • Simplified manual relationship management
  • Selecting a different SQLite database now clears the password field
  • kMaxReturn is now a protected constant for cleaner code
  • DBUpdates module code is now cleaner
  • Improved instructions in some locations
  • Base project templates optimized
  • Preferences module no longer writes to SpecialFolder.Preferences
  • iOS Create Data Sources defaults to true
  • Updated links to Xojo documentation
  • Generated localization module constants are now protected

Fixes:

  • DBUpdates.SetDBVersion no longer uses a BKS extension synonym for str()
  • Fixed return statement for iOS apps using 2018r2
  • Projects with empty name now have default save name
  • BKS Created/Modified overrides no longer generate properties that fail to Register
  • Corrected minor UI bug on Windows
  • Project listing loads faster
  • Speed improvements throughout the software
  • Projects created but never saved are no longer retained when closed
  • Checking for updates at launch now works
  • Preferences window will show the last update check time

Pricing, examples, and more details can be found at the project homepage at https://bkeeney.com/argen/ 

Evaluating Prospective Xojo Clients

$
0
0

A couple of weeks ago I did a blog post about evaluating Xojo consultants.  I think if you’re hiring a Xojo developer the consultant should clearly be an expert in Xojo and should be able to publicly show why they deserve your hard earned money.  But, there are two sides to the equation and I didn’t talk about evaluating the prospective client.  Here are some of the things that are red flags to us and maybe why we should steer clear of them.

Does the prospective client have a clear idea of what they want?  We’ve had clients that had a mere paragraph of content but could clearly articulate what they wanted.  Other clients have written an 80 page document full of meaningless gibberish that required a three hour face-to-face meeting to understand it.  

This is hard to evaluate but I’ve learned that if I can’t understand what the client wants and needs within a reasonable amount of time we’re not a good fit.  Either they can’t articulate what they want or it means that we’re just having communications issues.  It’s also possible they don’t know what they want and they want us to figure it out for them (which is a completely different project).

Has the prospective client worked with other Xojo developers before and been unhappy with the work?  Don’t get me wrong, we’ve picked up a lot of happy long-term clients and projects this way.  The client worked with another Xojo developer that couldn’t finish the project for a variety of reasons (like going back to a corporate job, or they bid too low and couldn’t live on the resulting income).

This is hard to evaluate too and you have to take it on a case by case basis.  Listen for the reasons why they were unhappy with the consultant.  Do their reasons seem petty or legitimate?  Do they accept at least some of the responsibility or do they put it all on the consultant?  Reasonable clients will accept partial responsibility.  The unreasonable clients, and the ones to stay away from, blame everything on the consultant.

The prospective client thinks they can do some of the work.  They have experience in <x> language and want to implement some of the work in Xojo on their own.  Or they feel their proof of concept project written in <x> language should give you a huge leg up on the overall project.

As with the previous points this is hard to evaluate.  Xojo is an easy to learn language but it’s been my experience that making Xojo work like <x> language is a recipe for disaster.  Xojo is Xojo and not like java or FileMaker or anything other language or environment.  Maybe their work helps but mostly it probably won’t.  It’s just easier to assume it’s going to be a complete rewrite.

The flip side to this is there are some clients that really are competent developers – just not in Xojo.  We’ve done a number of projects where we start the project for them.  We complete the basic infrastructure and give them some example List and Edit forms whatever else they want help with and then turn it over to them to complete the rest of the project.  They usually come back with some questions but for the most part they finish it themselves.  I consider this as part consulting and part training and we put more comments into code so they can understand the code better (since they’re learning).

The prospective client is always fighting with you about money.  We’ve had clients that want estimates on features so they can get their project done as cheap as possible.  I don’t begrudge any client that wants estimates on features to save money, but there are those clients that always complain about every penny and fight you on estimates and change orders and demand proof for every little thing.  They also tend to hold you to the dollar on any estimate you give them.

We had one prospective client that came with a project written by another developer.  It was referred to us by a Xojo consultant leaving the industry and couldn’t help them.  The project had a silly design where the SQL query was a staggering 200 pages when copied into a text editor.  It literally took minutes just to create the query and many minutes for the database to return results.  The only way to really clean it up and make it work properly was to break it up into smaller queries.  It would have given them more flexibility and it would actually speed up their entire process rather than locking the app up for minutes at a time.

Regardless, we came up with the estimate to fix it.  They said it was too much money and we parted ways.  They came back again in six months when the Xojo developer they found to ‘fix’ the query couldn’t do it (because it really needed to be broken up into smaller queries) and we gave them the same estimate.  It was still too high for them.  Six months later they came back yet again and asked if the price was the same.  It was not because we had raised our base rates.  We’ve never heard back from them and I wonder if they’re still in business.

Many clients are a delight to work with.  Not all of them will be long term clients but some will.  If you don’t get a warm fuzzy feeling after communicating with the client a few times you should really figure out why.  You’re going to know their project better than they do so you’d better figure it out before starting a big project.

Ironically some of our longest term clients were hard to work with at first.  See, they had bad experiences with other developers and were wary of being burned again.  Keep that in mind too. They’re being hard on you because they weren’t with their last developer.

These are just a few of the red flags that should concern you when talking with prospective clients.  What red flags do you look for?


Xojo 2019 R1

$
0
0

Xojo 2019 R1 was released today. This is the 2nd release in a row where there is not a dramatic number of new features but quite a few bug fixes and enhancements. Let’s dig into what’s changed in this release!

The big change in this release revolve around the URLConnection control. The HTTPStatusCode property is now available for both the Send and SendSync calls. The control now appears in the library. It now yields to other threads. Send requests are now closed before the ContentReceived and FileReceived events are fired. The string encoding for the ResponseHeaders is now consistent across platforms. It also now automatically handles compressed content-encodings in Windows and Linux (just like MacOS does). The TimeOut property now works (before it always did 30 seconds). Error messages are no longer empty in Windows. The ReceivingProgressed event now correctly reports the total bytes. The response headers are now updated property when a request is made. The SendSync no longer intermittently returns empty strings in MacOS.

The licensing has changed for Raspberry Pi. The license for Desktop and Console applications on the Pi is now free!

There are some other new items. The list is small but significant. The first is that 32-bit Windows builds can now set HiDPI and supported versions properties in the manifest file.

The TextArea control for Windows 8 (or newer), and Linux now support system spell checking. This matches the behavior on MacOS.

The Text datatype now has target appropriate EndOfLine properties. If you use Text you’ll no longer have to create your own EndOfLine constants.

The IDE added the ability to switch between Computed Properties and manual Getter/Setter methods. There is a new menu item when right-clicking on a property. In addition to the standard Convert To Computed Property there is a new menu item called Convert To Method Pair which creates two overloaded methods. For example, if you have MyProperty as Integer and select the Convert to Method it will create one MyProperty method that returns the integer value and another overloaded method that accepts an integer value with an assigns. So it looks like to consumers of this property as if nothing changed.

The constants setting has been changed from Dynamic to “Localized.” This creates a new grouping in the Code Editor called “Localized Strings”. It’s still a constant but it better reflects that it’s localized and should make it easier to visually see if a string is localized or not as there was no easy way to tell before.

There are 25 changes and 162 bug fixes for Xojo 2019 R1. Here are what I feel are the significant items:

The ODBC Database plugin now works better with 64-bit builds. Date fields in MacOS now work properly. In 64-bit Windows updating a binary/image column no longer fails with an invalid precision error.

The MySQLCommunityServer plugin no longer crashes when has certain field types and originated from a PreparedStatement.

The SQLiteDatabase no longer crashes when out of memory situations arise – an error is now generated.

Calling an OpenDialog from within a thread now properly raises a ThreadAccessingUI exception. I’m actually surprised that this wasn’t flag a long time ago.

StringShape rotation is no longer incorrectly offset. The original Feedback report was for Linux but it appears this affected other targets too.

The Window/Canvas Backdrop picture now draws correctly in HiDPI. This doesn’t affect me directly but this is the first time in several years where Canvas drawing in Windows seems really solid. I’m in testing right now with a client app that had been held back in 2017 R2.1 because of Windows drawing performance.

GroupBox caption in Windows now properly draws the size, bold, italic, and underlines styles instead of ignoring them.

A bunch of work was done in the Code, Constant, Layout, and FileTypes editors. The Inspector and Library received a little love too.

You can read the release notes at http://docs.xojo.com/Resources:2019r1_Release_Notes to get the entire list and see if anything affects you.

Conclusions

So far I’ve found this release to be solid and the major updates to URLConnection now appear to make it worthy of investigation. I’ve not used it enough, yet, to recommend it but I think most of the major bugs are worked out. The number of bug fixes and enhancements makes R1 a worthwhile upgrade.

I think this version is worthy of your time and effort to try out. As always, you should really test Xojo out on your projects, in all targets, to make sure it works as expected. Some of the bug fixes in this release might mean you have to get rid of some workarounds you’ve come up with (thinking of the StringShape rotation fix here).

You can download the new version at https://www.xojo.com/download/

Let’s hope that the major new features (like API 2.0, Web 2.0, and Android) can be staggered so there there isn’t a flood of new things in a single release. Too many new things makes it hard on beta testers.

Have you found any showstoppers? What are you most happy about in this release?

Until next time, Happy coding!

XDC 2019: Web Framework 2.0

$
0
0

At XDC 2019 Greg O’Lone of Xojo showed us the current status of Web Framework 2.0.

The design goals for the web framework:

Update the server technologies.

Improve responsiveness

Modernize the framework

New and Updated Controls

Improved Browser Support

HTTP 1.1 compliant server.

Minified frameworks and Client Rendering (more done on the browser now)

jQuery – feature rich JavaScript library

Boostrap and FuelUX controls

Browsers:

Support as many of the current browsers as possible.  Current framework parses headers to determine what to support but most browsers lie.  Going to ask the browser what it supports.  The controls themselves will determine what they can do.  Things like TouchEvents and File API support might change.

Adding Browser History triggers.  Can tell the session that something happened.  For example if user was filling out form partially and hit back button.  When they come back to the site the HashTagChanged event fires can allow you to get that information back

Visual Session Controls.

Server Connection Monitor.  New dialog to show user that it’s having problems communicating.

Layout Modes:  Fixed, put a control on a layout and it just stays there.  Fluid layout lets controls flow around in the container.  Auto(layout) – not in version 1.

Big list of already supported controls.  New ones:  MessageDialog, PagePanel, Breadcrumb, Rich Text Editor.

Big functionality updates:  File Uploader (splitting engine from the interface).  Listbox has pagination, dynamic data sources, sortable columns, built-in filtering, custom column types.  Canvas has layers, events, and Drag and Drop on browser side.  Toolbar is Bootstrap (but will have icons) and it will act more like the desktop toolbar.  TextFields gets browser side text formatting and validation.  MenuItems are theme compliant, disabled items, hierarchical, separators, and headers.

Styles:  Existing editor is painful.  All projects will get the global Bootstrap theme.  Drop-in theme replacement.  Themes can be previewed in the IDE!!!  Selective control-level customization more like what we get on the desktop.  Property-level style access which means will be able to change styles via code!

Project transition is a one way operation.  Using API 2.0 but will still use the deprecated API.  Some things like ListBox.AddRow will automatically converted to new API.  CGI projects are going away and the only option will be standalone.

Xojo Cloud will be using only 64-bit standalone apps.  You’ll get Load balancing and multiple domain names.  Must be using the newer server configurations.

WebSDK 2.0:  jQuery, Bootstrap and FuelUX will be included.  Browser feature detection and we’ll be able to query to see if a browser can do something.  

TypeScript allows us to compile the Javascript that all browsers use.  Get some definition files and other things.

Greg shows us a demo of the Web Framework 2.0:

Shows a WebPage that has working TabPanel.  Layout Editor drag and drop not working quite like it will in release version.  Shows me MessageDialog.  Shows new ChartingControl.

He then shows us changing the theme.  Simple drag and drop of Cyborg theme changed everything in the project.  Very nifty.

Greg shows us pre-Alpha Feedback using Web Framework 2.0.  TextField support password managers now!   Buttons are Escape and Enter sensitive now.  Listbox has custom column types:  Picture column and URL column.  Clicked on a link (Feedback report) and then opened it.  Showed use of the back button that took us to previous action.  Then showed Dynamically Load listbox an dhow it loaded more data as he scrolled to the bottom of the list.

Very functional demo!

Q & A:

Message Dialogs have icons?  Yes, just like current desktop.

The demo showed 3 buttons.  Will it return values?  Yes, just like current desktop.

Will container control will be draggable?  Redesigning drag and drop.  So maybe?  Might not be right away.

Pushing more stuff down to the client will be have access to hardware/devices on client side?  You’d have to use Internet Explorer and the WebSDK to load and ActiveX control.

How easy to support Dark Mode in web apps?  Only supported in Safari.  Answer is maybe and change the stylesheet on the fly.

Recommend load balancer for new web framework?  No.  Used it with several load balancers and they all worked.  Changed how much data is being transferred between client and server.  Transmissions cut down by 60%.

Can users change theme at runtime?  Yes.  Maybe not in version 1.

With Xojo Cloud load balancing is there any scheduling or rules?  Control distribution is up front – no thoughts on scheduling.

With new Canvas control would you be able to create a game with it?  Their intention is to expose the canvas handle to developers.  Some restrictions.

Custom skinning on progress wheels?  Yes.  Current one is SVG and it just rotates it.

How will editing in web listbox work?  Custom column type.  Doesn’t work today but a huge want.

Listbox has a built-in Search Field.  ListBox in general has a number of things built-in.  By Default has pagination and search field.  Will eventually support multiple layout types (list, picture) but not for version 1.

Open events work by the way.

Will tags be available in more places?  We haven’t done that yet.  Unknown if it will get into version 1.

User get click happy is there a way to prevent weird stuff from happening?  Still have the Auto Disable for buttons.  There is some mechanism in place to prevent the exact same event from being sent to server.

Column sorting and pagination?  Adopted desktop behavior for column sorting.  Sorting a column will requery the database.  Always goes back to the data source.

Listbox.CellTextPaint and Listbox.CellBackgroundPaint Memory Leaks

$
0
0

There are bugs and then there are bugs.  Not all are created equal and certainly not all are worthy of a dot release.  But when a serious bug comes to light you have to take it seriously.

Feedback 55596 is a perfect example of this.  If you use Listbox.CellTextPaint or Listbox.CellBackgroundPaint your app will leak memory.  Leaking memory is bad to begin with but since the Listbox calls these events frequently.  Losing 64 bytes per call adds up quickly.

I was going to do a release today for a client using 2019 R1.  This was the first release where Windows drawing was as fast as older versions of Xojo.  Prior releases of this product had to be built with 2017 R2.  So now what do I do?  I’m damned if I do a build and I’m damned if I go back to 2017 since we have to retest everything.

Xojo Inc. doesn’t seem interested in doing a dot release.  On the forum Greg was quoted as saying, “…doing a point release is not an insignificant task and takes resources away from making progress on other things, never mind the additional stress that comes with it.”  Who cares if it’s work on their part?  Seriously, if I can’t use the current public release then why am I here?  It’s bad enough I’ve been chasing Xojo versions for nearly two years with Windows drawing.

This is part of a much bigger issue that many at the Xojo Developers Conference discussed a few weeks ago.  Xojo has always been a lean organization and many times I’ve felt that it’s been quite anemic.  But an important bug and a public release to fix it shouldn’t be a major stress inducer to the developers.  To me this says there are too few developers and too much work on their plate.

For what it’s worth, the bug is marked as fixed as of May 14th.  It’s still too early to tell if we’ll get a dot release for such an important bug fix.  Maybe R2 is just around the corner but I don’t have time for a 30 to 60 day beta period.  I need this fix now.

Xojo 2019 R1.1

$
0
0

A dot release for Xojo 2019 Release 1 was released today.  Xojo 2019 R1.1 has several significant bug fixes.  This release is highly recommend for all users.

Perhaps the biggest bug fix is related to ListBox.CellbackgroundPaint and Listbox.CellTextPaint events.  They no longer leak memory 64 bytes of memory each call.

In Windows URLConnection received some attention.  They sped up socket requests and decreased the CPU usage.  Authentication no longer hangs when there is request content present.  The events for URLConnection are no longer re-entrant.  This is fancy way for saying that some events, like PageReceived would get called a lot rather than just once and could cause some issues depending upon usage.

Changing the case of label now changes the text in Windows.  For example if you set the label1.text = “lower” and then tried label1.text = UpperCase(label1.text).

Also in Windows, TabPanels embedded within another TabPanel no fires the Changed event multiple times.

One new thing made it into this build.  iOS projects now add default plist entries for NSLocationWhenInUseUsageDescription, NSLocationAlwaysUsageDescription (for iOS 10) and NSLocationAlwaysAndWhenInUseUsageDescription (for iOS 11+).   These can be overwritten by user plist files.

I am glad to see this dot release version of Xojo.  I know we like to beat up on Xojo Inc for various things but I think they generally do the right thing for the community.

(168)

Don’t Use GoTo

$
0
0

At XDC 2019 my session was titled Xojo Design Mistakes (the alternate but way longer title was ‘Thankfully time travel doesn’t exist or my future self might travel back and murder my younger self for the stupid coding mistakes I’ve made’).  These are things that I’ve discovered over the years, both in my own projects and in other peoples projects that are just plain wrong or less than ideal.  This will be an on-going series since I had well over 50 slides and left about 150 out.  So when I get bored I’ll bring these topics up.

Don’t use GoTo – ever.  GoTo is a holdover from the old BASIC days where code was unstructured and you needed to manage flow-of-control.  Old BASIC programs used a ton of GoTo statements because, well, you just had to.  It was the only way to get anything done.  Xojo uses a modern BASIC syntax but it’s fully object-oriented code and still has GoTo as a reserved keyword and it still functions.

Xojo has many ways of doing flow control.  There are multiple ways of doing loops with While’s, Do-Loop’s, For-Next’s, and we control those loops with keywords such as Continue, Exit, Return.  Since we have methods and functions too we can exit those by calling Return at any point in the method and the code resumes execution at that point.  GoTo just isn’t needed any more.

And yet GoTo still exists.  I recently ran across this code in a project we’re updating for a client.

As you can see we are in a fairly typical For-Next loop iterating through a ListBox.  The first line into the loop we check if we’re closing the window and if we are we call GoTo bale which takes us to where bail: is.  Bail is at the bottom of the method and we’re doing nothing afterwards (the last two lines are Exception handling in this method and aren’t called).

This is such a poor example of Xojo coding.  We can use Exit to accomplish the same thing since Exit will immediately exit the loop and since there would be nothing after the loop it would simply leave the method entirely by simply calling Return.  There’s no penalty for using either Exit or Return.

Honestly, I have no idea why the original developer did this.  I think they came from VB6 where code like this was pretty common, but even in that language there were much better ways to do the same thing.  So I will call this lazy coding because the developer didn’t use the best way in Xojo.

Using GoTo like this is potentially risky too.  Feedback case 24710 shows that using GoTo may cause a memory leak because the compiler may skip cleanup code.  I think the above code is safe but I could see if we loaded oNote before the GoTo exiting the loop it would be dangerous.  But even still, if GoTo is outdated, not recommend, and dangerous on top of all that why use it?  I can think of at least three ways to make this code safer and better.

At the end of the day, If you’re using GoTo – don’t.  Refactor your code so it makes use of the modern Xojo calls. It’s safer and the right way to code in Xojo.  Your future self will thank you.

Viewing all 119 articles
Browse latest View live