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.
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.