Hi Charles,
I have a General question if its possible with oxygen to call a function itself without calling it separately and extra as usual ? Dont using an include File?
'#include "testme.inc" '' with using an include file it's not a problem here
FUNCTION mytest() AS LONG
local t as long
LOCAL a,b,c AS LONG
a=20
b=50
c=a*b
print "calculation test "+ str(c) ' result 1000
''' it's possible to call mytest() itself inner function?
'if not t then
'call mytest()
'end if
''' it's possible to call mytest() itself inner function?
END FUNCTION
mytest() ' all ok that's the usual way to call a function
''
''mytest() ' if it's deactivated it's not possible to call mytest() function
'' or it's another way possible perhaps with asm?
If you mean recursion, yes. the function does not have to be declared first. But you have to make sure it stops calling itself before causing a stack overflow.
Example of simple direct recursion:
uses console
function rf(int i)
if i>0 'limit recursion
print i tab i*i cr
rf(i-1) 'recurse
endif
end function
rf 20
wait
Yes thanks.. I know already recursive function as Well but my question was more directed into this direction what happened If you dont call in your example the rf(20) ?
I tried to understand how does a function Like pbmain() Works without calling it itself at the end?
I think its Not possible but I can See it must Run ;)
All functions are designed to be called. In PB there is invisible code calling pbmain(). (OxygenBasic does not require a main function.)
Yes, thanks charles :) I have explored some Infos more... And I understand more about this Special topic..
"In PowerBASIC, the pbmain() function is a special function that serves as the entry point for the program.
When you run a PowerBASIC program, the pbmain() function is automatically called by the PowerBASIC runtime, so you don't
need to call it explicitly in your code."
I am not quite sure but found an old simple example of a PowerBASIC program that demonstrates how The pbmain() function and the PowerBASIC runtime library work together:
#Include "PbWin90.inc"
Function pbMain() As Long
MessageBox 0, "Hello, World!", "PowerBASIC Example", MB_OK
EndFunction