Learning Basic to use PureBasic.

Everything else that doesn't fall into one of the other PB categories.
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by celeron504.

Hi all!

I guess I have lurked in the shadows long enough. I would appreciate if anyone here could recommend a good source or tutorial on Basic so that I could learn how to use PureBasic. I am really interested in what Fred has accomplished so far. (And in the future.) In my former life, programming was not really necessary so I had the misfortune of not being able to enjoy this fine adventure. I would like to (someday) be able to program games but realize this will take time and a concentrated effort on my part. I can do console programming in C++ so I am able to learn and can read/understand program flow so it will not be totally new. I just never had the opportunity to learn Basic.

Thanks in advance.

Using WindowsXP, my Linux box is in the shop!
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by dmoc.

Hi celeron! I suggest you start with the many examples from the resources site (below) and post any questions you have in the beginners forum here. If you have done C++ programming then it won't be difficult to pick up BASIC.

http://www.reelmediaproductions.com/pb/
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by celeron504.

dmoc,

Thanks for the reply. I tried looking at some examples at the site listed but they seemed to be a little over my head at the moment. I was wondering more about starting small and working up from there. Say a text editor or a nice little console app.

Any other help is greatly appreciated.

Thanks to all who viewed. I appreciate the attention!

Using WindowsXP, my Linux box is in the shop!
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by ricardo.

Hi,

You need to learn BASIC or just to understand how to code in PureBasci?
Its not the same, the BASIC stuff is if you need to learn things like IF, SELECT CASE, FOR, etc.

And Purebasic is if you need only to know how to make your own app in PB.

See this code:

Code: Select all

;Here you create a Window
If OpenWindow(0,100,150,450,200,#PB_Window_SystemMenu,"Test")
  ;Here yo say PB that you will add controls to your window
  CreateGadgetList(WindowID())
  
  ;Now list every control, the first number is the NUMBER of the control (gadget)
  StringGadget(1,50,50,350,20,"")
  ButtonGadget(2,200,100,50,25,"Test")
  
  ;Now here you will catch when some control receive user input
  ;your app will stay here until the user exit the app
  Repeat
    ;Receive every user input
    EventID=WaitWindowEvent()
    
    
    Select EventID
      ;We will se which gadget receive the input
      Case #PB_EventGadget
        Select EventGadgetID()
          ;The NUMBER of every gadget is used here to catch the events of that gadget
          ;in this case the button is gadget 2 remember? ButtonGadget(2
          Case 2
            ;If the gadget 2 receives the event then trigger this part
            MessageRequester("button clicked","Hello PureBasic",0)
        EndSelect
    
    EndSelect
   ;when the user exit the app 
  Until EventID=#PB_EventCloseWindow
EndIf
Its a very simple esqueleton of an application. We can do something a little more complicated:

Code: Select all

;Here you create a Window
If OpenWindow(0,100,150,450,200,#PB_Window_SystemMenu,"Test")
  ;Here yo say PB that you will add controls to your window
  CreateGadgetList(WindowID())
  
  ;Now list every control, the first number is the NUMBER of the control (gadget)
  StringGadget(1,50,50,350,20,"")
  ButtonGadget(2,200,100,50,25,"Test")
  ;Instructions
  MessageRequester("Instructions", "Write your name in the textbox and then click the button",0)
  ;Now here you will catch when some control receive user input
  ;your app will stay here until the user exit the app
  Repeat
    ;Receive every user input
    EventID=WaitWindowEvent()
    
    
    Select EventID
      ;We will se which gadget receive the input
      Case #PB_EventGadget
        Select EventGadgetID()
          ;The NUMBER of every gadget is used here to catch the events of that gadget
          ;in this case the button is gadget 2 remember? ButtonGadget(2
          Case 2
            ;If the gadget 2 receives the event then trigger this part
              ;With GeGadgetText(#) we can get the text that is inside a gadget or control
              If GetGadgetText(1) = ""
            MessageRequester("Hey","You need to write your name in the text box",0)
              Else
            MessageRequester("Ok", "Hello " + GetGadgetText(1),0)
              EndIf
        EndSelect
    
    EndSelect
   ;when the user exit the app 
  Until EventID=#PB_EventCloseWindow
EndIf
This kind of help did you need or something more complicated?



Best Regards

Ricardo

Dont cry for me Argentina...
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by Danilo.

All Basic keywords are explained in the Reference manual
on the left side.

If you read all that entries about If..ElseIf..Else..EndIf
and Select..Case..Default..EndSelect and everything, you
should be able to use it very fast.
Its like in C, the basic keywords for controling program flow
are not very much.
And after that, you could read about all PureBasic commands
on the right side in the reference manual.

If you read the reference manual, you´ll be able to use BASIC/PB
in some days and in 2 month you can make really nice programs.

Just dont forget to write much code while reading about new stuff...

cya,
...Danilo
(registered PureBasic user)
Post Reply