Where is windows.pbi ?

Just starting out? Need help? Post your questions and find answers here.
Randy Walker
Addict
Addict
Posts: 1060
Joined: Sun Jul 25, 2004 4:21 pm
Location: USoA

Where is windows.pbi ?

Post 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
- - - - - - - - - - - - - - - -
Randy
I *never* claimed to be a programmer.
User avatar
Bisonte
Addict
Addict
Posts: 1313
Joined: Tue Oct 09, 2007 2:15 am

Re: Where is windows.pbi ?

Post by Bisonte »

Really ?

You ask an AI to write a source ? ...

These LLM's are not trained with purebasic codes :mrgreen:

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.
PureBasic 6.21 (Windows x64) | Windows 11 Pro | AsRock B850 Steel Legend Wifi | R7 9800x3D | 64GB RAM | RTX 5080 | ThermaltakeView 270 TG ARGB | build by vannicom​​
English is not my native language... (I often use DeepL.)
BarryG
Addict
Addict
Posts: 4173
Joined: Thu Apr 18, 2019 8:17 am

Re: Where is windows.pbi ?

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

Image

Image
Little John
Addict
Addict
Posts: 4789
Joined: Thu Jun 07, 2007 3:25 pm
Location: Berlin, Germany

Re: Where is windows.pbi ?

Post 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.
infratec
Always Here
Always Here
Posts: 7616
Joined: Sun Sep 07, 2008 12:45 pm
Location: Germany

Re: Where is windows.pbi ?

Post by infratec »

Why you don't asked Meta :?: :?: :?:

Only the programmer knows what he has done.
User avatar
spikey
Enthusiast
Enthusiast
Posts: 769
Joined: Wed Sep 22, 2010 1:17 pm
Location: United Kingdom

Re: Where is windows.pbi ?

Post 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
dige
Addict
Addict
Posts: 1405
Joined: Wed Apr 30, 2003 8:15 am
Location: Germany
Contact:

Re: Where is windows.pbi ?

Post 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.
"Daddy, I'll run faster, then it is not so far..."
Randy Walker
Addict
Addict
Posts: 1060
Joined: Sun Jul 25, 2004 4:21 pm
Location: USoA

Re: Where is windows.pbi ?

Post 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 :mrgreen:

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.
- - - - - - - - - - - - - - - -
Randy
I *never* claimed to be a programmer.
Randy Walker
Addict
Addict
Posts: 1060
Joined: Sun Jul 25, 2004 4:21 pm
Location: USoA

Re: Where is windows.pbi ?

Post by Randy Walker »

WOW spikey!!! Hellofva reply, with all the insight and solution that works great to boot.
THANKS!!!!
- - - - - - - - - - - - - - - -
Randy
I *never* claimed to be a programmer.
Randy Walker
Addict
Addict
Posts: 1060
Joined: Sun Jul 25, 2004 4:21 pm
Location: USoA

Re: Where is windows.pbi ?

Post 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.
- - - - - - - - - - - - - - - -
Randy
I *never* claimed to be a programmer.
Post Reply