Command Buffer "Loop Command"
Moderator: InsideQC Admins
3 posts
• Page 1 of 1
Command Buffer "Loop Command"
Any vague ideas on how a console command could be made to do a "for" loop or a "do while" loop?
The night is young. How else can I annoy the world before sunsrise?
Inquisitive minds want to know ! And if they don't -- well like that ever has stopped me before ..
-

Baker - Posts: 3666
- Joined: Tue Mar 14, 2006 5:15 am
cmd_registercmd("while", mywhile_f);
void mywhile_f(void)
{
if (evaluate(argv(1)) == false)
cbuf_addtext(va("%s\n%s %s\n", argv(2), argv(0), args());
}
would probably do an effective enough while loop. quote the body, or use a single alias for that.
failing that you can always peek ahead in the cbuf and invoke Cmd_Execute directly on the commands up until your 'stop' directive, thus meaning you can add continue/break properly.
or just splice the cbuf execution code directly for intermingling of if/for/do-while/while/switch/etc.
if that's not overkill
void mywhile_f(void)
{
if (evaluate(argv(1)) == false)
cbuf_addtext(va("%s\n%s %s\n", argv(2), argv(0), args());
}
would probably do an effective enough while loop. quote the body, or use a single alias for that.
failing that you can always peek ahead in the cbuf and invoke Cmd_Execute directly on the commands up until your 'stop' directive, thus meaning you can add continue/break properly.
or just splice the cbuf execution code directly for intermingling of if/for/do-while/while/switch/etc.
if that's not overkill
- Spike
- Posts: 2892
- Joined: Fri Nov 05, 2004 3:12 am
- Location: UK
3 posts
• Page 1 of 1
Who is online
Users browsing this forum: No registered users and 1 guest