Just started,
Just started,
Hey,
i have just started with this language.
I haven't made anything as of yet. But i will shortly i am sure.
I have been coding in other languages now for a while.
Mainly doing web development.
So i thought this could be an easy chance back into the Software side.
Just a couple of questions before i get started,
-Does this language code with sockets and internet?
For example, making some sort of web browser?
Also in sockets making some sort of irc bot?
I will be using this for whatever i can so,
Thanks.
i have just started with this language.
I haven't made anything as of yet. But i will shortly i am sure.
I have been coding in other languages now for a while.
Mainly doing web development.
So i thought this could be an easy chance back into the Software side.
Just a couple of questions before i get started,
-Does this language code with sockets and internet?
For example, making some sort of web browser?
Also in sockets making some sort of irc bot?
I will be using this for whatever i can so,
Thanks.
- Rook Zimbabwe
- Addict
- Posts: 4322
- Joined: Tue Jan 02, 2007 8:16 pm
- Location: Cypress TX
- Contact:
HideWindow() will do that for you... really simple.
Pretty simple really!
You should Read the Manual and a lot of code.
Code: Select all
Enumeration
#Window_POPUP ; set up gadgets
#Window_MAIN
EndEnumeration
Enumeration
#Button_CLOSEPOPUP
#Text_0
#Button_OPENPOPUP
EndEnumeration
; the followingis done by the Visual Designer
Structure VisualDesignerGadgets
Gadget.l
EventFunction.l
EndStructure
Global NewList EventProcedures.VisualDesignerGadgets()
; gadget list
Procedure Button_CLOSEPOPUP_Event(Window, Event, Gadget, Type)
Debug "#Button_CLOSEPOPUP"
HideWindow(#Window_POPUP,1) ; HideWindow(NAME,STATUS) = 1 HIDDEN
EndProcedure
Procedure Button_OPENPOPUP_Event(Window, Event, Gadget, Type)
Debug "#Button_OPENPOPUP"
HideWindow(#Window_POPUP,0) ; HideWindow(NAME,STATUS) = 0 SHOW
EndProcedure
; the following allows the program to understand what to do when someone presses a gadget
Procedure RegisterGadgetEvent(Gadget, *Function)
If IsGadget(Gadget)
AddElement(EventProcedures())
EventProcedures()\Gadget = Gadget
EventProcedures()\EventFunction = *Function
EndIf
EndProcedure
Procedure CallEventFunction(Window, Event, Gadget, Type)
ForEach EventProcedures()
If EventProcedures()\Gadget = Gadget
CallFunctionFast(EventProcedures()\EventFunction, Window, Event, Gadget, Type)
LastElement(EventProcedures())
EndIf
Next
EndProcedure
Procedure Open_Window_MAIN()
If OpenWindow(#Window_MAIN, 129, 26, 299, 132, "Window MAIN", #PB_Window_SystemMenu | #PB_Window_SizeGadget | #PB_Window_TitleBar | #PB_Window_ScreenCentered )
If CreateGadgetList(WindowID(#Window_MAIN))
ButtonGadget(#Button_OPENPOPUP, 10, 70, 275, 45, "CLICK TO OPEN POPUP")
RegisterGadgetEvent(#Button_OPENPOPUP, @Button_OPENPOPUP_Event())
TextGadget(#Text_0, 10, 25, 275, 20, "CLICK THE BUTTON TO OPEN A POPUP WINDOW!!!", #PB_Text_Center)
EndIf
EndIf
EndProcedure
Procedure Open_Window_POPUP()
If OpenWindow(#Window_POPUP, 247, 78, 298, 79, "Window POPUP", #PB_Window_TitleBar | #PB_Window_ScreenCentered | #PB_Window_Invisible )
; The #PB_Window_Invisible makes it hidden until called upon
If CreateGadgetList(WindowID(#Window_POPUP))
ButtonGadget(#Button_CLOSEPOPUP, 10, 10, 275, 50, "CLICK TO CLOSE POPUP WINDOW")
RegisterGadgetEvent(#Button_CLOSEPOPUP, @Button_CLOSEPOPUP_Event())
EndIf
EndIf
EndProcedure
Open_Window_POPUP()
Open_Window_MAIN()
Repeat
Event = WaitWindowEvent(3) ; allow other tasks to process
Gadget = EventGadget()
Type = EventType()
Window = EventWindow()
Select Event
Case #PB_Event_Gadget
CallEventFunction(Window, Event, Gadget, Type)
EndSelect
Until Event = #PB_Event_CloseWindow
End
You should Read the Manual and a lot of code.

-
- Addict
- Posts: 1264
- Joined: Wed Feb 28, 2007 9:13 am
- Location: London
Yip.Is it actually easier than it looks?
PureBasic is a very rewarding language. It enables you to do many, many, many different things. It's very flexible and it cuts out a lot of unnecessary syntax nonsense that plagues other languages.
But it enables you to do so many things because it doesn't do everything for you. You are in full control. Therefore, yes, there's quite a lot to learn.
BUT, because of the simplicity of the language, learning it gets easy very quickly, if you stay with it.
Simpler:
Or with a real window:
Code: Select all
OpenWindow(0, 0, 0, 512, 384, "", #PB_Window_ScreenCentered | #PB_Window_SystemMenu)
CreateGadgetList(WindowID(0))
Button = ButtonGadget(#PB_Any, 10, 10, 97, 23, "Click me!")
Repeat
Select WaitWindowEvent()
Case #PB_Event_Gadget
Select EventGadget()
Case Button
MessageRequester("Title", "Ouch, don't poke me like that!!!")
EndSelect
Case #PB_Event_CloseWindow
Break
EndSelect
ForEver
Code: Select all
OpenWindow(0, 0, 0, 512, 384, "", #PB_Window_ScreenCentered | #PB_Window_SystemMenu)
CreateGadgetList(WindowID(0))
Button = ButtonGadget(#PB_Any, 10, 10, 197, 23, "Click me many times")
OpenWindow(1, 0, 0, 200, 200, "Small window", #PB_Window_Invisible)
Repeat
Select WaitWindowEvent()
Case #PB_Event_Gadget
Select EventGadget()
Case Button
HideWindow(1, Hidden)
Hidden = (-Hidden)+1
EndSelect
Case #PB_Event_CloseWindow
Break
EndSelect
ForEver
oToom wrote:Sounds cool.
The console applications seem quite easy.
i am having problems with / when using the Visual Editor.
I make a button, just so that when i click it i get a pop up, yet i don't know how to do it.
Like in VB you get like a On_Click do you get these on here?
Code: Select all
If OpenWindow(0,100,150,450,200,"Test",#PB_Window_SystemMenu) ;Create a window
CreateGadgetList(WindowID(0)) ;tell PB you will add controls/gadgets
ButtonGadget(2,200,100,50,25,"Test") ;add your button
;And now you get the what the user does in this loop
Repeat
EventID=WaitWindowEvent()
Select EventID ;some event happends
Case #PB_Event_Gadget ;it was a gadget
Select EventGadget() ;lets find which gadget
Case 2 ;was gadget 2, so lets do something when gadget 2 was clicked
MessageRequester("","hello world!",0)
EndSelect
EndSelect
Until EventID=#PB_Event_CloseWindow ;if closewindow is clicked
EndIf
End ; bye
I recommend the book, buy it.
If you download the 'sample' you can view the table of contents.
http://www.kalekold.net/pb-beginners/Re ... Sample.pdf
cheers
http://www.kalekold.net/pb-beginners/Re ... Sample.pdf
cheers