| 04-13-2009, 04:13 AM | #1 |
so after coding modules, I feel like recoding textmacros so they have things like nesting and loops. A textmacro loop is supposed to fix that problem people have some times, have you ever created 100 rects in a map to then figure out you need to add all of them to a region? JASS:
call RegionAddRect(r, gg_rct_ar001)
call RegionAddRect(r, gg_rct_ar002)
call RegionAddRect(r, gg_rct_ar003)
call RegionAddRect(r, gg_rct_ar004)
call RegionAddRect(r, gg_rct_ar005)
...
So a textmacro loop should be able to do that. You give it numbers 1 and 4 and then it repeats the same text macro over and over again. The question is: give me syntax for that. Remember these are textmacros so it is supposed to be //! - based. JASS://! textmacro addreg takes i call RegionAddRect(r, gg_rct_ar00$i$ ) //! endtextmacro // (insert syntax to run addreg from 1 to 9 here) |
| 04-13-2009, 04:24 AM | #2 |
JASS://! runtextmacro for n to N addreg(LOOP_COUNT) //! runtextmacro addreg(LOOPCOUNT) for n to N LOOP_COUNT is the, well the integer 'n'. "for n to N" is a for-loop syntax. |
| 04-13-2009, 05:08 AM | #3 |
JASS://! runtextmaco addreg(LOOP_COUNT) while i < 10 //! runtextmaco addreg(LOOP_COUNT) until i == 9 Of course, allow the standard comparison operators. |
| 04-13-2009, 06:40 AM | #4 |
OMG add this and.. and ill abuse it more. ive stopped abusing textmacros cus u didnt add such uberness HAPPY! :D |
| 04-13-2009, 07:19 AM | #5 |
Just have it be MIN:MAX instead of a string literal. JASS://! runtextmacro name("some_arg", 0:99, "some_other_arg") |
| 04-13-2009, 08:28 AM | #6 | |
Quote:
I like this. Would also be nifty if it would recognized 99:0 and start high and subtract to the low. |
| 04-13-2009, 09:26 AM | #7 |
this solution misses an identifier for the index. |
| 04-13-2009, 12:12 PM | #8 |
maybe this is too complicated, but i would like to see something like this if you expand textmacros. JASS://! textmacro addreg takes i call RegionAddRect(r, gg_rct_ar00$i$ ) //! endtextmacro //! set i = 1 //! textloop //! runtextmacro addreg(i) //! set i = i + 1 //! exitwhen i > 9 //! endtextloop JASS://! textmacro addreg takes i call RegionAddRect(r, gg_rct_ar00$i$ ) //! endtextmacro //! textmacro times takes macro, count //! runtextmacro macro(count) //! if count > 0 then //! runtextmacro times(macro, count-1) //! endif //! endtextmacro //! runtextmacro times(macro, 9) |
| 04-13-2009, 03:32 PM | #9 | |
Quote:
You only need an identifier when declaring the text macro, or if you wanted the same index to be used in two arguments. JASS://! runtextmacro name("some_arg", 0:99, "some_other_arg") //expands to: //! runtextmacro name("some_arg", "0", "some_other_arg") //! runtextmacro name("some_arg", "1", "some_other_arg") ... //! runtextmacro name("some_arg", "99", "some_other_arg") |
| 04-13-2009, 04:15 PM | #10 |
I'd say that JASS:
//! fortextmacro(min,max,step) addreg(:iterator:)
Greez |
| 04-14-2009, 02:17 AM | #11 |
//! runtextmacro name("meh", iterator) 1 to 5 step 2
Dunno, just a random suggestion. I don't particularly care for textmacros anyway. |
| 04-14-2009, 02:58 AM | #12 |
//! for i=1 to 5 step 1 do runtextmacro addreg(i)
pascal-style! maybe without "step 1".... |
| 04-14-2009, 04:44 AM | #13 |
Code:
//!for n=0;9 call RegionAddRect(region, gg_rct_000$n$) //!endloop [edit] endloop is probably going to be tokenized; so you'd probably need something not already taken. or Maybe Code:
//!do call RegionAddRect(region, gg_rct_000$n$) //!for n=0;9 |
| 04-14-2009, 05:48 AM | #14 |
loop(start,end,step)://! loop(1,100,1) stuff //! endloop addreg example://! loop(1,9,1) //! runtextmacro addreg(i) //! endloop Alternatively, we could define what our symbol is - loop(start,end,symbol,step)://! loop(1,10,Q,1) //! runtextmacro addreg($Q$) //! endloop Alternative keywords://! textmacroloop(1,10,i,1) //! endtextmacroloop //! textloop(1,10,i,1) //! endtextloop //! macroloop(1,10,i,1) //! endmacroloop //! forloop(1,10,i,1) //! endforloop //! for(1,10,i,1) //! endfor |
| 04-14-2009, 06:33 AM | #15 |
JASS://! textloop addreg i(+1,00,09) call RegionAddRect(r, gg_rct_ar00$i$ ) //! endtextloop JASS:call RegionAddRect(r, gg_rct_ar0000 ) call RegionAddRect(r, gg_rct_ar0001 ) call RegionAddRect(r, gg_rct_ar0002 ) call RegionAddRect(r, gg_rct_ar0003 ) //etc... |
