qr-code -text-subject

So I tested GPT-4o by creating a script in Python. I haven't used Python that much; almost none at all, but my thought was that OpenAi likes(it's very proficient) in python, and I wanted it to be able to run it on most platforms. In my case Windows and Linux.

 

I was actually just playing around with Affinity when I saw that there was an update (2.5), and one of the things that Affinity could do was create all kinds of QR-codes. I thought it was pretty nice(neat, kind of cool), because I did not know that there were that many types of QR-codes. Like "sms", "email" and so on. I thought there was only one which was "text". So anyway, i thought that making a script that does the same but without having to have to open Affinity would be nice. And I could create the QR-code fast. And even create batch-wise if needed.

My first query was straight to the point and it gave me exactly what I wanted:

#python, library segno
create a script that reads a string-A and string-B from the commandline and creates a qr-code using the string-A. 
It should save the qr code as a pdf, where the name of the file is string-B

It did exactly what it was supposed to do. I then expanded the functionality by telling the AI the following:

#python, using library segno
Based on the first script that you gave me earlier (it's at the bottom of this message), let's add more functionality. The script should take 3 parameters:
Parameter 1: tells us what type of qr-code-data: either url, email or text. Check if the user-text given is correct.
Parameter 2: the data to encode. If it's a url, check to see if "http" or "https" is given; if not add i to the string. If param1 is email, param2 should be in the following format "<email-adresse><subject><body>"
Parameter 3: filename to save to (pdf)

It did not understand what I wanted regarding the email-format, so I had to elaborate more on that one:

#python, using library segno
Maybe i did not make it clear: if parameter 1 is "email" parameter 2 should have the data enclosed in <>. An example of this is <This email address is being protected from spambots. You need JavaScript enabled to view it.><my email subject><my emails body>. When you create the qr-code use that data to create the email-qr-code

The next was to add more data:

2024-06-01 18:47:08: #python, using library segno
can you add 2 more data-types: "sms" and "call" into the script.
The sms dataformat in Parameter 2 should be: <users phone-numrer><users text-message>
The call dataformat in Parameter 2 should be "phone number".

I added some help functions (parameters in Linux fashion):

#using python
I'd like to change how the parameters are inputed on the command line. i.e. I'd like the commandline parameters to be in Linux-style using "-" before the parameter-name. Can you create/change my script so it fits the following:

-h or -help - prints out how to use this application
-t or -type - takes one string: in this application it can be either "url", "email", "sms","call", "text". In my script this corresponds to the vcariable "data_type"
-d or -data - corresponds to the variable "data" in the script.
-o or -output - name of filename. Default extension is png, If '-f' is not given 
-f or -format - format/extension of filename. This can be either "png" og "pdf"

And of course the script it created was flawless. The only "problem" I got at one point was that my phone's QR-code scanner did not recognize the QR-code created when using the "call" parameter. I thought there was something wrong with the code, but I read through some documentation and came to the conclusion that there can be errors in reading the QR-code, so I added error-correction parameter in the code myself. Se below:

qr = segno.make(data, error='H')  # Increase error-correction level for better reliability

It's the highest realiability.

Conclusion: To be honest; without using OpenAi I would of used many days to create this, since I'm far from fluent in Python (programing) in general. But ofcourse it helps to have a background in programing, to know what you want and how you should get it so that your descriptions to the AI is directly to the point and has the information it needs to create what you want. There's probably more I could do to make it better/safer, but for a couple of hours of work this is more than good. Below is is an example of usage:

Here's some examples of usage:

Example_of_usage
Example of usage with error messages