HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Using Textmacroes with Strings

12-14-2008, 09:34 AM#1
Pyrogasm
How does one call a textmacro with a string (with quotation marks) as one of the arguments? I haven't tested compiling this because I don't have access right now, but it seems like this would go all haywire:
Collapse JASS:
//! textmacro Something takes NAME, TYPE, DEFAULT
    function Something$NAME$ takes $TYPE$ Value returns $TYPE$
        if Value != $DEFAULT$ then
            call DoSomethingWith(Value)
            return Value
        endif
        return $DEFAULT$
    endfunction
//! endtextmacro

//! call runtextmacro Something("Integer", "integer", "0")
//! call runtextmacro Something("Handle", "handle", "null")
//! call runtextmacro Something("String", "string", """")
I know on its own that code makes very little sense, but I think the general gist is there. I need to return the null string (""), but I don't know if that'll work with a textmacro.


Or can a string be == null?
12-14-2008, 12:02 PM#2
Skater
Just escape the "

//! runtextmacro Something("String", "string", "\"\"")
12-14-2008, 09:39 PM#3
Pyrogasm
Wut?
12-14-2008, 11:02 PM#4
Ammorth
For quotes to exist in a string, they need to have the escape character before them: \" == " Its for the same reason why \\ == \ and also why \n works.
12-15-2008, 01:44 AM#5
PandaMine
Yeah its a standard for most programming languages
12-15-2008, 05:09 AM#6
Pyrogasm
Oh, thanks!
12-15-2008, 07:37 AM#7
MaD[Lion]
Collapse JASS:
//!textmacro Vexorians_Hate takes CODE
$CODE$
//!endtextmacro

...

//! runtextmacro Vexorians_Hate("function hate takes nothing returns nothing\ncall BJDebugMsg(\"hate this\")\nendfunction")
...
call hate()

add more textmacro abuse pls vex
12-15-2008, 07:38 AM#8
Gorman
ummm...?

Does this work?