Welcome, Guest. Please login or register.

Author Topic: Hello, World!  (Read 3862 times)

Offline TI-994A

  • Sr. Member
  • ***
  • Posts: 242
  • You can do it in BASIC!
    • View Profile
Hello, World!
« on: September 12, 2014, 02:52:46 PM »
PureBasic's version of the traditional Hello, World! program, displayed within a window, with just one line of code:

Code: [Select]
MessageRequester("PureBasic", "Hello, World!")
Texas Instruments 99/4A Home Computer: the first home computer with a 16bit processor, crammed into an 8bit architecture. Great hardware - Poor design - Wonderful BASIC engine. And it could talk too!

Offline TI-994A

  • Sr. Member
  • ***
  • Posts: 242
  • You can do it in BASIC!
    • View Profile
Re: Hello, World!
« Reply #1 on: November 17, 2015, 01:09:08 AM »
The message requester is actualy not a window but a specific dialog not a window.

Wrong; as usual::)

Quote from: MSDN - Windows Dev Center
A dialog box is a temporary window an application creates to retrieve user input.

Windows Programming 101.  ;D
Texas Instruments 99/4A Home Computer: the first home computer with a 16bit processor, crammed into an 8bit architecture. Great hardware - Poor design - Wonderful BASIC engine. And it could talk too!

Offline blueb

  • Jr. Member
  • *
  • Posts: 6
    • View Profile
Re: Hello, World!
« Reply #2 on: November 18, 2015, 09:28:39 AM »
 :)

Offline blueb

  • Jr. Member
  • *
  • Posts: 6
    • View Profile
Re: Hello, World!
« Reply #3 on: November 18, 2015, 09:53:16 AM »
Here's an cut-down (80 page) Windows Tutorial. Found it some where on the net a long time ago.

I know you've had some questions about 'Windows Messages"

Here's an excerpt...

Quote
Message Loop
Once the window is created, the window will interact with the rest of the system by way of messages. The system
sends messages to the window, and the window sends messages back. Most programs in fact don't do anything but
read messages and respond to them!
Messages come in the form of an MSG data type. This data object is passed to the GetMessage() function, which
reads a message from the message queue, or waits for a new message from the system. Next, the message is sent to
the TranslateMessage function, which takes care of some simple tasks such as translating to Unicode or not. Finally,
the message is sent to the window for processing using the DispatchMessage function.

I've added it as an attachment.

--blueb


Offline TI-994A

  • Sr. Member
  • ***
  • Posts: 242
  • You can do it in BASIC!
    • View Profile
Re: Hello, World!
« Reply #4 on: November 18, 2015, 11:14:13 AM »
Quote
Once that's done we pass the message to DispatchMessage(). What DispatchMessage() does is take the message, checks which window it is for and then looks up the Window Procedure for the window. It then calls that procedure, sending as parameters the handle of the window, the message, and wParam and lParam.
I am simply trying to follow that tutorial. get my message with waitwindowevent() then send it to the correct window event handler. Nothing else.

Hope this makes it a little clearer.

Yes it does. You're trying to apply C/C++ code rules to PureBasic.  ::)
Texas Instruments 99/4A Home Computer: the first home computer with a 16bit processor, crammed into an 8bit architecture. Great hardware - Poor design - Wonderful BASIC engine. And it could talk too!

Offline TI-994A

  • Sr. Member
  • ***
  • Posts: 242
  • You can do it in BASIC!
    • View Profile
Re: Hello, World!
« Reply #5 on: November 18, 2015, 12:06:56 PM »
Not really it is the way windows seems to work.

Yes, it is. But it's not the way PureBasic handles it's event loop.

How, pray tell, would you implement the Windows' DefWindowProc() function in your PureBasic program?

This should be good.  ;D
Texas Instruments 99/4A Home Computer: the first home computer with a 16bit processor, crammed into an 8bit architecture. Great hardware - Poor design - Wonderful BASIC engine. And it could talk too!

Offline TI-994A

  • Sr. Member
  • ***
  • Posts: 242
  • You can do it in BASIC!
    • View Profile
Re: Hello, World!
« Reply #6 on: November 18, 2015, 11:52:41 PM »
Code: [Select]
Procedure DefWindowProc(Event)
  ;Do any default programming here to deal with events not handled by your main code
  ;If you wish
EndProcedure

The event loop in the program here is then handled in the way windows works and is programmed in Pure Basic so Pure Basic is handling it's event loop, and by that, the only event loop we are talking about here is the one in the program, in the way windows works. Of course you can use Pure Basic to program in the way windows does not work as well, i just prefer to program in the way windows works.

That's total gibberish. And your DefWindowProc() procedure is priceless.  ;D
Texas Instruments 99/4A Home Computer: the first home computer with a 16bit processor, crammed into an 8bit architecture. Great hardware - Poor design - Wonderful BASIC engine. And it could talk too!

Offline TI-994A

  • Sr. Member
  • ***
  • Posts: 242
  • You can do it in BASIC!
    • View Profile
Re: Hello, World!
« Reply #7 on: November 19, 2015, 12:45:34 AM »
I also notice you miss off the quote from Microsoft.

Quote
Defwindowproc() Calls the default window procedure to provide default processing for any window messages that an application does not process. This function ensures that every message is processed. DefWindowProc is called with the same parameters received by the window procedure.

I wrote that little humourous snippet at your request as you seem to be unable to understand. ;D

Sadly, it is you that don't understand.  ::)

Microsoft explains the fundamentals of programming their operating system through the C/C++ language.

PureBasic, however, is a higher level language that cloaks and automates most of these fundamentals.

As I've said before, you're reinventing the wheel.

Do you really think that you're building and handling a window simply with one simple OpenWindow() function?
Texas Instruments 99/4A Home Computer: the first home computer with a 16bit processor, crammed into an 8bit architecture. Great hardware - Poor design - Wonderful BASIC engine. And it could talk too!

Offline TI-994A

  • Sr. Member
  • ***
  • Posts: 242
  • You can do it in BASIC!
    • View Profile
Texas Instruments 99/4A Home Computer: the first home computer with a 16bit processor, crammed into an 8bit architecture. Great hardware - Poor design - Wonderful BASIC engine. And it could talk too!

Offline TI-994A

  • Sr. Member
  • ***
  • Posts: 242
  • You can do it in BASIC!
    • View Profile
Re: Hello, World!
« Reply #9 on: November 22, 2015, 11:41:53 AM »
It appears that collectordave has looted the forum of his posts.



Unprecendented!  ;D
Texas Instruments 99/4A Home Computer: the first home computer with a 16bit processor, crammed into an 8bit architecture. Great hardware - Poor design - Wonderful BASIC engine. And it could talk too!