Function indexing
- nblackburn
- User
- Posts: 67
- Joined: Mon Aug 19, 2013 1:22 am
- Location: United Kingdom
- Contact:
Function indexing
Not sure if this will be a popular idea or not but it could work if the language indexes the function names before parsing (so it knows they exist), so that you no longer have to place them in a certain order, thus preventing the error of them not existing.
Re: Function indexing
Declare ?
Re: Function indexing
The compiler makes only one pass. This is why the order is important. Bisonte's suggestion is the routine way for the language to deal with procedure's code that appears after they are first called.nblackburn wrote:Not sure if this will be a popular idea or not but it could work if the language indexes the function names before parsing (so it knows they exist), so that you no longer have to place them in a certain order, thus preventing the error of them not existing.
- nblackburn
- User
- Posts: 67
- Joined: Mon Aug 19, 2013 1:22 am
- Location: United Kingdom
- Contact:
Re: Function indexing
What i mean is if you create a function called Foo() and called it before it was declared in the code then you get an error which most languages have overcome so i was suggesting it for this language as i feel it would be a good idea.
Thanks for the suggestions but could you demonstrate to me how this would be done as I am fairly new to the language.
Thanks for the suggestions but could you demonstrate to me how this would be done as I am fairly new to the language.
-
- 666
- Posts: 1033
- Joined: Mon Sep 01, 2003 2:33 pm
Re: Function indexing
what Bisonte and Demivec say is correct. The declare command is what you are after... and already exists.nblackburn wrote:Not sure if this will be a popular idea or not but it could work if the language indexes the function names before parsing (so it knows they exist), so that you no longer have to place them in a certain order, thus preventing the error of them not existing.
Example:
Code: Select all
EnableExplicit ; This command is your best friend!!!
; Make sure the declarations match the procedure exactly or you get an error...
;
Declare.i moo()
Declare.s Baa()
Declare.f Woof()
Woof()
Baa()
moo()
;-Procedures
End
Procedure.i moo()
Debug "moo"
EndProcedure
Procedure.s Baa()
Debug "Baa"
EndProcedure
Procedure.f Woof()
Debug "Woof"
EndProcedure
- nblackburn
- User
- Posts: 67
- Joined: Mon Aug 19, 2013 1:22 am
- Location: United Kingdom
- Contact:
Re: Function indexing
Thanks for the example, I would of replied sooner but appear to have had my IP blacklisted as I can't access the website via traditional methods.
I will see if I can get this thread closed as it is not longer relevant.
I will see if I can get this thread closed as it is not longer relevant.
-
- 666
- Posts: 1033
- Joined: Mon Sep 01, 2003 2:33 pm
Re: Function indexing
you are welcome 

Re: Function indexing
I realize the norm seem to be to try to code something and see how it goes, to eventually fallback asking in the forum, but
since you are a new user reading once the manual from top to bottom would prove to be extremely useful.
You can then fallback to the forum for what it's still missing or unclear.
since you are a new user reading once the manual from top to bottom would prove to be extremely useful.
You can then fallback to the forum for what it's still missing or unclear.
help wrote: Syntax
Declare[.<type>] name(<parameter1[.<type>]> [, <parameter2[.<type>]>, ...])
Description
Sometimes a procedure need to call another procedure which isn't declared before its definition. This is annoying because the compiler will complain 'Procedure <name> not found'. Declare can help in this particular case by declaring only the header of the procedure. Nevertheless, the Declare and real Procedure declaration must be identical (including the correct type).
"Have you tried turning it off and on again ?"
A little PureBasic review
A little PureBasic review
Re: Function indexing
> Not sure if this will be a popular idea or not
Hi, I know you're new here, but PureBasic has been around for
over 12 years now and just about EVERYTHING has been asked
or discussed before. Almost literally. Including this thread. You
just need to use the forum search function first before posting.
So, as a newbie, you think you've found bugs and come up with
fresh new ideas, but as long-time member I can tell you that's
pretty much always false. That's why in your other post about
the font ID you were told to read the Bug Report FAQ.
I know you're excited to be here, but just do lots of searching
the forums and reading the manual first. All answers are there.
Don't take offense at this post, as that's not my intention.
Welcome to the forums!
Hi, I know you're new here, but PureBasic has been around for
over 12 years now and just about EVERYTHING has been asked
or discussed before. Almost literally. Including this thread. You
just need to use the forum search function first before posting.
So, as a newbie, you think you've found bugs and come up with
fresh new ideas, but as long-time member I can tell you that's
pretty much always false. That's why in your other post about
the font ID you were told to read the Bug Report FAQ.

I know you're excited to be here, but just do lots of searching
the forums and reading the manual first. All answers are there.
Don't take offense at this post, as that's not my intention.
Welcome to the forums!

I compile using 5.31 (x86) on Win 7 Ultimate (64-bit).
"PureBasic won't be object oriented, period" - Fred.
"PureBasic won't be object oriented, period" - Fred.
- nblackburn
- User
- Posts: 67
- Joined: Mon Aug 19, 2013 1:22 am
- Location: United Kingdom
- Contact:
Re: Function indexing
Sorry, no offence taken.
I have been browsing the forum and reading the manual like a insane person, I just sometimes can't find what I am looking for as I don't know what I am suppose to be searching for.
I have been browsing the forum and reading the manual like a insane person, I just sometimes can't find what I am looking for as I don't know what I am suppose to be searching for.
-
- Always Here
- Posts: 6426
- Joined: Fri Oct 23, 2009 2:33 am
- Location: Wales, UK
- Contact:
Re: Function indexing
We have all had that problem at first, and we are all here to help you - PB is not only powerful, it has one of the best forums too. Many of the experts very kindly donate a huge amount of their time here.I just sometimes can't find what I am looking for as I don't know what I am suppose to be searching for.
IdeasVacuum
If it sounds simple, you have not grasped the complexity.
If it sounds simple, you have not grasped the complexity.