Page 1 of 1
Where I can get documentation
Posted: Wed Jan 04, 2006 12:15 am
by chen
Hi,
Sorry Im starting with PureBasic and suffering a lot these first days...
Could you tell me where I can get help about the following topics:?
- PB constants : the meaning, how to use them
- PB events
Please I have in mind to develop multiplatform applications, take me in that direction.
Thanks
Here is where Im stucked:
I have a 2 columns ListIcon, the first is a checkbox Type, second is a normal one
I have a counter about how many rows are selected... no problem here...
But I want to detect the nameof the second column when user click on it:
- if I click in the second column where the first one is selected..... I dont get the text
- The counter moves down when I select a row next the checkbox or in the 2 column
- If I click on 2 column and the first is NO select.... works OK
I tested with all the PB_ events but nothing work......
Here is the part of code:
#li_filesToCheck .... listIcon 2 columns
#st_filesToProcess .... counter (checked columns)
Code: Select all
Procedure.l numberOfCheckedElements(Gadget)
numItemsChecked.l = 0
For r=0 To CountGadgetItems(Gadget) - 1
Result = GetGadgetItemState(Gadget, r)
If Result = #PB_ListIcon_Checked
numItemsChecked = numItemsChecked + 1
EndIf
Next
ProcedureReturn numItemsChecked
EndProcedure
Procedure.s SelectedElement(Gadget)
EndProcedure
IF GadgetID = #li_filesToCheck
If EventType = #PB_EventType_LeftClick
numItemsChecked.l = numberOfCheckedElements(#li_filesToCheck)
SetGadgetText(#st_filesToProcess, Str(numItemsChecked))
ElseIf EventType = #PB_EventType_LeftDoubleClick
; selected element
For r=0 To CountGadgetItems(#li_filesToCheck) - 1
Result = GetGadgetItemState(#li_filesToCheck, r)
If Result = #PB_ListIcon_Selected
MessageRequester("resul", GetGadgetItemText(#li_filesToCheck,r,1), #PB_MessageRequester_Ok)
EndIf
Next
EndIf
EndIF
:roll:
Re: Where I can get documentation
Posted: Wed Jan 04, 2006 12:59 am
by Hydrate
chen wrote:Hi,
Sorry Im starting with PureBasic and suffering a lot these first days...
Could you tell me where I can get help about the following topics:?
- PB constants : the meaning, how to use them
- PB events
Please I have in mind to develop multiplatform applications, take me in that direction.
Thanks

Nice to see new programmers starting out. I can provide my interpretation of what you asked, i hope it helps:
A constant is a variable that is constantly the same (never changes, and cannot be changed). The PB constants are constants in the purebasic langauge, for example, the MessageRequester() function has the following constants:
#PB_MessageRequester_YesNo
#PB_MessageRequester_YesNoCancel
#PB_MessageRequester_Ok
The first one is 0, the second 1, the third 3. You can either put the constant value in, to change the type of message box, or the value instead, the constant values are there to make it easier.
An event is when something happens. For example, the #PB_Event_Menu is when the menu has been left clicked on. So you declare actions for when each button is pressed.
Posted: Wed Jan 04, 2006 1:05 am
by thefool
Hydrate is correct, here is a little thought of why constants are constants.:
At compile time constants are swiched with their corresponding value.
You can look at a constant the same way you look at numbers or strings directly typed in quotes.
Are not doable. Thats why
is the same as:
Wich doesnt make sense.
Posted: Wed Jan 04, 2006 1:24 am
by chen
I understand the meaning of constants, variables, events....etc.
My problem arise when i tried to use some PB commands and add to them
some constants or events. The manual has a few ones. It seems to me (newbe) in events is worst.
I've read several examples... most of them 2 or more years old...
those examples use events and variables that dont start with #PB_.
I think these variables are not multiplatform compatible..... But I dont
know if the #PB_ constants and events are enough to develop for all
the platforms PB claims to be.
Anyway I added the code is killing me in this moment... its in the first post.
if some of you have some minutes (You are experts!!

) , then give me a hand... a push... or some light
thanks again
Posted: Wed Jan 04, 2006 1:30 am
by thefool
Ah
Purebasic has lots of build in constants and structures you can use. Open the ide, click Tools and there you got Structure viewer. Open it and at top you can see 3 tabs, One with a list of structures and if you doubleclick them you can see what they contain, a list of interfaces, wich you also can doubleclick AND A list of constants.
Many of the constants, the most of them, doesnt contain the PB_ .
For example the #WS_TabStop wich you can use when making windows etc.
Posted: Wed Jan 04, 2006 1:31 am
by blueznl
did you check this...
viewtopic.php?t=18424
as well as the link below?
Posted: Wed Jan 04, 2006 2:10 am
by Intrigued
You can get at the PB Function List at: (change your drive letter (i.e. C:\) if you need to):
C:\Program Files\PureBasic\Compilers\PBFunctionListing.txt
also, take a look in the directory stopping at \Compilers for other useful information. The Constants I pulled from a post here in the forum, sometime back and I have non clue what that post is called.
Posted: Thu Jan 05, 2006 12:56 am
by chen
I've read every reply, I customized the IDE to have #PB_ constants
and events so as the API_ thing.
I checked the structures, functions, and constant in the IDE and
in the files you recommended me.
I have read the survive and the topic for starters so as checked
and review the file "PBFunctionListing.txt "
thanks: Hydrate, thefool, blueznland and Intrigued
I modified my code, and only one problem is alive.
When I select the second column ( In fact all the row is selected)
this affect my counter.... then I need to click in the ListIcon
after the last row for the counter comes back to the correct value.
How can I stop this behavior?
I spent several hours here and I coudnt get the solution.
Current code:
Code: Select all
Procedure.l numberOfCheckedElements(Gadget)
numItemsChecked.l = 0
For r=0 To CountGadgetItems(Gadget) - 1
Result = GetGadgetItemState(Gadget, r)
If Result = #PB_ListIcon_Checked
numItemsChecked = numItemsChecked + 1
EndIf
Next
ProcedureReturn numItemsChecked
EndProcedure
If EventType = #PB_EventType_LeftClick
numItemsChecked.l = numberOfCheckedElements(#li_filesToCheck)
SetGadgetText(#st_filesToProcess, Str(numItemsChecked))
EndIf
If EventType = #PB_EventType_LeftDoubleClick
res = GetGadgetState(#li_filesToCheck) ; get row doubleclicked
file.s = GetGadgetItemText(#li_filesToCheck,res,1) ; Get the file in row, col=1
MessageRequester("File Name", file , #PB_MessageRequester_Ok) ; here is the file name I need
EndIf
By the way: API functions means only WIndows? or are cross platform....
thanks again.

Posted: Thu Jan 05, 2006 1:02 am
by netmaestro
API functions are specific to the operating system you are using. PB for Windows has only Windows API functions.
Posted: Thu Jan 05, 2006 1:10 am
by chen
netmaestro wrote:API functions are specific to the operating system you are using. PB for Windows has only Windows API functions.
then this means... I can use API functions in windows and if I want to run
my application in MAC OSX .... compile it in MAC and run it without problems?
What I want to make sure is if the API functions defined in PB for windows
have their equinvalents in PB for MAC OSX and Linux, or is not in this way

Posted: Thu Jan 05, 2006 1:41 am
by netmaestro
For cross-platform development, the easiest way is to avoid API and stick to native commands, as most (if not all) are for all platforms.
Posted: Thu Jan 05, 2006 1:47 am
by Straker
chen wrote:netmaestro wrote:API functions are specific to the operating system you are using. PB for Windows has only Windows API functions.
then this means... I can use API functions in windows and if I want to run
my application in MAC OSX .... compile it in MAC and run it without problems?
What I want to make sure is if the API functions defined in PB for windows
have their equinvalents in PB for MAC OSX and Linux, or is not in this way

That is dependent upon the OS. Most PureBasic functions are portable amongst OSes, however, check the help file for function specifics. I just posted this code in another forum, however, it shows you how to code for multiple platforms:
Code: Select all
Procedure.l EditorGadgetDisplayOnly(pEditorGadget.l,pDisplayOnly.l)
; Parameters:
; pEditorGadget.l : the editor gadget to affect
;
; pDisplayOnly.l :
; 1 = Make the EditorGadget displayonly
; 0 = Make the EditorGadget editable
;
; Returns:
; 1 if successful
; -1 if OS is incorrect
;
lRetVal.l = 1
If (pDisplayOnly.l)
; set to display only/non-editable...
CompilerSelect #PB_Compiler_OS
CompilerCase #PB_OS_Linux
gtk_text_set_editable_(GadgetID(pEditorGadget.l),0)
CompilerCase #PB_OS_Windows
SendMessage_(GadgetID(pEditorGadget.l),#EM_SETREADONLY,#True,0)
CompilerDefault
lRetVal.l = -1
CompilerEndSelect
Else
; set to editable...
CompilerSelect #PB_Compiler_OS
CompilerCase #PB_OS_Linux
gtk_text_set_editable_(GadgetID(pEditorGadget.l),1)
CompilerCase #PB_OS_Windows
SendMessage_(GadgetID(pEditorGadget.l),#EM_SETREADONLY,#False,0)
CompilerDefault
lRetVal.l = -1
CompilerEndSelect
EndIf
ProcedureReturn lRetVal.l
EndProcedure
Basically, the code makes the EditorGadget display only, but makes API calls to do this.
For Windows, I call:
SendMessage_(GadgetID(pEditorGadget.l),#EM_SETREADONLY,#False,0)
For Linux, I call:
gtk_text_set_editable_(GadgetID(pEditorGadget.l),1)
As you can also see, there is a very handy native
CompilerSelect/CompilerIf pre-compiler directive available in PureBasic.