I'll quick run this by you to see if I understand it right, but I think I do. I'm writing a simplistic library for pascal/lua to handle the CRT functionality of Freepascal. So I've written a function supporting multiple types, integer and string, and use that to set the text color of the console. (IE, the foreground color)

[pascal]function lua_TextColor(L: PLua_State) : integer; cdecl;
var n,i: integer;
c: byte;
s: string;
const colors: array[0..15] of string = ('black','blue','green','cyan','red','magenta','br own','lightgray','darkgray',
'lightblue','lightgreen','lightcyan','lightred','l ightmagenta','yellow','white');
begin
n := lua_gettop(L);
assert(n = 1, 'Number of arguments to TextColor must be 1.');
lua_TextColor := 0;

if lua_isstring(L,1) then begin
s := lua_tostring(L,1);
c := 15; // The default color.
for i := 0 to 15 do
if lowercase(s) == colors[i] then begin
c := i;
break;
end;
end else if lua_isnumber(L,1) then
c := byte(min(lua_tointeger(L,1),15));
else assert(false,'Error, invalid type passed to TextColor!');

assert((c >= 0)and(c < 16), 'TextColor must be called with a value equal to, or between 0 and 15.');
TextColor(c);
end;[/pascal]

So eventually I want to register a library, not just a function. Referencing this page I think I know how to do it, save one thing. Must I include the ending (nil,nil) entry? And how do I define a constant 2D array in FreePascal? I never was good at constant multidepth arrays. :roll: Like this?
Code:
const crtlib&#58; array of array of variant = &#40;&#40;"KeyPressed", @lua_KeyPressed&#41;, &#40;"TextColor", @lua_TextColor&#41;, &#40;nil,nil&#41;&#41;;
Or, is this impossible with FPC? Seems like a messy array of variants to me. :? Can I actually do this in pascal, or not? I'm guessing that, as a long shot, I could register it the normal way as "crt.TextColor" rather than just "TextColor".