Page 1 of 1

Procedure is not defined

Posted: Mon Feb 01, 2016 5:11 am
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

Re: Procedure is not defined

Posted: Mon Feb 01, 2016 8:20 am
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

Re: Procedure is not defined

Posted: Mon Feb 01, 2016 3:37 pm
by skywalk
Hi Fred,
Does PureBasic also remove unreferenced Procedures?

Re: Procedure is not defined

Posted: Mon Feb 01, 2016 5:38 pm
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

Re: Procedure is not defined

Posted: Mon Feb 01, 2016 10:50 pm
by Fred
skywalk wrote:Hi Fred,
Does PureBasic also remove unreferenced Procedures?
Yes, but not the referenced PureBasic command inside unused procedure.