difference between a command, constant, structure Interface?
-
- New User
- Posts: 9
- Joined: Fri Aug 28, 2009 12:35 am
- Location: PA>USA
difference between a command, constant, structure Interface?
I have read over the documentation a hundred times and also searched the forum and also read Kale's book. Could someone please give me a simple explanation what is the difference between a command, constant, structure, and an interface ? And also how structures and constants relate to the winAPI ? I know this might be very simple for some but I could not find any simple explanations on each of these.
- Kaeru Gaman
- Addict
- Posts: 4826
- Joined: Sun Mar 19, 2006 1:57 pm
- Location: Germany
Re: Simple Explanation
interesting, I never realized such basic knowledge isn't explained anywhere...
a #Constant is a placeholder for a single Value, it will be replaced by a literal value while compiling.
a Structure is a complex Type, put together by several single types.
it is the same as a RecordSet in older languages.
In fact it's a descriptive set of offsets.
a Command is an Instruction.
in fact only the Basic Keywords* are Commands, but often built-in library functions are also called commands.
* 3rd paragraph on the left: http://www.purebasic.com/documentation/index.html
... and about Interface ... thats complicated.
a #Constant is a placeholder for a single Value, it will be replaced by a literal value while compiling.
a Structure is a complex Type, put together by several single types.
it is the same as a RecordSet in older languages.
In fact it's a descriptive set of offsets.
a Command is an Instruction.
in fact only the Basic Keywords* are Commands, but often built-in library functions are also called commands.
* 3rd paragraph on the left: http://www.purebasic.com/documentation/index.html
... and about Interface ... thats complicated.

oh... and have a nice day.
Re: Simple Explanation
You obviously haven't read any of the above then. :roll:TheCorruptor wrote:I have read over the documentation a hundred times and also searched the forum and also read Kale's book. Could someone please give me a simple explanation what is the difference between a command, constant, structure, and an interface ? And also how structures and constants relate to the winAPI ? I know this might be very simple for some but I could not find any simple explanations on each of these.
-
- New User
- Posts: 9
- Joined: Fri Aug 28, 2009 12:35 am
- Location: PA>USA
Re: difference between a command, constant, structure Interface?
Thank you Kaeru Gaman for your explanation. After reading Kales comment :roll: ( wich I know somebody was going to say I didnt read something or other). I was hoping a simple explantation would answer my question . Let me clarify my question. Yes I do understand the basics of a command - do something, a constant - a name or value that doesnt change that can be referenced at anytime (#DAYS_IN_THE_YEAR = "365"), structure - a place holder for multiple variables. I am sorry if my question was too general. As for structures the documentation shows how to make a structure. This is where I should of explained my question a little better. If you open up the structure viewer in the IDE what are these structures? Is there more info on these besides double clicking on them ? How are they used ? Also the constants and interfaces in the structure viewer also ? I know all this may be very simple for a lot of you but I am just a noob looking to learn from a lot of you more experienced so be easy on me. 

- Kaeru Gaman
- Addict
- Posts: 4826
- Joined: Sun Mar 19, 2006 1:57 pm
- Location: Germany
Re: difference between a command, constant, structure Interface?
please use the ENTER key more often. was hard to read your post. 
the predefined Structures are used by functions - PB-Native or API.
e.g. the POINT structure is used by Win-API functions that need Screen-, Desktop- oder Window-Coordinates.
a lot of Data used for "everyday" handling is organized in Structures.
e.g. an Image is a Structure, first carrying a Header with format informations and then kinda BLOB with the image bitmap.

the predefined Structures are used by functions - PB-Native or API.
e.g. the POINT structure is used by Win-API functions that need Screen-, Desktop- oder Window-Coordinates.
a lot of Data used for "everyday" handling is organized in Structures.
e.g. an Image is a Structure, first carrying a Header with format informations and then kinda BLOB with the image bitmap.
oh... and have a nice day.
- netmaestro
- PureBasic Bullfrog
- Posts: 8451
- Joined: Wed Jul 06, 2005 5:42 am
- Location: Fort Nelson, BC, Canada
Re: difference between a command, constant, structure Interface?
Here's a tiny tutorial on what a structure is and how it can be used:
Code: Select all
; Structures
;
; A structure is a template. Similar to a floorplan, it describes the size, shape and layout of a set of data.
; In and of itself, it consumes no memory and contains nothing tangible. It is a blueprint only.
;
; Once a variable is initialized with a structure, each individual part of the variable can be
; accessed by referring to the structure members.
;
; A simple example:
;
;Structure POINTS ; This is a predefined structure present in PureBasic.
; x.w ; It describes 4 bytes of memory in the form of two WORD variables.
; y.w
;EndStructure
;
; Let's say we have a LONG variable, and we are told that its lo-word contains something usable,
; and so does the hi-word. We have to access them individually.
;
; EXAMPLE: WM_LBUTTONDOWN
;
; This is a message we get from Windows when the user presses the left mouse button somewhere in
; the area of our window. But where?
;
; MSDN says:
;
; lParam
; The low-order word specifies the x-coordinate of the cursor. The coordinate is relative to the upper-left corner of the client area.
; The high-order word specifies the y-coordinate of the cursor. The coordinate is relative to the upper-left corner of the client area.
;
; We could get at the individual WORD vars using bit masking and shifting, but the POINTS structure is ideal for this.
;
; lParam contains a LONG variable that our program can read. It is memory already allocated and filled. We just need to
; describe its shape and size to access its component parts easily. We'll use the POINTS structure for this:
;
OpenWindow(0,0,0,640,480,"Structure usage demo: Make some LeftButton mouse clicks...",#PB_Window_SystemMenu|#PB_Window_ScreenCentered)
Repeat
EventID = WaitWindowEvent()
Select EventID
Case #WM_LBUTTONDOWN
this_lParam = EventlParam() ; Make a copy of lParam
*lparam.POINTS = @this_lParam ; Lay our POINTS template over it using a pointer structured as POINTS
x = *lparam\x ; Now we can access each component using a descriptive name
y = *lparam\y
Debug "x="+Str(x)+", y="+Str(y)
EndSelect
Until EventID = #PB_Event_CloseWindow
;
; This is much preferable to writing hard-to-read code like:
; x = EventlParam()&$FFFF
; y = EventlParam()>>16
BERESHEIT