Procedure is not defined

Just starting out? Need help? Post your questions and find answers here.
Stefan Schnell
Posts: 46
Joined: Tue Dec 01, 2015 8:17 am
Contact:

Procedure is not defined

Post by Stefan Schnell »

Hello Fred,
if I try this example it didn't work:

Code: Select all

Procedure MyProcedure()
  Debug "Hello world"
EndProcedure
  
!f_myprocedure();
Uncaught reference error: f_myprocedure is not defined.

The procedure MyProcedure doesn't exists really in spiderbasic.js.

Thanks for correcting.

Cheers
Stefan
Fred
Site Admin
Posts: 1820
Joined: Mon Feb 24, 2014 10:51 am

Re: Procedure is not defined

Post by Fred »

You need to call it at least once, as SpiderBasic automatically remove unused procedures (so you can have big includes without using all the functions). But It can be referenced in an unused function, as it does not remove it recursively:

Code: Select all

Procedure MyProcedure()
  Debug "Hello world"
EndProcedure
 
!f_myprocedure();

; This one will be stripped from the output
Procedure ReferenceProcedures()
  MyProcedure()
EndProcedure
User avatar
skywalk
Posts: 55
Joined: Tue Feb 25, 2014 2:13 am
Location: Boston, MA

Re: Procedure is not defined

Post by skywalk »

Hi Fred,
Does PureBasic also remove unreferenced Procedures?
When working toward the solution of a problem, it always helps if you know the answer. ~ ?
An expert is one who knows more and more about less and less until he knows absolutely everything about nothing. ~ Weber
Stefan Schnell
Posts: 46
Joined: Tue Dec 01, 2015 8:17 am
Contact:

Re: Procedure is not defined

Post by Stefan Schnell »

Hello Fred,

thank you very much for your explanation. I think this information are valueable to be included in the documentation - what do you think?

Thanks again and cheers
Stefan
Fred
Site Admin
Posts: 1820
Joined: Mon Feb 24, 2014 10:51 am

Re: Procedure is not defined

Post by Fred »

skywalk wrote:Hi Fred,
Does PureBasic also remove unreferenced Procedures?
Yes, but not the referenced PureBasic command inside unused procedure.
Post Reply