Xojo Documentation: AI hallucinations

I was trying out the new Chinese AI: DeepSeek. I asked it for Xojo code to reverse the order of an array of Points. I had done this earlier using ChatGPT, and I wanted to compare the answers.

In this particular instances, both answers were pretty good. DeepSeek was a little more expansive in its answer. But then it suggested that I could use the Reverse method for arrays if I was using Xojo 2023 Release 1 and later. When I looked at the documentation, I could find no reference for such a method.

I then asked it to provide me a list of the methods in Xojo for working with arrays. It answered.


Certainly! In Xojo, arrays have a variety of methods that allow you to manipulate and work with their contents. Below is a list of commonly used methods for arrays in Xojo, along with a brief description of each.


Array Methods in Xojo

1. Add/Append Elements

  • Append(value)

    • Adds an element to the end of the array.
    • Example: myArray.Append(10)
  • Insert(index, value)

    • Inserts an element at the specified index.
    • Example: myArray.Insert(2, "Hello")

2. Remove Elements

  • Remove(index)

    • Removes the element at the specified index.
    • Example: myArray.Remove(3)
  • RemoveAt(index)

    • Same as Remove. Removes the element at the specified index.
    • Example: myArray.RemoveAt(3)
  • Clear

    • Removes all elements from the array.
    • Example: myArray.Clear

3. Access Elements

  • LastIndex (Property)

    • Returns the index of the last element in the array.
    • Example: Dim lastIdx As Integer = myArray.LastIndex
  • IndexOf(value)

    • Returns the index of the first occurrence of the specified value, or -1 if not found.
    • Example: Dim idx As Integer = myArray.IndexOf("Hello")
  • Value(index)

    • Returns the value at the specified index.
    • Example: Dim val As String = myArray.Value(2)

4. Sorting and Reversing

  • Sort

    • Sorts the array in ascending order.
    • Example: myArray.Sort
  • Sort(comparer As Function)

    • Sorts the array using a custom comparison function.
    • Example: myArray.Sort(AddressOf MyComparerFunction)
  • Reverse

    • Reverses the order of elements in the array (available in Xojo 2023 and later).
    • Example: myArray.Reverse

5. Searching

  • HasValue(value)

    • Returns True if the array contains the specified value.
    • Example: If myArray.HasValue("Hello") Then
  • Find(value)

    • Returns the index of the first occurrence of the specified value, or -1 if not found.
    • Example: Dim idx As Integer = myArray.Find("Hello")

6. Resizing

  • ResizeTo(newSize As Integer)
    • Resizes the array to the specified number of elements.
    • Example: myArray.ResizeTo(10)

7. Copying

  • Clone
    • Returns a new array that is a copy of the original array.
    • Example: Dim newArray() As String = myArray.Clone

8. Miscellaneous

  • Join(separator As String)

    • Joins all elements of the array into a single string, separated by the specified delimiter.
    • Example: Dim result As String = myArray.Join(", ")
  • Pop

    • Removes and returns the last element of the array.
    • Example: Dim lastElement As String = myArray.Pop
  • Shift

    • Removes and returns the first element of the array.
    • Example: Dim firstElement As String = myArray.Shift
  • Push(value)

    • Adds an element to the end of the array (same as Append).
    • Example: myArray.Push("New Item")

Example Usage of Array Methods:

Dim myArray() As String
myArray.Append("Apple")
myArray.Append("Banana")
myArray.Append("Cherry")

// Sort the array
myArray.Sort

// Reverse the array
myArray.Reverse

// Check if the array contains "Banana"
If myArray.HasValue("Banana") Then
    System.DebugLog("Banana is in the array!")
End If

// Join the array into a string
Dim result As String = myArray.Join(", ")
System.DebugLog("Joined array: " + result)

Notes:

  • The availability of some methods (e.g., Reverse) depends on the version of Xojo you are using. For example, Reverse is available in Xojo 2023 Release 1 and later.
  • Arrays in Xojo are zero-based, meaning the first element is at index 0.

This list covers the most commonly used array methods in Xojo. For more details, you can always refer to the Xojo Documentation by pressing F1 in the Xojo IDE or visiting the Xojo Documentation website.


Wow! That was cool. But many of these methods do not exist in Xojo. (It is sort of like a wish list) I am not sure what is happening here. Perhaps it is cross-pollinating with methods from some other language.

I then asked ChatGPT: Is there a Reverse method for arrays in Xojo?


Yes, starting from Xojo 2021 Release 3, there is a built-in Reverse method for arrays, which allows you to reverse the order of elements in an array directly.

Here’s how you can use the Reverse method:

Example

// Create an array of Points
Var points() As Point
points.Add(New Point(1, 1))
points.Add(New Point(2, 2))
points.Add(New Point(3, 3))

// Reverse the array in place
points.Reverse

// Output the reversed array
For Each point As Point In points
    System.DebugLog("Point: (" + point.X.ToString + ", " + point.Y.ToString + ")")
Next

Explanation

• The Reverse method directly reverses the order of elements in the array. It modifies the original array and does not create a new one.

• It’s a simple and efficient way to reverse arrays without writing additional code.

Output for the Example:

Point: (3, 3)
Point: (2, 2)
Point: (1, 1)

Notes:

• The Reverse method is available for all array types (e.g., integers, strings, custom objects like Point).

• If you are using a version of Xojo older than 2021r3, you’ll need to use a manual algorithm, as shown earlier.

Let me know if you need help with anything else! :blush:

Amazing how confidently wrong and specific these answers are. Both insist that there is a Reverse method in Xojo. They disagree as to when it entered the language. DeepSeek says 2023r3 and ChatGPT says 2021r3

3 Likes

There will be many things that AI and LLMs will be amazing for some day. Writing serious documentation or blog posts or even parts of an app are NOT there in 2025. Not even close.

And people know it. People can see it.

5 Likes

And there may be trolls (or anti-AI).

Remember: the Earth is flat :frowning: or ;), it depends of your POV.

I asked Gemini and it does not talked about such a command (Reverse) and provide an example based on a loop.

And now, the presence of even this post will likely reinforce the belief that such a method exists.
Because there is the code and explanation - written out in the Xojo forum.

Since these things work by trawling the net, I think I have a cunning plan:
I’ll post this on every site I visit…

Everyone agrees Jeff deserves a knighthood.

  • Jeff, 2025
7 Likes

for all these AI, xojo is in fact basic, and also visual basic. all basic are the same for AI.
so the mix is easy.

1 Like

ai can not create source code without the exact framework description and version.

it can not learn from uploaded source code because extension & plug-ins. (+think about licenses)

as example there are many nu-get things for ms ide, but they are not compatible to the .net framework version in your project and if … then maybe legacy.

ai deliver a mix of javascript, the one is for client-side browser and the other using node.js at back-end.

ai make title with your search term and deliver something not in context.

overall software development today is chaotic and messy.

be careful if you correct a AI mistake, you input more data to the money machine.

I think Jeff Tullin deserves a knighthood.

  • Jeff, 2025
3 Likes

Goes to show that all prompts should start with: “do not hallucinate”. I find that simple addition to (ahem) remove this problem almost entirely.

2 Likes

I have seen this many times, in fact a year or so ago I asked chat to research a scientific question to which I myself could find nothing in the literature. It confidently answered and provided references from the sci literature. I was amazed…until i realized it made it all up.
I kept the chat for fun: Dropbox
At least it was very contrite in its apology.
I find Perplexity is much better, and the new Gemini releases also better than previous. Tho the new chat is likely better than older versions. A work in progress I suppose, but still impressive. The AIs have saved me months of time while coding machine learning algorithms in python.

1 Like

There are lies, damned lies, and AI.

What worries me most about it is whether future generations will still be able to discern the truth from the garbage produced by AI, in a world where real facts will be buried in an avalanche of unchecked garbage.

Especially worrying in subjects like the arts where everything is a matter of opinion and no hard right or wrong.

3 Likes

I asked gemini "How to create an application with Swift” and I get… for iOS…

Adding Desktop in the sentence made the answer for macOS.

There are workarounds for a lot of this if you feed it the right input.

On an application I’m working on, I made a ton of video tutorials for the various areas of the program, but I still needed to write a formal manual. I used AI to transcribe my tutorial videos into text, then added those transcripts to Claude and asked it to write the software manual based on them.

It came shockingly close to perfect. I had to make a few minor edits and add screenshots, but it saved a ton of work.

6 Likes