| 1023 | //COMMANDN(if, ifthen, "sss"); // CB seriously trips over this one ;) |
| 1024 | |
| 1025 | void loopa(char *var, int *times, char *body) |
| 1026 | { |
| 1027 | if(*times > CSLIMIT_ITERATION) { cslimiterr("loop iterations"); return; } |
| 1028 | int t = *times; |
| 1029 | if(t<=0) return; |
| 1030 | ident *id = newident(var, execcontext); |
| 1031 | if(id->type!=ID_ALIAS) return; |
| 1032 | char *buf = newstring("0", 16); |
| 1033 | pushident(*id, buf); |
| 1034 | loop_level++; |
| 1035 | execute(body); |
| 1036 | loop_skip = false; |
| 1037 | if(loop_break) loop_break = false; |
| 1038 | else |
| 1039 | { |
| 1040 | loopi(t-1) |
| 1041 | { |
| 1042 | if(buf != id->action) |
| 1043 | { |
| 1044 | if(id->action != id->executing) delete[] id->action; |
| 1045 | id->action = buf = newstring(16); |
| 1046 | } |
| 1047 | itoa(id->action, i+1); |
| 1048 | execute(body); |
| 1049 | loop_skip = false; |
| 1050 | if(loop_break) |
| 1051 | { |
| 1052 | loop_break = false; |
| 1053 | break; |
| 1054 | } |
| 1055 | } |
| 1056 | } |
| 1057 | popident(*id); |
| 1058 | loop_level--; |
| 1059 | } |
| 1060 | COMMANDN(loop, loopa, "sis"); |
| 1061 | |
| 1062 | void whilea(char *cond, char *body) |