kingkingyyk3
Visitor (Welcome to the Jungle, Baby!)
- Reaction score
- 216
Is it possible to make a code variable with array?
struct Code
code whatever
endstruct
globals
Code array codes[SIZE]
endglobals
function Whatever [...]
set codes[1] = Code.create()
set codes[2] = Code.create()
set codes[1].whatever = someCode
set codes[2].whatever = someOtherCode
endfunction
library Loller
function interface Callable takes nothing returns nothing
globals
private Callable array Funcs
private integer N = 0
endglobals
function AddFunctionToCall takes Callable c returns nothing
set Funcs[N] = c
set N = N + 1
endfunction
function CallAll takes nothing returns nothing
local integer i = 0
loop
exitwhen i == N
call Funcs<i>.evaluate()
set i = i + 1
endloop
endfunction
endlibrary
scope TestLoller initializer Init
private function A takes nothing returns nothing
call BJDebugMsg("A")
endfunction
private function B takes nothing returns nothing
call BJDebugMsg("B")
endfunction
private function C takes nothing returns nothing
call BJDebugMsg("C")
endfunction
private function Init takes nothing returns nothing
call AddFunctionToCall(A)
call AddFunctionToCall(B)
call AddFunctionToCall(C)
call CallAll()
endfunction
endscope
</i>
Oh... Stupid me.Artificial said:@trb92
You can't use codes as non-static struct members, as those compile to normal arrays.