survival guide

Just starting out? Need help? Post your questions and find answers here.
User avatar
blueznl
PureBasic Expert
PureBasic Expert
Posts: 6172
Joined: Sat May 17, 2003 11:31 am
Contact:

survival guide

Post by blueznl »

i put most of my stupid mistakes together on a page, a sort of survival guide... :wink:

if anyone knows his stuff and has nothing better to do... did i make any mistakes? other than the ones that caused me to set up that page :-)

http://www.xs4all.nl/~bluez/datatalk/pure1.htm
TerryHough
Enthusiast
Enthusiast
Posts: 781
Joined: Fri Apr 25, 2003 6:51 pm
Location: NC, USA
Contact:

Re: survival guide

Post by TerryHough »

blueznl wrote:...if anyone knows his stuff and has nothing better to do...
Certainly doesn't apply to me :D

In your discussion of Code Order, you way want to look at and add the
Declare approach.

I, too, like to sometimes have Procedures called before they appear in
the code. Took me a few days to realize how to make that happen.

Your example:

Code: Select all

test1()  ; can't compile as test1() is not yet defined 

  Procedure test1() 
    test2()  ; can't compile as test2() is not yet defined 
  EndProcedure 

  Procedure test2() 
    ; do nothing 
  EndProcedure 
with a slight change now compiles

Code: Select all

Declare test1()
Declare test2()

test1()  ; now compiles without a problem 
test2()  ; 
  Procedure test1() 
    test2()  ; can't compile as test2() is not yet defined 
  EndProcedure 

  Procedure test2() 
    ; do nothing 
  EndProcedure 
Keep going, I am sure you will find (and report) lots of interesting new
things as you learn more about PureBasic.

Terry
User avatar
blueznl
PureBasic Expert
PureBasic Expert
Posts: 6172
Joined: Sat May 17, 2003 11:31 am
Contact:

Post by blueznl »

i will add this, didn't know it, more of this is welcome!
( PB6.00 LTS Win11 x64 Asrock AB350 Pro4 Ryzen 5 3600 32GB GTX1060 6GB - upgrade incoming...)
( The path to enlightenment and the PureBasic Survival Guide right here... )
GPI
PureBasic Expert
PureBasic Expert
Posts: 1394
Joined: Fri Apr 25, 2003 6:41 pm

Post by GPI »

blueznl wrote:i will add this, didn't know it, more of this is welcome!
Activate in japbe "automatic save declare" and you can do this:

(Save as test.pb)

Code: Select all

xincludefile "test.pb.declare"
debug test(1)

procedure test(a)
  procedurereturn test2(a)
endprocedure
procedure test2(a)
  procedurereturn a*a
endprocedure
but NOTE!
You should definied your structure before includeing "test.pb.declare", when you use your structure in the parameter-list

this will not work:

Code: Select all

xincludefile "test.pb.declare"

structure Dummy
  l.l
endstructure

debug test(1)

procedure test(a)
  procedurereturn test2(@a)
endprocedure
procedure test2(*a.dummy)
  procedurereturn a\l*a\l
endprocedure
This will:

Code: Select all

structure Dummy
  l.l
endstructure

xincludefile "test.pb.declare"

debug test(1)

procedure test(a)
  procedurereturn test2(@a)
endprocedure
procedure test2(*a.dummy)
  procedurereturn a\l*a\l
endprocedure
or don't use Structre in the parameterlist:

Code: Select all

xincludefile "test.pb.declare"

structure Dummy
  l.l
endstructure

debug test(1)

procedure test(a)
  procedurereturn test2(@a)
endprocedure
procedure test2(*b)
  *a.dummy=*b
  procedurereturn *a\l * *a\l
endprocedure
Edit: Last note:
When you start to compile, jaPBe look in the directory of your mainfile and create a "all.declare", which includes all files, which are found in this directory.
Post Reply