Aloe and Newbie

Hi, filemaker developer trying to understand the Aloe and XFM combination from @Tim Dietrich (thanks tim, see you in Denver), to build better website. Was able to combine Aloe Express and XFM, but am running into a issue, where some guidance would be appreciated ( never posted in a forum, normally i resolve it myself after banging my head a few times in the wall).

Have not yet fully embarked on the Xojo way of working, so limited experience, as my go-to-tool is still Filemaker. The problem:

When I am retrieving records from the Filemaker Database, using XFM, and if i have more then 1 record then no problem can build the HTML table all fine. But when the result-set is only 1 record, then app is not building the HTML variable, it gets stuck in the for loop. I did not change the sample XFM code which is:
// Loop over the records…
For i As Integer = 0 To Records.Count - 1

// Get the next record.
Dim Record As JSONItem = Records(i)

// Get the fields for this record.
Dim Fields As JSONItem = XFM.FieldsGet(Record)

This works fine for multiple records but not for 1 record retrieved in the XFM logic. Hope this makes sense.

Tried to catch the issue by using if statement:

if Records.Count = 3 then
// Get the next record.
Dim Record As JSONItem = Records(0)

// Get the fields for this record.
Dim Fields As JSONItem = XFM.FieldsGet(Record)

But also this does not work.

Hope this makes sense?

Kind regards,

I don’t have XFM or Filemaker so my advice is blind, but are you examining the contents of record in the debugger as you step through this code? Is there a difference between the 1 record and multiple records case?

If not, then you’d have to suspect something in the XFM.FieldsGet method. If XFM ships with source code you could step into that method as well and see what the difference might be between the two cases.

@Ron Hollebrandse :

In your code, before you start looping over the records, add this:

[code]If Records.IsArray = False Then

Dim RecordsString As String = “[” + Records.ToString + “]”
Records = New JSONItem(RecordsString)

End If[/code]

That should resolve the issue. If not, let me know.

Sorry for the short reply. I’m slammed this morning.

@Kevin Windham the main difference was that indeed there was a difference: multiple records where returned within [ ], so array, and the single record was returned as { } so an object. Within Filemaker i know exactly how to deal with that, but within xojo I am still not experienced enough to easily resolve this. Would have been great to have a data viewer like in Filemaker ( where you can directly see the outcome of variables etc and play with the calculations ). Thanks for your input!

@Tim Dietrich thanks for the solution, working now, sweet and simple. Planning to use Aloe and XFM to integrate with our current filemaker solutions, the look and feel by building the site with Rapidweaver and have the data available via Aloe & XFM is a game changer for us, we now just need to spend the time to better understand xojo.

@Ron Hollebrandse - Glad I could help. Let me know if you have any other questions about Aloe and XFM.

Also, I’ll be releasing new versions of both Aloe Express and XFM next week. The new version of Aloe Express will support Mustache-like templating (see The new version of XFM will be fully unlocked, and will include improved support for connecting to FileMaker Server 16 over https.

Looking forward to meeting you at XDC.