it's amazing and incredible (AI is shocking)

91 views
Skip to first unread message

Grigory Filatov

unread,
Jul 31, 2025, 10:10:15 AMJul 31
to Harbour Minigui
Hi Friends,

Today I wrote a new demo program using the wonderful EasySQL wrapper to work with the MySQL database. I then generated a description of this demo using ChatGPT and fed this detailed explanation to Grok AI. I was shocked when the AI almost completely restored my original code.
Here is a detailed breakdown and explanation of what this example does by ChatGPT.

This demo is written in Harbour, a modern, open-source version of Clipper/xBase language.
It uses HMG (Harbour MiniGUI) and a custom EasySQL wrapper to work with a MySQL database.

Below is a detailed breakdown and explanation of what this example does:

---

🌐 Purpose:

This is a demo program that:

1. Connects to a MySQL database.
2. Checks if tables customers and orders exist. If not, it creates them and inserts test data.
3. Runs a complex SQL query to retrieve top customer purchases per day within a date range.
4. Displays three editable table views: customers, orders, and the final result.

---

🔧 Key Components and Functions:

1. main_create_table_action() — The main procedure

* Connects to MySQL using constants: _MYSQL_SERVER_, _MYSQL_USER_, etc.
* Creates customers and orders tables (if they don’t exist).
* Populates them with sample data.
* Runs three SELECT queries and shows the results using EDIT EXTENDED TITLE ....
* Disconnects from the DB at the end.

2. IsExistTable( oSql, cTable )

* Executes a query against INFORMATION_SCHEMA.TABLES to check if a table exists.
* Compares the found table name with the expected one (case-insensitively).
* Returns .T. if it exists, otherwise .F..

3. cCreateQuery() / cCreateQuery2()

* Return SQL string for creating the customers and orders tables.

4. cAddQuery() / cAddQuery2()

* Return SQL string for inserting hardcoded records into customers and orders.

5. cGetQuery()

* Returns the final SQL query used to find:

  * The customers who made the highest total daily purchase between '2019-02-01' and '2019-05-01'.

✅ Explanation of SQL logic:

* First subquery (daily_totals): Groups all orders per customer per date, sums up total_order_cost.
* Second subquery (max_daily): Gets the maximum daily total cost per day (across all customers).
* Final JOIN: Matches daily totals with the max cost to get the customers who achieved that max.
* Joined with customers to get the first_name.

---

🖥 UI & Display Logic

* Uses EDIT EXTENDED TITLE ... with FIELDENABLED aEdit to show data in a GUI window.
* aEdit := Array( FCount() ) with AFill( aEdit, .F. ) disables field editing (read-only view).

---

✅ Summary

| Component                    | Purpose                                        |
| ---------------------------- | ---------------------------------------------- |
| SQL():New()                  | Creates a new database connection object       |
| IsExistTable                 | Checks if a table exists in the current schema |
| cCreateQuery / cAddQuery     | Define schema and insert data for customers    |
| cCreateQuery2 / cAddQuery2   | Define schema and insert data for orders       |
| cGetQuery                    | Core logic: find top customers per day         |
| EDIT EXTENDED                | Shows GUI table-like views of the data         |

---

💡 Notes:

* This is a great educational demo on SQL + Harbour integration.

---

I have also attached the code recovered using Grok for your review.

I have no words. ;-)))

Thank you for your attention.

Kind regards,
Grigory
demo.prg

Anand Gupta

unread,
Jul 31, 2025, 11:37:28 AMJul 31
to Grigory Filatov, Harbour Minigui
WOW!!

Are we really going to be obsolete now ?
I mean 'old coders like me'

--
Visit our website on https://www.hmgextended.com/ or https://www.hmgextended.org/
---
You received this message because you are subscribed to the Google Groups "Harbour Minigui" group.
To unsubscribe from this group and stop receiving emails from it, send an email to minigui-foru...@googlegroups.com.
To view this discussion, visit https://groups.google.com/d/msgid/minigui-forum/8eee49e1-42b7-460a-9270-c630bf33977fn%40googlegroups.com.

juanpere...@gmail.com

unread,
Jul 31, 2025, 12:21:04 PMJul 31
to Harbour Minigui
Hello
Grigory

Interesting example. A question to compile the demo: is the pro version required or is the basic version sufficient?

Regards
Juan

priadi andika

unread,
Jul 31, 2025, 1:49:45 PMJul 31
to juanpere...@gmail.com, Harbour Minigui
Dear Grigory

Please give me information versi mysql server and how to install and connect with harbour minigui extended in demo file

Thanks
Br 
Spd

Grigory Filatov

unread,
Jul 31, 2025, 1:58:56 PMJul 31
to Harbour Minigui
Hello Juan,

Thanks for your feedback!

The standard build is enough with adding easy_sql library to your link script.

Please note that this restored source code is almost complete, but the original code is different and contains connection settings and GUI parts.

Kind regards,
Grigory

четверг, 31 июля 2025 г. в 18:21:04 UTC+2, juanpere...@gmail.com:
Message has been deleted

José Quintas

unread,
Jul 31, 2025, 8:52:57 PMJul 31
to Harbour Minigui
Some MySQL stored functions to show value as text.
Maybe some users begans to understand that a SQL database is more than to use DBF.
Converted to english using AI.
AI changes text, variable name, function name, without to lost code.

José M. C. Quintas

Em quinta-feira, 31 de julho de 2025 às 15:33:56 UTC-3, Nelson Radford escreveu:
D
ze_numbertowordsfull.sql
ze_numbertowordsunits.sql
ze_numbertowordscurrency.sql
ze_numbertowordstens.sql
ze_numbertowordshundreds.sql
Reply all
Reply to author
Forward
0 new messages