wc3campaigns
WC3C Homepage - www.wc3c.netUser Control Panel (Requires Log-In)Engage in discussions with other users and join contests in the WC3C forums!Read one of our many tutorials, ranging in difficulty from beginner to advanced!Show off your artistic talents in the WC3C Gallery!Download quality models, textures, spells (vJASS/JASS), systems, and scripts!Download maps that have passed through our rigorous approval process!

Go Back   Wc3C.net > Warcraft III Modding > Developer's Corner > Triggers & Scripts
User Name
Password
Register Rules Get Hosted! Chat Pastebin FAQ and Rules Members List Calendar



Reply
 
Thread Tools Search this Thread
Old 06-25-2009, 03:00 AM   #1
Ignitedstar
Moderator
 
Ignitedstar's Avatar


RP Section Moderator
 
Join Date: Jul 2005
Posts: 1,755

Ignitedstar has a spectacular aura about (102)Ignitedstar has a spectacular aura about (102)Ignitedstar has a spectacular aura about (102)Ignitedstar has a spectacular aura about (102)

Send a message via MSN to Ignitedstar Send a message via Yahoo to Ignitedstar
Default Question: Textmacros are...?

Okay, I can use scopes and libraries just fine, but I'm seeing textmacros be used more and more, yet I have no idea what exactly they are for. What is it? If it's too complicated to explain what exactly it is, I would just like to know what people use it for. I know that UnitProperties uses it, but I can't really use it if I don't know what textmacros are.
__________________
Current Activity: It's a secret, now.
Evaluation: I actually logged in?!?!
"If I speak in the tongues of men and of angels, but have not love,
I am only a resounding gong or a clanging cymbal.
If I have the gift of prophecy and can fathom all mysteries and all knowledge,
and if I have a faith that can move mountains, but have not love, I am nothing."

1 Corinthians 13:1-2

Current Works:
None.
Ignitedstar is offline   Reply With Quote
Sponsored Links - Login to hide this ad!
Old 06-25-2009, 03:19 AM   #2
moyack
Evil Emoticon
 
moyack's Avatar


Respected User
Project Leader: PoC
 
Join Date: Jan 2006
Posts: 3,279

Submissions (17)

moyack is a splendid one to behold (666)moyack is a splendid one to behold (666)moyack is a splendid one to behold (666)moyack is a splendid one to behold (666)

AI Tournament #2 - 2nd PlaceHero Contest - Second place

Send a message via MSN to moyack
Default

For example you have a set of functions which share a similar (repetitive) shape but changes some argument types or parts of them, then you can use a textmacro to save writing time.

Example (from the JassHelper manual)

Collapse JASS:
    //! textmacro GetSetHandle takes TYPE, TYPENAME
        function GetHandle$TYPENAME$ takes handle h, string k returns $TYPE$
            return GetStoredInteger(udg_handlevars, I2S(H2I(h)), k)
            return null
        endfunction
        function SetHandle$TYPENAME$ takes handle h, string k, $TYPE$ v returns nothing
            call StoredInteger(udg_handlevars,I2S(H2I(h)),k, H2I(v))
        endfunction
    //! endtextmacro

    //! runtextmacro GetSetHandle("unit","Unit")
    //! runtextmacro GetSetHandle("location","Loc")
    //! runtextmacro GetSetHandle("item","Item")

(the example will be deprecated when patch 1.24 becomes release) As you can see, instead of writing the same for unit, location and item, we set the template of the functions and jassHelper will write the code for us.

Last edited by moyack : 06-25-2009 at 03:22 AM.
moyack is offline   Reply With Quote
Old 06-25-2009, 03:34 AM   #3
fX_
User
 
fX_'s Avatar
 
Join Date: Jan 2007
Posts: 528

Submissions (2)

fX_ will become famous soon enough (38)fX_ will become famous soon enough (38)

Default

textmacro is a way to write code easily by reducing the encryption of codes with iterated structure to a single line.
a general structure of code is designated with its significant variable elements defined.
the structure is iterated in its every implementation, with different valuations of the significant variable elements according to incident.
the elements are arguments of the textmacro as strings: the encryption of the code you would write.

textmacro aTextmecro takes (structure)element1, element2, element3, ..., elementN
example:
//declare
Collapse JASS:
//!textmacro aTextmacro takes type, name
//code of textmacro starts here
globals
$type$ $name$
endglobals
//code of textmacro ends here
//declare end
//!endtextmacro
implementing this textmacro - with use of different kinds of $name$s and $types$ - will produce/encrypt code of its structure and with different valuations of of name and type.
example:
Collapse JASS:
//! runtextmacro aTextmacro("integer", "myIntegerVariable")
results in:
Collapse JASS:
globals
integer myIntegerVariable
endglobals

example2:
Collapse JASS:
//! runtextmacro aTextmacro("real", "myRealVariable")
results in:
Collapse JASS:
globals
real myRealVariable
endglobals

the code structures in both examples are instances or incidents of the general structure:
Collapse JASS:
globals
$type$ $name$ //declaration of global variable with such a type and such a name
endglobals
particularly for integer and real variables with appropriated names, respectively


so textmacro just make it easier to write things

Last edited by fX_ : 06-25-2009 at 03:38 AM.
fX_ is offline   Reply With Quote
Old 06-25-2009, 03:47 PM   #4
Ignitedstar
Moderator
 
Ignitedstar's Avatar


RP Section Moderator
 
Join Date: Jul 2005
Posts: 1,755

Ignitedstar has a spectacular aura about (102)Ignitedstar has a spectacular aura about (102)Ignitedstar has a spectacular aura about (102)Ignitedstar has a spectacular aura about (102)

Send a message via MSN to Ignitedstar Send a message via Yahoo to Ignitedstar
Default

Oh, thanks you guys. I keep forgetting that the JassHelper Manual exists... I will read it thoroughly later. It will be able to explain to me what structs are and how to use them (I've messed that one up too many times to count).

I especially like this example:

Collapse JASS:
    //! textmacro bye
    call BJDebugMsg("1")
    call BJDebugMsg("2")
    call BJDebugMsg("3")
    //! endtextmacro

    function test takes nothing returns nothing
        //! runtextmacro bye()
        //! runtextmacro bye()
    endfunction

Hmm... Does this mean that I can use a textmacro to make private globals, too? And, by the looks it, it may be able to make structs, too?

Er... I don't know, though. By the looks it, it looks like I'd have to use hundreds of textmacros to actually make it worthwhile in saving space (like UnitProperties). Unless every byte of code truly counts. I was thinking of using textmacros like the above as a general variable template for repetitive things (like spells), but if I have to set each variable with a line of code, I'm not really saving space... Or am I? I guess textmacros are for convenience and/or saving space depending what it's used for.

Well, in that case, I suppose textmacros are for much bigger things, which may explain why they are coming up more often. Okay, I guess I understand. Thanks.
__________________
Current Activity: It's a secret, now.
Evaluation: I actually logged in?!?!
"If I speak in the tongues of men and of angels, but have not love,
I am only a resounding gong or a clanging cymbal.
If I have the gift of prophecy and can fathom all mysteries and all knowledge,
and if I have a faith that can move mountains, but have not love, I am nothing."

1 Corinthians 13:1-2

Current Works:
None.

Last edited by Ignitedstar : 06-25-2009 at 03:48 PM.
Ignitedstar is offline   Reply With Quote
Old 06-25-2009, 03:55 PM   #5
Vexorian
Free Software Terrorist
 
Vexorian's Avatar


Technical Director
 
Join Date: Apr 2003
Posts: 14,898

Submissions (37)

Vexorian has a reputation beyond repute (1062)Vexorian has a reputation beyond repute (1062)Vexorian has a reputation beyond repute (1062)Vexorian has a reputation beyond repute (1062)Vexorian has a reputation beyond repute (1062)Vexorian has a reputation beyond repute (1062)Vexorian has a reputation beyond repute (1062)

Hero Contest #3 - 2nd Place

Default

textmacros are just a way to do copy and paste automatically. You 'can' have private globals inside textmacros, as long as the place in which you run the textmacro allows private globals. This logic works for just about everything...

They are also very good at making your code ugly.
__________________
Zoom (requires log in)Wc3 map optimizer 5.0
Someone should fix .wav sound in this thing.
Zoom (requires log in)JassHelper 0.A.2.A
Turns your simple code into something that is complicated enough to work.
Faster != more useful
Vexorian is offline   Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off


All times are GMT. The time now is 11:05 PM.


Affiliates
The Hubb The JASS Vault Clan WEnW Campaign Creations Clan CBS GamesModding Flixreel Videos

Powered by vBulletin (Copyright ©2000 - 2019, Jelsoft Enterprises Ltd).
Hosted by www.OICcam.com
IT Support and Services provided by Executive IT Services