I couldn't find a sub or include keyword and where do you put your structures and constants?Do you put them in every routine that needs them? Thanks in advance:
Hot Pockets
How do you write a program?
Re: How do you write a program?
PB 6.01 ― Win 10, 21H2 ― Ryzen 9 3900X, 32 GB ― NVIDIA GeForce RTX 3080 ― Vivaldi 6.0 ― www.unionbytes.de
Lizard - Script language for symbolic calculations and more ― Typeface - Sprite-based font include/module
Lizard - Script language for symbolic calculations and more ― Typeface - Sprite-based font include/module
-
- User
- Posts: 51
- Joined: Mon Jun 01, 2009 3:56 am
Re: How do you write a program?
Thank You for Being so help full!
Hot Pockets
Hot Pockets

Re: How do you write a program?
If i were you, i would download kales book
"PureBasic - A Beginner's Guide To Computer Programming"
link : http://www.purebasic.fr/english/viewtop ... 14&t=37059
Edit* Your subject doesn't fit your question
Regards
Henrik
"PureBasic - A Beginner's Guide To Computer Programming"
link : http://www.purebasic.fr/english/viewtop ... 14&t=37059
Edit* Your subject doesn't fit your question
Regards
Henrik
Last edited by Henrik on Wed Nov 24, 2010 7:51 pm, edited 4 times in total.
- utopiomania
- Addict
- Posts: 1655
- Joined: Tue May 10, 2005 10:00 pm
- Location: Norway
Re: How do you write a program?
Install PB and check out some of the examples that comes with it.
Re: How do you write a program?
Hotpockets, it depends on your coding style. I typically throw all inits etc. togeter in one procedure leading to a basic structure like this:
Collections of routines that I keep using (in my case I have a file called x_lib.pb, it's included with CodeCaddy) have a similar structure:
In my main programs I include the x_lib.pb file, and call x_init() once to get the thing moving:
Code: Select all
;
;
EnableExplicit
Define init()
Define main()
init()
main()
;
Procedure init()
;
; define structures, code, constants, whatever
;
EndProcedure
Procedure main()
;
; loop, event handling, whatever
;
EndProcedure
Code: Select all
Procedure x_init()
;
EndProcedure
Procedure x_something()
;
EndProcedure
Code: Select all
;
;
EnableExplicit
Define init()
Define main()
IncludeFile("x_lib.pb")
x_init()
init()
main()
;
Procedure init()
;
; define structures, code, constants, whatever
;
EndProcedure
Procedure main()
;
; loop, event handling, whatever
;
x_whatever()
EndProcedure
( PB6.00 LTS Win11 x64 Asrock AB350 Pro4 Ryzen 5 3600 32GB GTX1060 6GB)
( The path to enlightenment and the PureBasic Survival Guide right here... )
( The path to enlightenment and the PureBasic Survival Guide right here... )
- netmaestro
- PureBasic Bullfrog
- Posts: 8451
- Joined: Wed Jul 06, 2005 5:42 am
- Location: Fort Nelson, BC, Canada
Re: How do you write a program?
Structures and constants have a global scope and can go anywhere north of the first line in which they are used, including inside procedures but good coding style (to me at least) is to group them at the top of your program and clearly identify what they're for using comments.
BERESHEIT