Page 1 of 1
Posted: Wed Jun 05, 2002 12:08 pm
by BackupUser
Restored from previous forum. Originally posted by Justin.
Hello, i'm new to PureBasic, i know how to program the windows api in other languages. How it is done in pb?, just typing the function name?, i have not seen anything in the help files, thanks.
Posted: Wed Jun 05, 2002 12:16 pm
by BackupUser
Restored from previous forum. Originally posted by WolfgangS.
Try this:
beep_(1000,1000)
And try to get a API viewer from here:
http://www.reelmediaproductions.com/pb/ and click the Editor Resources.
cu
WolfgangS
Posted: Wed Jun 05, 2002 2:59 pm
by BackupUser
Restored from previous forum. Originally posted by Justin.
i have not downloaded the program yet but i figured out that you have to add '_' at the end of the function and '#' at the beginning of the api constant.
thank you.
Posted: Wed Jun 05, 2002 3:56 pm
by BackupUser
Restored from previous forum. Originally posted by Franco.
Hi Justin,
'#' at the beginning of a name is for constants in general, not only API constants.
If you need selfmade constants in your app just write:
#MyOwnConstant=700
A constant can be every type you want (look under Variables and Types in the manual) even a string just use:
#MyOwnConstant.s="That's me"
or
#MyOwnConstant$="That's me"
BTW: Just looked at the manual and didn't find any sentence about '#' and 'constants'.
Fred can you add constants to the manual for 3.2
Maybe under 'Constants, Variables and Types'
Have a nice day...
Franco
Sometimes you have to go a lonely way to accomplish genius things.
Posted: Wed Jun 05, 2002 5:48 pm
by BackupUser
Restored from previous forum. Originally posted by Pupil.
A constant can be every type you want (look under Variables and Types in the manual) even a string just use:
#MyOwnConstant.s="That's me"
or
#MyOwnConstant$="That's me"
You don't really have to use '.s' or $ when dealing with constants it all works perfectly without them i.e:
#Constant = "no .s or $" ; is perfectly legal
BTW: Just looked at the manual and didn't find any sentence about '#' and 'constants'.
You just didn't look at the right place, i've found one sentence (barelly) that tells about constants. It's located under 'General Syntax Rules' in the reference manual. But you're right this issue should have some more space in the manual.
Posted: Wed Jun 05, 2002 7:03 pm
by BackupUser
Restored from previous forum. Originally posted by Justin.
thank you all for clear up things.
i have another question, what is '@'?, 'address of' maybe?
i have not seen it in the help files.
Posted: Wed Jun 05, 2002 7:13 pm
by BackupUser
Restored from previous forum. Originally posted by Danilo.
Yes.
See PureBasic Help:
Reference Manual \ Various topics \ Pointers and Memory access
cya,
...Danilo
(registered PureBasic user)
Posted: Wed Jun 05, 2002 8:42 pm
by BackupUser
Restored from previous forum. Originally posted by Franco.
You just didn't look at the right place, i've found one sentence (barelly) that tells about constants. It's located under 'General Syntax Rules' in the reference manual.
You are right Pupil, I missed:
- All constants are preceded by #
Example :
#Hello = 10 is a constant.
Hello = 10 is a variable.
It's not much, but it's there
Have a nice day...
Franco
Sometimes you have to go a lonely way to accomplish genius things.
Posted: Wed Jun 05, 2002 9:36 pm
by BackupUser
Restored from previous forum. Originally posted by PB.
> i know how to program the windows api in other languages.
> How it is done in pb?
When using the API in PureBasic, you don't (normally) need to declare the API
routine and any constants used with it. All API calls must be followed by the
underscore character, and all constants must be prefixed with a hash character.
Here's a quick example of an API call in Visual Basic, and the same code in
PureBasic. This example closes the Windows calculator, if open, on an English
version of Windows.
Code: Select all
' [b]Visual Basic version.[/b]
'
Public Const WM_CLOSE = &H10
'
Public Declare Function FindWindow Lib "user32" Alias _
"FindWindowA" (ByVal lpClassName As String, _
ByVal lpWindowName As String) As Long
'
Public Declare Function PostMessage Lib "user32" Alias _
"PostMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, _
ByVal wParam As Long, lParam As Any) As Long
'
r = FindWindow(0, "Calculator")
If r 0 Then
PostMessage r, WM_CLOSE, 0, 0
End If
Code: Select all
; [b]PureBasic version.[/b]
;
r=FindWindow_(0,"Calculator")
If r0
PostMessage_(r,#WM_CLOSE,0,0)
EndIf
PB - Registered PureBasic Coder
Edited by - PB on 05 June 2002 22:42:45
Posted: Wed Jun 05, 2002 9:51 pm
by BackupUser
Restored from previous forum. Originally posted by Franco.
Code: Select all
; [b]PureBasic version.[/b]
;
r=FindWindow_(0,"Calculator")
If r0
PostMessage_(r,#WM_CLOSE,0,0)
EndIf
PB - Registered PureBasic Coder
Ahh, live can be so easy...
Have a nice day...
Franco
Sometimes you have to go a lonely way to accomplish genius things.