ChatGPT saves me more time again for a slight mod...

JohnC

Expert
Licensed User
Longtime User
My ChatGPT 4.0 Prompt = "The below B4A code simply hides or shows a panel when the screen is touched. Please modfy the code so that if the screen is touched in the middle of the screen (with a 10% margin), it will instead call another routine called "MuteAudio":
B4X:
Sub pnlInv_Touch (Action As Int, X As Float, Y As Float)
   If Action <> 0 Then Return
 
   If pnlButtons.Visible = False Then
        pnlButtons.Visible = True
   Else
       pnlButtons.Visible = False
   End If
End Sub

ChatGPTs response within 5 seconds (ChatGPT even added comments to the code!):

To modify the code so that it calls the "MuteAudio" routine when the screen is touched in the middle (with a 10% margin on either side), we first need to determine the dimensions of the screen, and then calculate where the middle region is. This is how you could modify your code:

B4X:
Sub pnlInv_Touch (Action As Int, X As Float, Y As Float)
    If Action <> 0 Then Return

    ' Get screen dimensions
    Dim ScreenWidth As Float = 100%y
    Dim ScreenHeight As Float = 100%x

    ' Calculate middle area boundaries (10% margin)
    Dim Margin As Float = 0.10
    Dim LeftBoundary As Float = ScreenWidth * Margin
    Dim RightBoundary As Float = ScreenWidth * (1 - Margin)
    Dim TopBoundary As Float = ScreenHeight * Margin
    Dim BottomBoundary As Float = ScreenHeight * (1 - Margin)

    ' Determine if touch occurred within middle area
    If X > LeftBoundary And X < RightBoundary And Y > TopBoundary And Y < BottomBoundary Then
        ' Touch occurred within middle area, call MuteAudio
        MuteAudio
    Else
        ' Touch occurred outside middle area, toggle visibility of panel
        If pnlButtons.Visible = False Then
            pnlButtons.Visible = True
        Else
            pnlButtons.Visible = False
        End If
    End If
End Sub

Sub MuteAudio
    ' Code for muting audio goes here
End Sub

This B4A (Basic for Android) code checks if the screen was touched in the 10% margin of the center of the screen, if so, it calls the "MuteAudio" routine, otherwise, it toggles the visibility of the panel as before. Remember to replace ' Code for muting audio goes here with the actual code to mute the audio.

I copied and pasted the code and it worked just as I wanted - Simply VERY cool!
 
Last edited:

Daestrum

Expert
Licensed User
Longtime User
I might be being picky, but isn't X usually the width and Y the height.
 

Hishow

Member
Pretty soon programmers will be out of a job lmao
Chat GPT is just to guide us on our codes. It can't right a complete Application for us. So no matter how we see it. The Programmers will remain relevant till eternal.

The only thing we can say is that, the number of Programmers will increase as it will now be easier to code and get free guidance from Chat GPT.

Thank you
 

amorosik

Expert
Licensed User
Chat GPT is just to guide us on our codes. It can't right a complete Application for us. So no matter how we see it. The Programmers will remain relevant till eternal.

The only thing we can say is that, the number of Programmers will increase as it will now be easier to code and get free guidance from Chat GPT.

Thank you

If you know how to place a brick correctly, then it is highly probable that you already know how to build a house
Whether or not you CURRENTLY build houses
The really surprising thing for ChatGpt is the "understanding" of the question being written, understood as the ability to provide an answer perfectly congruent with the question asked
And this, if combined with the very large memorization capacity and the exceptional speed of current computers, allows it to respond 'quite well' on any topic
In consideration of the fact that the current technology available in research centers is certainly more advanced than what the general public sees, I believe that we have already arrived and we have already exceeded the limit of the Turing test
We are witnessing, right now, a new era of information technology
Like when the www was born
 
Last edited:

JohnC

Expert
Licensed User
Longtime User
It can't right a complete Application for us.
When we write a "complete application" from a customer's spec, we first break it up into a list of small sub-routines that we need to first create, then tie them together to get the finished product.

It's not that big a leap for AI to also break the details of a "complete app" into a list of small sub-routines, write the code for those routines, and then tie them all together.
 

techknight

Well-Known Member
Licensed User
Longtime User
When we write a "complete application" from a customer's spec, we first break it up into a list of small sub-routines that we need to first create, then tie them together to get the finished product.

It's not that big a leap for AI to also break the details of a "complete app" into a list of small sub-routines, write the code for those routines, and then tie them all together.

And when the AI learns to be able to do that, it can then develop the ability to alter its own programming and compile itself. Thats bad for multiple reasons.
 
Top