Code: Select all
If ThisIsInFunctionOrSubCalled then
return true
else
return false
end if
Code: Select all
If ThisIsInFunctionOrSubCalled then
return true
else
return false
end if
Code: Select all
#macro set(n)
sub n
tally+=__function__+" "
print timer
print
sleep 100
end sub
#endmacro
function tally() byref as string
static as string s
return s
end function
set(a)
set(b)
set(c)
set(d)
set(e)
set(f)
set(g)
set(h)
set(i)
a
d
g
i
sub finish destructor
print "procedures called:"
print tally
print "press any key to end"
sleep
end sub
Code: Select all
function WhoCalledMe(ThisIsInFunctionOrSubCalled as boolean = false) as boolean
if ThisIsInFunctionOrSubCalled = true then
print "I am called by a function or a sub"
else
print "I am called by main"
end if
return ThisIsInFunctionOrSubCalled
end function
sub CallWhoCalledMe
print WhoCalledMe(true)
end sub
print WhoCalledMe
print
CallWhoCalledMe
sleep
Code: Select all
Function WhoCalledMe(Byref fct As String) As Boolean
If fct = "__FB_MAINPROC__" Or fct = "__FB_MODLEVELPROC__" Then
Print "I am called by main"
Return False
Else
Print "I am called by a function or a sub ('" & fct & "')"
Return True
End If
End Function
Sub CallWhoCalledMe
Print WhoCalledMe(__FUNCTION__)
End Sub
Print WhoCalledMe(__FUNCTION__)
Print
CallWhoCalledMe
Sleep
Code: Select all
I am called by main
false
I am called by a function or a sub ('CALLWHOCALLEDME')
true
Yep this works finefxm wrote: ↑Mar 19, 2023 17:14 I did not quite understand what you are exactly looking to do, but the code below might be able to help:Code: Select all
Function WhoCalledMe(Byref fct As String) As Boolean If fct = "__FB_MAINPROC__" Or fct = "__FB_MODLEVELPROC__" Then Print "I am called by main" Return False Else Print "I am called by a function or a sub ('" & fct & "')" Return True End If End Function Sub CallWhoCalledMe Print WhoCalledMe(__FUNCTION__) End Sub Print WhoCalledMe(__FUNCTION__) Print CallWhoCalledMe Sleep
Code: Select all
I am called by main false I am called by a function or a sub ('CALLWHOCALLEDME') true
Please use the code tags around code in your posts: [ code ] [ /code ] without the spaces inside the brackets will display your code in a nicer way.Hedgehog wrote: ↑Mar 21, 2023 18:51 here the solution to your light problem:Code: Select all
' 'chuck.summer@mail.com: dim shared as boolean f2,b1 ' function uf(x as ubyte) as boolean:return x=1:end function 'under_function_uf function f0() as boolean:dim f1 as boolean:f1=uf(1):? "f1:";f1:return f1:end function 'call uf in function f0 sub f2b():f2=uf(1):? "f2:";f2:end sub 'call uf in sub ' b1=f0() 'call uf (returns true) in main_function f2b() 'call uf (returns true) in main_sub b1=uf(0):? b1 'call uf (returns false) :code is not in function or sub ' do:loop ' 'PCN w Hedgehog