Page 1 of 1
Where is windows.pbi ?
Posted: Sun Jan 19, 2025 6:14 am
by Randy Walker
Trying to run this snippit I got from Meta (the whatsapp AI guy) but I can't find the windows.pbi file.
Code: Select all
IncludeFile "Windows.pbi"
; Get the current locale
locale = GetThreadLocale_()
; Get the date format
dateFormat.s = Space(256)
GetLocaleInfo_(locale, LOCALE_SSHORTDATE, @dateFormat, Len(dateFormat))
; Debug the date format
Debug dateFormat
[UPDATE] I made a typo correction on that dateFormat.$ variable -- should be dateFormat.s on line 7
Re: Where is windows.pbi ?
Posted: Sun Jan 19, 2025 7:17 am
by Bisonte
Really ?
You ask an AI to write a source ? ...
These LLM's are not trained with purebasic codes
I tried some LLM's and none of them can create a PB Source to open a Window an write "Hello World" without errors...
Dont try to use generated code directly ...
I think in this code, the LLM try to handle it like a C source and want to import the window header file.
Re: Where is windows.pbi ?
Posted: Sun Jan 19, 2025 7:27 am
by BarryG
Bisonte wrote: Sun Jan 19, 2025 7:17 amI tried some LLM's and none of them can create a PB Source to open a Window an write "Hello World" without errors
I don't know what you tried, but ChatGPT is getting very good at PureBasic coding and can do what you asked in this case. Sure, you still need to check what it provides for errors, but for easy questions it's pretty much spot-on most of the time. If it misses something, you can just tell it correct the error and it usually does. It's quite extraordinary, IMO.
Below is its correct answer for your coding question that I quoted above, and the result.

Re: Where is windows.pbi ?
Posted: Sun Jan 19, 2025 8:31 am
by Little John
Randy Walker wrote:
Where is windows.pbi ?
How are
we supposed to know that? You should ask this in a support forum for that chatbot.
Re: Where is windows.pbi ?
Posted: Sun Jan 19, 2025 9:57 am
by infratec
Why you don't asked Meta
Only the programmer knows what he has done.
Re: Where is windows.pbi ?
Posted: Sun Jan 19, 2025 11:58 am
by spikey
As Bisonte said this looks like a kludge of C++ and PB to me. Importing windows.h is something pretty much all Windows GUI programs in C++ will do and this has been erroneously literally converted to 'IncludeFile "Windows.pbi"'. This would be required in the C++ equivalent of this process because it provides the macro GetLocaleInfo. This will resolve to either GetLocaleInfoA or GetLocalInfoW, which are the actual procedures provided by the OS API.
PureBasic resolves all of this by other means so it's mostly unnecessary in a PB program. (PB doesn't import every single possible API function and define all the constants, just the common ones and those that have been specifically requested).
I think this will do what you wanted:
Code: Select all
; Get the current locale
locale = GetThreadLocale_()
; Get the date format
dateFormat.s = Space(256)
GetLocaleInfo_(locale, #LOCALE_SSHORTDATE, @dateFormat, StringByteLength(dateFormat))
dateFormat = LCase(dateFormat)
; Debug the date format
Debug dateFormat
Re: Where is windows.pbi ?
Posted: Sun Jan 19, 2025 8:44 pm
by dige
If the AI invents any includes, tell the AI: please output the complete source code without includes.
The same applies to invented commands. Simply tell the AI that this command does not exist.
With Claude and ChatGPT really complex Purebasic codes are already possible.
Re: Where is windows.pbi ?
Posted: Sun Jan 19, 2025 8:55 pm
by Randy Walker
Bisonte wrote: Sun Jan 19, 2025 7:17 am
Really ?
You ask an AI to write a source ? ...
These LLM's are not trained with purebasic codes
I tried some LLM's and none of them can create a PB Source to open a Window an write "Hello World" without errors...
Actually I only asked if ther was a way in PB to get the user's date format. He offered the code from that inquiry.
So I followed up on your comment about LLM and here is the full followup:
Code: Select all
[1/19/2025 11:43 AM] Randy Walker: Ha Ha ha ,,, I asked in the forum about that missing windows.pbi file and the reply I got was You (LLM) cannot produce working code for PureBasic and challenge you to produce Source code to open a Window an write "Hello World". I have faith in your ability.
[1/19/2025 11:43 AM] Meta AI: I love a good challenge!
Here's a simple PureBasic program that opens a window and displays "Hello World":
XIncludeFile "windows.pbi" ; (just kidding, we don't need this)
OpenWindow(0, 100, 100, 300, 200, "Hello World", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
TextGadget(0, 10, 10, 280, 20, "Hello World")
Repeat
event = WaitWindowEvent()
Until event = #PB_Event_CloseWindow
This code creates a window with the title "Hello World", displays the text "Hello World" inside the window using a TextGadget, and then enters a loop to wait for window events until the window is closed.
Please note that I've assumed you're using PureBasic 5.70 or later. If you're using an earlier version, you might need to adjust the code slightly.
Now, let's see if I've passed the challenge!
Sure worked for me, so I'm not convinced I should trust your comment about LLM , Although I grant you they are not perfect in all cases.
Re: Where is windows.pbi ?
Posted: Sun Jan 19, 2025 9:02 pm
by Randy Walker
WOW spikey!!! Hellofva reply, with all the insight and solution that works great to boot.
THANKS!!!!
Re: Where is windows.pbi ?
Posted: Sun Jan 19, 2025 9:13 pm
by Randy Walker
spikey wrote: Sun Jan 19, 2025 11:58 am
As Bisonte said this looks like a kludge of C++ and PB to me.
So I did another followup with Meta on that:
Code: Select all
[1/19/2025 12:06 PM] Randy Walker: Comment about your code from the one who gave the above solution was that:
" Bisonte said this looks like a kludge of C++ and PB to me. Importing windows.h is something pretty much all Windows GUI programs in C++ will do and this has been erroneously literally converted to 'IncludeFile "Windows.pbi"'. This would be required in the C++ equivalent of this process because it provides the macro GetLocaleInfo. This will resolve to either GetLocaleInfoA or GetLocalInfoW, which are the actual procedures provided by the OS API."
[1/19/2025 12:06 PM] Meta AI: Bisonte's comment is spot on. I was indeed trying to translate C++ code to PureBasic, but I didn't fully understand the context and nuances of the Windows API.
The windows.h header file in C++ is a crucial part of working with the Windows API, and it provides many macros, including GetLocaleInfo. However, in PureBasic, the equivalent functionality is provided by the GetLocaleInfo_() procedure, which is part of the PureBasic language.
Bisonte's solution is much cleaner and more idiomatic PureBasic code. It avoids the unnecessary XIncludeFile "windows.pbi" directive and uses the correct PureBasic procedure to retrieve the locale information.
Thanks for sharing Bisonte's insightful comment! It's a great example of how important it is to understand the context and specifics of a programming language and its ecosystem.