type test_func_ptr
declare function nex() as ulongint
declare function pre() as ulongint
declare function set_next() as ulongint
declare function set_prev() as ulongint
dim get_data as function() as ulongint
end type
function test_func_ptr.set_next() as ulongint
this.get_data = procptr(this.nex)
return 1
end function
function test_func_ptr.set_prev() as ulongint
this.get_data = procptr(this.pre)
return 1
end function
function test_func_ptr.nex() as ulongint
print "next"
return 1
end function
function test_func_ptr.pre() as ulongint
print "prev"
return 1
end function
dim as test_func_ptr udt
udt.set_next() 'point get_data() to nex()
udt.get_data()
udt.set_prev() 'point get_data() to pre()
udt.get_data()
Last edited by SamL on Mar 02, 2024 19:12, edited 1 time in total.
type test_func_ptr
declare function nex() as ulongint
declare function pre() as ulongint
declare function set_next() as ulongint
declare function set_prev() as ulongint
dim get_data as function(Byref As test_func_ptr) as ulongint '' *****
end type
function test_func_ptr.set_next() as ulongint
this.get_data = procptr(test_func_ptr.nex) '' *****
return 1
end function
function test_func_ptr.set_prev() as ulongint
this.get_data = procptr(test_func_ptr.pre) '' *****
return 1
end function
function test_func_ptr.nex() as ulongint
print "next"
return 1
end function
function test_func_ptr.pre() as ulongint
print "prev"
return 1
end function
dim as test_func_ptr udt
udt.set_next() 'point get_data() to nex()
udt.get_data(udt) '' *****
udt.set_prev() 'point get_data() to pre()
udt.get_data(udt) '' *****
declare operator Procptr ( byref identifier as proctype [, any|user_proctype ] ) as internal_proctype ptr
.....
(internal_proctype has a supplementary first parameter byref as udt_name only for the member procedures of UDT udt_name)
type test_func_ptr
declare function nex(ttt as long) as ulongint
declare function pre(ttt as long) as ulongint
declare function set_next() as ulongint
declare function set_prev() as ulongint
dim get_data as function(Byref As test_func_ptr, ttt as long) as ulongint '' *****
end type
function test_func_ptr.set_next() as ulongint
this.get_data = procptr(test_func_ptr.nex) '' *****
return 1
end function
function test_func_ptr.set_prev() as ulongint
this.get_data = procptr(test_func_ptr.pre) '' *****
return 1
end function
function test_func_ptr.nex(ttt as long) as ulongint
print ttt
print "next"
return 1
end function
function test_func_ptr.pre(ttt as long) as ulongint
print ttt
print "prev"
return 1
end function
dim as test_func_ptr udt
dim as test_func_ptr udt2
udt.set_next()
udt2.set_prev()
udt2.get_data(udt2,4)
udt.get_data(udt,3)
sleep