HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Running textmacros inside functions?

08-01-2008, 04:25 PM#1
Vestras
Is it possible? It gives me syntax errors.
08-01-2008, 04:28 PM#2
Alexander244
It's possible.

Can we see the macros?
08-01-2008, 04:38 PM#3
Vestras
Collapse JASS:
function test1 takes nothing returns nothing
  call BJDebugMsg("1")
endfunction

function test2 takes nothing returns nothing
  call BJDebugMsg("2")
endfunction

//! textmacro testmacro takes FUNC, INSTANCE
   function whenrunned$INSTANCE$ takes nothing returns nothing
     call $FUNC$
   endfunction
//! endtextmacro

function runtext takes nothing returns nothing
  //! runtextmacro testmacro("test1", "1")
  //! runtextmacro testmacro("test1", "2")
endfunction

function InitTrig takes nothing returns nothing
   local trigger t = CreateTrigger()
   call TriggerAddAction(t, function runtext)
endfunction
08-01-2008, 04:42 PM#4
Alexander244
You can't have a function in a function.

This is what you want I think:
Collapse JASS:
//! textmacro testmacro takes FUNC
     call $FUNC$()
//! endtextmacro
08-01-2008, 04:45 PM#5
Fireeye
The problem in this case is, that you write a function inside a function ...
The entire thing should be
Collapse JASS:
function test1 takes nothing returns nothing
  call BJDebugMsg("1")
endfunction

function test2 takes nothing returns nothing
  call BJDebugMsg("2")
endfunction

//! textmacro testmacro takes FUNC, INSTANCE
   call $FUNC$()
//! endtextmacro

function runtext takes nothing returns nothing
  //! runtextmacro testmacro("test1", "1")
  //! runtextmacro testmacro("test1", "2")
endfunction

function InitTrig takes nothing returns nothing
   local trigger t = CreateTrigger()
   call TriggerAddAction(t, function runtext)
endfunction

---Edit---
Darn, Alexander was faster ...