| 390 | } |
| 391 | |
| 392 | char *lookup(char *n, int levels) // find value of ident referenced with $ in exp |
| 393 | { |
| 394 | if(levels > 1) n = exchangestr(n, lookup(newstring(n), min(levels - 1, CSLIMIT_LOOKUPNESTING - 1))); // nested ("$$var"), limit to three levels |
| 395 | ident *id = idents->access(n); |
| 396 | if(id) switch(id->type) |
| 397 | { |
| 398 | case ID_VAR: { string t; itoa(t, *id->storage.i); return exchangestr(n, t); } |
| 399 | case ID_FVAR: return exchangestr(n, floatstr(*id->storage.f)); |
| 400 | case ID_SVAR: { { if(id->getfun) ((void (__cdecl *)())id->getfun)(); } return exchangestr(n, *id->storage.s); } |
| 401 | case ID_ALIAS: return exchangestr(n, id->action); |
| 402 | } |
| 403 | conoutf("unknown alias lookup: %s", n); |
| 404 | scripterr(); |
| 405 | return n; |
| 406 | } |
| 407 | |
| 408 | char *parseword(const char *&p, int arg, int *infix, int rec) // parse single argument, including expressions |
| 409 | { |