PDA

View Full Version : Coding Problem (Macro Substitution in C++)



dulux-oz
May 25th, 2013, 08:42
Hi Guys,

Got a small coding problem. In C++ it would be a simple macro substitution (ie MacroName with the operands "&" and "." eg "&MacroName.)". However, I can't seem to get this straight - any help greatly appreciated.

Code:
local oMacro = "window.objectName" .. target[1];
oMacro.functionCall();

Notes:
(1) target[1] is set properly
(2) Error message = "attempt to call field 'functionCall' (a nil value)"

Cheers

Trenloe
May 25th, 2013, 17:06
I don't think you can use an Object whose name is set in a string.

e.g. the following code will give a similar error to what you're getting:

local oMacro = "Debug";

oMacro.chat("Hello");

Whereas the following works fine:

local oMacro = Debug;

oMacro.chat("Hello");

I'm not sure if there is any way to convert a string "Debug", for example, into the actual Object Debug.