News:

Welcome to RetroCoders Community

Main Menu

UDF in interpreter

Started by aurel, Apr 30, 2024, 02:38 PM

Previous topic - Next topic

aurel

;D
First time in micro(A) global and local
calculation as function parameter expression


' function with arguments
var g : g = 50 : wcolor 0,0,0 : mode 1
fcolor 150,240,150 : print 50,50,g : swap
myFn(5+g*2)
'print 100,150,a

func myFn(var a)
fcolor 250,200,150
print 50,80,"local + global (5+g*2)"
print 50,100,a
swap 
endFn

aurel

and now test with 3 params and one of them is
expression with built-in function sin(90)

' function with arguments
var g : g = 50 : wcolor 0,0,0 : mode 1
fcolor 150,240,150 :print 5,10,"global:": print 100,10,g : swap
' func call with params...
myFn(5,3+g,2*sin(90))

func myFn(var a,var b,var c)
  fcolor 250,200,150
  print 50,30,"local a"
  print 50,50,a
  print 50,80,"local b"
  print 50,100,b
  var f : f = a + b + c
  fcolor 150,200,250 :print 5,150,"result:": print 100,150,f
  swap   
endFn