Copilot is getting better.

Daestrum

Expert
Licensed User
Longtime User
Just for sh*ts and giggles I gave this to Copilot

I just told it it was B4J UI code and what did it make of it.
B4X:
Sub Process_Globals
    Private fx As JFX
    Private MainForm As Form
    Private xui As XUI
    Private TableView1 As TableView
End Sub

Sub AppStart (Form1 As Form, Args() As String)
    MainForm = Form1
    MainForm.RootPane.LoadLayout("Layout1")
    MainForm.Show
    ' TableView1 has 3 columns Name, Age, Gender

    ' add some dummy data to the tableview

    ' call the sub to search tableview for "Fred"
End Sub

' Create a sub here that searches for names in tableview that start with specified string
' and log any that are found

This is what I got back after it said "lets add the missing bits."

B4X:
Sub Process_Globals
    Private fx As JFX
    Private MainForm As Form
    Private xui As XUI
    Private TableView1 As TableView
End Sub

Sub AppStart (Form1 As Form, Args() As String)
    MainForm = Form1
    MainForm.RootPane.LoadLayout("Layout1")
    MainForm.Show

    ' Adding dummy data to the TableView
    Dim dummyData(4) As Object
    dummyData(0) = Array("Fred", 30, "Male")
    dummyData(1) = Array("Alice", 25, "Female")
    dummyData(2) = Array("Frederick", 40, "Male")
    dummyData(3) = Array("John", 22, "Male")

    For Each item As Object In dummyData
        TableView1.Items.Add(item)
    Next

    ' Call the sub to search TableView for "Fred"
    SearchTableView("Fred")
End Sub

' Sub to search for names in TableView that start with the specified string and log any that are found
Sub SearchTableView(SearchString As String)
    For i = 0 To TableView1.items.Size - 1
        Dim row() As Object = TableView1.items.Get(i)
        Dim name As String = row(0)
        If name.StartsWith(SearchString) Then
            Log(name)
        End If
    Next
End Sub

I was quite impressed.
 

AnandGupta

Expert
Licensed User
Longtime User
So very soon we will have correct b4x codes written by A.I.
It will definitely help B4X. Very Good.
 
Cookies are required to use this site. You must accept them to continue using the site. Learn more…