Inner function

Started by Frank Brübach, June 30, 2024, 09:07:17 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Frank Brübach

Good morning

I have found this little old oxygen example and would Like to fix IT but how? Do you have another inner function example for me Charles? Thanks, Frank

' inner function example
' oxygen, old example
'
uses console

printl "ok"

'---------------------------
function myfun(int k) as long
'===========================
local int v,a,c
static int b
a=k
c=20000
b=4

printl "ok1"

'function abc(int k) as long = k*20 ' doesn't work
function abc(int k=k*20) as long
int a
'--------------------- //
'print str abc a ' error
'--------------------- //
end function

function abc(int k) as long (function=10+k*10)
'--------------------- //
'print str abc a ' error
'--------------------- //


function abc(byval v as long) as long (local c=13 : function=k*3+b+c )
'--------------------- //
'print str abc a ' error
'--------------------- //

function f(int k) as long
(
local int c=17
function=c+k*3
)


function=0
end function

printl "ok2"

print myfun(1)
wait

Charles Pegge

Hi Frank,

Much simpler example, but I see a problem with the inner function=... so I substituted it with return ...

' inner function example
uses console

function myfun(long v) as long
==============================
  'inner
  function f(long k) as long
    int c=10
    return c+k*3 'problem with function=...
  end function

function= f(v)+100
end function

print myfun(2) '116
wait