Only within the life of your code, you could use a pointer.
run first with createfile.
then comment out createfile and run (to test outside your code)
Code: Select all
'Step1 Create Code
sub test
print "Hello World"
end sub
'Step2 Write Code to binary
#macro createfile
open "code.bin" for binary as #1
dim as any ptr p=@test
put #1,,cint(p)
close #1
#endmacro
createfile
'Step3 Load and execute code
dim as integer code
open "code.bin" for binary as #1
get #1,,code
close #1
cast(sub,code)()
sleep
Not using createfile is the same as calling the pointer from another code, it seems to work here, but it is probably not guaranteed to work.