06-16-2025, 04:00 PM
Yes, a lot lately. But actually I use it to help me expand into other languages. I run QB64pe from a Mac. I can usually write what I want in BASIC without too much issue. Some things just run better from a shell command to a script, whether it's AppleScript, Automator, Python, etc. I don't know how to program in any of those languages, and yet I can with ChatGPT's help.
Ok, here goes. I have a bunch of interface boards from National Control Devices. A 32 output relay board, a 24 switch input board, an 8 potentiometer output board, and some others. I plug them into the USB port of my computer and send them simple binary codes to control them. I used them over 10 years ago to run a very complicated coil winder from a Windows computer. Now I am re-purposing them, but don't use Windows anymore (and don't want to). But QB64pe can't write to a virtual com port from a Mac. I decided that Mac must be able to write to the port, so I would have to find a shell command or something to accomplish this.
So I went to ChatGPT. I asked it to help me use a QB64pe program to read and write characters from a Virtual USB port on my Mac. It took me nearly 12 hours of chatting and testing but it got me there. Here's what I discovered and did:
The output boards use an FTDI driver to make a virtual com port. You can download the drivers for Mac/Linux/Windows, but the Mac already has them. ChatGPT wrote a helper script in Python. It opens a virtual com port with the proper settings. It takes any data that shows up at the port (incoming) and prints it to a temporary file, Receive.txt. It looks for a temporary file called Send.txt, and if it finds the file it sends its contents to the virtual port. In QB64pe BASIC the application first sends a shell command to start the python script at the launch of the program. When I want to send a command to the boards, it opens the Send.txt file for output and prints the data to it, then closes the file. The Python script sees it and sends it to the port. When I want to receive I do the same thing for the Receive.txt file. When I am finished I send a shell command to kill the Python script, then close the port. In the end, the BASIC side looks much like writing to a port using "open com" but actually works on a Mac. ChatGPT helped me use Terminal to identify the relay board when it was plugged in. It helped me to use Terminal to test the port and loopback the board. It helped me write the Python helper program. It showed me how to check permissions and such. It showed me how to incorporate it in BASIC. And it showed me how to shut it all down when I was finished. I now have my boards running from my Mac, but it took me about 12 hours to get through it all.
By the way, I was concerned about time delays passing everything through temp files, but as it is only a few characters at a time there weren't any significant delays. When I get a chance I'll write this up for anyone who needs something like "Open com" for use on Mac.
My advice and experience with ChatGPT: Think like a programmer. Give adequate background information. Edit your question or ask something specific if the response you got doesn't quite work. Make sure you add safeties, for example; it told me how to write the helper script, but I had to ask if I needed to close it afterward. Describe what you want the program you are writing to do, in detail. You can upload your program if it helps, you can also paste error messages and such into the dialog box. Don't get lazy and expect ChatGPT to write a long complicated program. It will do it, but it will have too many errors to deal with. Instead just ask it to help you with the parts you don't understand or know how to do. Keep patient, it will keep track of everything you asked it, and you can just keep refining and testing until you get there.
It will be wrong often. At one point it told me the QP64pe has a command called "Open com" that I could use even though I told it I was using the Mac version. I replied "Open com" isn't available in the Mac version. It said "you're right" then gave me an alternative.
It will usually give you the whole code block. But the more time you spend refining it, the more it will want to give you just the sections that changed, and the more it will give you multiple choices on how to solve and test it. It can get overwhelming. You can slow it down by saying "tell me more about choice 3", or "show me the whole program". If you sign up (even for free) it will remember your sessions. You can go back later and continue or even change questions. If you want it to process things like images, you will quickly need to go to a paid version. That kind of processing is intensive. I did use it once to make an icon for my program.
This is getting long, but one last example. I am using a lot of downloaded subtitles. Basically TXT files with an SRT extension. But I don't want text for the hearing impaired (SDH), or color or font changes. SDH usually uses [ for captions, and { for font commands. I have software that can clean up these files, but if I have 100 files I may only need to clean a few. But which ones? So (abbreviated) here's what happened with ChatGPT:
"I am using a Mac m2 pro running Sequoia 15.5. I want to highlight a group of text files in finder, then right-click on them to run a service called 'SRT Pre-scan'. I want a script to search those files for any of the following characters [{< and un-highlight any files that don't contain them"
ChatGPT wrote the script, and showed me how to build it in Automator, install it, and give it permissions. I tested the script. I highlighted a bunch of files, right-clicked and chose 'SRT Pre-Scan', and it un-highlighted the files that did not contain those characters. It left the other files highlighted, so I could just drag them onto my cleaning program. I realized that I might choose some non-SRT files by accident, so I told ChatGPT:
"That worked but I want it to ignore and de-select any files that aren't .srt or .txt"
It gave me the new code, which worked. Several days later I noticed that if I selected a group of files and clicked "SRT Pre-Scan", if all of the files contained those characters then then proper output from the script would look like nothing had happened. So I went back to ChatGPT and said:
"When I run this script, if all of the files or none of the files contain the characters I'm searching for, I want a pop-up box to tell me that"
And ChatGPT fixed it for me.
I realize that last example has nothing to do with QB64pe, but it shows what ChatGPT can be like, and can easily be applied to QB64pe. I love QB64pe, but I also realize how much more I can do with it by combining it with other methods.
Ok, here goes. I have a bunch of interface boards from National Control Devices. A 32 output relay board, a 24 switch input board, an 8 potentiometer output board, and some others. I plug them into the USB port of my computer and send them simple binary codes to control them. I used them over 10 years ago to run a very complicated coil winder from a Windows computer. Now I am re-purposing them, but don't use Windows anymore (and don't want to). But QB64pe can't write to a virtual com port from a Mac. I decided that Mac must be able to write to the port, so I would have to find a shell command or something to accomplish this.
So I went to ChatGPT. I asked it to help me use a QB64pe program to read and write characters from a Virtual USB port on my Mac. It took me nearly 12 hours of chatting and testing but it got me there. Here's what I discovered and did:
The output boards use an FTDI driver to make a virtual com port. You can download the drivers for Mac/Linux/Windows, but the Mac already has them. ChatGPT wrote a helper script in Python. It opens a virtual com port with the proper settings. It takes any data that shows up at the port (incoming) and prints it to a temporary file, Receive.txt. It looks for a temporary file called Send.txt, and if it finds the file it sends its contents to the virtual port. In QB64pe BASIC the application first sends a shell command to start the python script at the launch of the program. When I want to send a command to the boards, it opens the Send.txt file for output and prints the data to it, then closes the file. The Python script sees it and sends it to the port. When I want to receive I do the same thing for the Receive.txt file. When I am finished I send a shell command to kill the Python script, then close the port. In the end, the BASIC side looks much like writing to a port using "open com" but actually works on a Mac. ChatGPT helped me use Terminal to identify the relay board when it was plugged in. It helped me to use Terminal to test the port and loopback the board. It helped me write the Python helper program. It showed me how to check permissions and such. It showed me how to incorporate it in BASIC. And it showed me how to shut it all down when I was finished. I now have my boards running from my Mac, but it took me about 12 hours to get through it all.
By the way, I was concerned about time delays passing everything through temp files, but as it is only a few characters at a time there weren't any significant delays. When I get a chance I'll write this up for anyone who needs something like "Open com" for use on Mac.
My advice and experience with ChatGPT: Think like a programmer. Give adequate background information. Edit your question or ask something specific if the response you got doesn't quite work. Make sure you add safeties, for example; it told me how to write the helper script, but I had to ask if I needed to close it afterward. Describe what you want the program you are writing to do, in detail. You can upload your program if it helps, you can also paste error messages and such into the dialog box. Don't get lazy and expect ChatGPT to write a long complicated program. It will do it, but it will have too many errors to deal with. Instead just ask it to help you with the parts you don't understand or know how to do. Keep patient, it will keep track of everything you asked it, and you can just keep refining and testing until you get there.
It will be wrong often. At one point it told me the QP64pe has a command called "Open com" that I could use even though I told it I was using the Mac version. I replied "Open com" isn't available in the Mac version. It said "you're right" then gave me an alternative.
It will usually give you the whole code block. But the more time you spend refining it, the more it will want to give you just the sections that changed, and the more it will give you multiple choices on how to solve and test it. It can get overwhelming. You can slow it down by saying "tell me more about choice 3", or "show me the whole program". If you sign up (even for free) it will remember your sessions. You can go back later and continue or even change questions. If you want it to process things like images, you will quickly need to go to a paid version. That kind of processing is intensive. I did use it once to make an icon for my program.
This is getting long, but one last example. I am using a lot of downloaded subtitles. Basically TXT files with an SRT extension. But I don't want text for the hearing impaired (SDH), or color or font changes. SDH usually uses [ for captions, and { for font commands. I have software that can clean up these files, but if I have 100 files I may only need to clean a few. But which ones? So (abbreviated) here's what happened with ChatGPT:
"I am using a Mac m2 pro running Sequoia 15.5. I want to highlight a group of text files in finder, then right-click on them to run a service called 'SRT Pre-scan'. I want a script to search those files for any of the following characters [{< and un-highlight any files that don't contain them"
ChatGPT wrote the script, and showed me how to build it in Automator, install it, and give it permissions. I tested the script. I highlighted a bunch of files, right-clicked and chose 'SRT Pre-Scan', and it un-highlighted the files that did not contain those characters. It left the other files highlighted, so I could just drag them onto my cleaning program. I realized that I might choose some non-SRT files by accident, so I told ChatGPT:
"That worked but I want it to ignore and de-select any files that aren't .srt or .txt"
It gave me the new code, which worked. Several days later I noticed that if I selected a group of files and clicked "SRT Pre-Scan", if all of the files contained those characters then then proper output from the script would look like nothing had happened. So I went back to ChatGPT and said:
"When I run this script, if all of the files or none of the files contain the characters I'm searching for, I want a pop-up box to tell me that"
And ChatGPT fixed it for me.
I realize that last example has nothing to do with QB64pe, but it shows what ChatGPT can be like, and can easily be applied to QB64pe. I love QB64pe, but I also realize how much more I can do with it by combining it with other methods.

