NO

Author Topic: ChatGPT examples  (Read 15313 times)

Offline WiiLF23

  • Member
  • *
  • Posts: 89
Re: ChatGPT examples
« Reply #30 on: January 06, 2024, 05:25:22 AM »
GPT has practically built a entire P2P Winsock filesharing application (client + server DLL) and it is on steroids! I dont under estimate AI by any means.

The level of checks, overflow protections and much more are beyond my skill set. I have learned a great deal from using GPT. Most of what I've posted (except progress painting) is all AI-generated.

2 months of that, which has basically built the entire application from start to finish is just mind blowing.

Today, I now write a lot of it myself as I have studied every single prompt, with all of the "why" and "how" well utilized over time.

Yes.. GPT can write complete software from the point of a single header line. Thats almost scary.. it has trained me so endless code solutions I cant even begin to explain what it has provided for this compiler and IDE.

I will continue to use it in order to gain insight into C programming, functions and structures. Like I said.. it has developed the entire thing for me just by asking prompts and copying and pasting.

Bloody thing runs @ 1.8MB in memory and it is very optimized and cleans up at all points needed, far more than I could ever expect. Very optimized!

The only thing I question.. are security issues. It does not handle very well at all. Just for those wondering. I will hire an audit for that.


Offline Vortex

  • Member
  • *
  • Posts: 870
    • http://www.vortex.masmcode.com
Re: ChatGPT examples
« Reply #31 on: January 06, 2024, 11:20:36 AM »
Hi WiiLF23,

Chat GPT is probably more successfull with high level languages at least for today :

Quote
I will continue to use it in order to gain insight into C programming, functions and structures. Like I said.. it has developed the entire thing for me just by asking prompts and copying and pasting.

I agree with you.
Code it... That's all...

Offline MrBcx

  • Global Moderator
  • Member
  • *****
  • Posts: 195
    • Bcx Basic to C/C++ Translator
Re: ChatGPT examples
« Reply #32 on: January 06, 2024, 04:01:05 PM »
Below are some of the things I now know and use ChatGPT for.

My initial prompts for code generation often specifies "plain c", "Win32 API", and "Windows 10".
Depending on what I'm doing, I'll also specify specific WinAPI libraries to be used, such as GDI or GDI+

ChatGPT ( https://chat.openai.com/  ) gives us 1500 chars for "Custom Instructions" which
can accomplish magic.  Because a lot of what I do involves BCX BASIC, the following are the
custom instruction I have stored under ChatGPT's Settings.

Code: [Select]
I developed BCX BASIC and code in  C17 and Win32API on Windows. 
You will help me solve coding problems. When providing BCX source code,
always convert parenthesis to square brackets when they refer to  arrays. 
All variables and function arguments must be type declared. 
FOR-NEXT loop variables, must be TYPE declared. 
For example:  FOR LONG  i =  1  to 10 STEP 2 ... and so on.  BCX functions
return their function result using "FUNCTION =".  Never use "RETURN" to exit
a function or sub.   
SUB and FUNCTION arguments must be wrapped around parenthesis. 
Variables in BCX must be DIM'ed.  BCX's default datatype is integer, not
SINGLE like other BASIC dialects.  When converting code from other dialects,
always DIM the variables, if one does not exist.
BCX uses "GLOBAL" not "DIM SHARED".
Do not dim and assign in the same statement, keep them separate.
BCX user-defined functions generally follow this format:
FUNCTION DegToRad(Degrees AS DOUBLE) AS DOUBLE
    DIM AS DOUBLE Radians
    Radians = Degrees * 0.01745 )
    FUNCTION = Radians
END FUNCTION
when targeting the Win32 API, BCX works best when you use published
Win32 variable types , such as HDC, HBITMAP, etc, when creating variables.
Do not use the "@" symbol for pointers, use the ADDRESSOF function.
when passing variable pointers to functions, BCX can use the full Win32 API,
just like any Win32 C17 program.

I have gotten back compilable BCX BASIC code from ChatGPT on the first shot about 50% of the time, the rest of the time the generated code usually contains a few minor errors mixed with the occasional hallucination.  Quickly getting a prototype, even a rough one, quickly is tremendously useful. 

I also routinely provide code to ChatGPT and ask it to review, explain, and provide refactoring opportunities.
Bcx Basic to C/C++ Translator
https://www.BcxBasicCoders.com

Offline WiiLF23

  • Member
  • *
  • Posts: 89
Re: ChatGPT examples
« Reply #33 on: January 06, 2024, 08:21:39 PM »
Below are some of the things I now know and use ChatGPT for.

My initial prompts for code generation often specifies "plain c", "Win32 API", and "Windows 10".
Depending on what I'm doing, I'll also specify specific WinAPI libraries to be used, such as GDI or GDI+

ChatGPT ( https://chat.openai.com/  ) gives us 1500 chars for "Custom Instructions" which
can accomplish magic.  Because a lot of what I do involves BCX BASIC, the following are the
custom instruction I have stored under ChatGPT's Settings.

Code: [Select]
I developed BCX BASIC and code in  C17 and Win32API on Windows. 
You will help me solve coding problems. When providing BCX source code,
always convert parenthesis to square brackets when they refer to  arrays. 
All variables and function arguments must be type declared. 
FOR-NEXT loop variables, must be TYPE declared. 
For example:  FOR LONG  i =  1  to 10 STEP 2 ... and so on.  BCX functions
return their function result using "FUNCTION =".  Never use "RETURN" to exit
a function or sub.   
SUB and FUNCTION arguments must be wrapped around parenthesis. 
Variables in BCX must be DIM'ed.  BCX's default datatype is integer, not
SINGLE like other BASIC dialects.  When converting code from other dialects,
always DIM the variables, if one does not exist.
BCX uses "GLOBAL" not "DIM SHARED".
Do not dim and assign in the same statement, keep them separate.
BCX user-defined functions generally follow this format:
FUNCTION DegToRad(Degrees AS DOUBLE) AS DOUBLE
    DIM AS DOUBLE Radians
    Radians = Degrees * 0.01745 )
    FUNCTION = Radians
END FUNCTION
when targeting the Win32 API, BCX works best when you use published
Win32 variable types , such as HDC, HBITMAP, etc, when creating variables.
Do not use the "@" symbol for pointers, use the ADDRESSOF function.
when passing variable pointers to functions, BCX can use the full Win32 API,
just like any Win32 C17 program.

I have gotten back compilable BCX BASIC code from ChatGPT on the first shot about 50% of the time, the rest of the time the generated code usually contains a few minor errors mixed with the occasional hallucination.  Quickly getting a prototype, even a rough one, quickly is tremendously useful. 

I also routinely provide code to ChatGPT and ask it to review, explain, and provide refactoring opportunities.

That is great to hear! I have become wise to its hallucinations and dummy responses. In that case, you reset the entire session by opening a new chat. I do this quite aggressively to keep the inquiry relevant and not pull up old history that alters its responses further. You have to catch that quickly, but it is beyond rewarding.

I use stricly

"For Pelles C, show me how to <your desire>"

Or for code assessment:

"In Pelles C, I have <code description>, and I need to <your desire>"

I find when you mention "Show me in pure C" it just brings up Linux-intended code. Sure, thats great if you are setup for cross-development but I am not so it is fluff to me. I keep it on topic for Pelles C, so it already comprehends the headers in use and general expectations.

Side note:

GPT easily understands subclassing, it sucks at painting unless you really dumb it down step by step (like the MessageBar topic I posted, all AI generated). When it comes to painting, it really lacks in that area.
« Last Edit: January 06, 2024, 08:24:51 PM by WiiLF23 »

Offline John Z

  • Member
  • *
  • Posts: 865
Re: ChatGPT examples
« Reply #34 on: January 07, 2024, 09:44:51 PM »
Hi WiiLF23,

At some point I am forced to produce a custom TreeView control as this is the heart of my application. Not at all easy to do. Source code is on github so maybe it is possible. I need node padding, custom color highlighting, and gradient effects.

So will you give ChatGPT the task of creating the subclassed treeview with the ability to independently set/control all visual elements of the treeview display?  Might it be better and/or more complete than GitHub?  Beyond me, I've used Bard exactly once so I'm well behind in this tool.

John Z

P.S. what is 'node padding' ?

Offline WiiLF23

  • Member
  • *
  • Posts: 89
Re: ChatGPT examples
« Reply #35 on: January 11, 2024, 07:21:43 PM »
Hi WiiLF23,

At some point I am forced to produce a custom TreeView control as this is the heart of my application. Not at all easy to do. Source code is on github so maybe it is possible. I need node padding, custom color highlighting, and gradient effects.

So will you give ChatGPT the task of creating the subclassed treeview with the ability to independently set/control all visual elements of the treeview display?  Might it be better and/or more complete than GitHub?  Beyond me, I've used Bard exactly once so I'm well behind in this tool.

John Z

P.S. what is 'node padding' ?

In reality, its subclassing really anything and following the paint events and messages specific to that control. I've realized how to do this to all elements of a ListView (background, alternating rows, header columns) and works fine. I also did a full custom paint for tabs as well. I dont see why this is not possible for TreeView without any help from AI. I just needed to know the event message macros and go from there, AI was helpful for that.

At this point, and how seamless styling each control is I have practically written a UI framework lol the amount of drawing and paint procedures deserve a DLL and entry point functions pointed at a controls handle.

This will let me wrap and style anything from the UI framework DLL and move all of the drawing to the DLL and out of the main application.

"node padding" just means row spacing for each full-row selected node in the treeview control. VS has margins and padding, so usually its known by referring back to that. In pelles C, its all manual.
« Last Edit: January 11, 2024, 07:23:33 PM by WiiLF23 »