What I am looking for is a function that gets a list of the active variables (the names, rather than contents) and outputs them to a string list.
This would be useful for self creating jsons where all you have to input are the list of fields as part of your original input, and the code creates the rest - the biggest advantage being you just have to add to the input to add to the json.
I am working round it with a reference json right now, containing the list of fields used - but it would be nice to be able to self generate.
[1.3b70] get active variables
Moderators: dorpond, trevor, Azhrei, giliath, jay, Mr.Ice
-
- Great Wyrm
- Posts: 1343
- Joined: Sun Aug 12, 2007 10:49 am
- Location: Midsomer Norton, (Near Bath), UK
- Contact:
[1.3b70] get active variables
Cweord
This message has been spell checked by Freudcheck - any mistakes are purley a figment of your imagination.
-------
My Tokens Directory
http://gallery.rptools.net/v/contrib/Cw ... er_Tokens/
This message has been spell checked by Freudcheck - any mistakes are purley a figment of your imagination.
-------
My Tokens Directory
http://gallery.rptools.net/v/contrib/Cw ... er_Tokens/
- CoveredInFish
- Demigod
- Posts: 3104
- Joined: Mon Jun 29, 2009 10:37 am
- Location: Germany
- Contact:
Re: [1.3b70] get active variables
Maybe this could be another topic for Wiki: getInfo() like getInfo("macro") or something like that.
Re: [1.3b70] get active variables
I'm a little fuzzy on what you're saying. What is the scope of your active variables? Do you mean a list of variables defined in a macro? Or defined on a token? If you mean defined on a token then there is a function for that (or 2), Wiki: getMatchingProperties() and Wiki: getMatchingLibProperties() will list the properties on a token given a filter. To list the all use ".*". The result will return the property names but all in lower case format, but will include "hidden" variables too. Using Wiki: getAllPropertyNames() will return (in the proper case) of the campaign token property names defined for the campaign given the property type name.Cweord wrote:What I am looking for is a function that gets a list of the active variables (the names, rather than contents) and outputs them to a string list.
This would be useful for self creating jsons where all you have to input are the list of fields as part of your original input, and the code creates the rest - the biggest advantage being you just have to add to the input to add to the json.
I am working round it with a reference json right now, containing the list of fields used - but it would be nice to be able to self generate.
Downloads:
- Notepad++ MapTool addon
- RPEdit details (v1.3)
- Coding Tips: Modularity and Design
- Videos: Macro Writing Tools
- CoveredInFish
- Demigod
- Posts: 3104
- Joined: Mon Jun 29, 2009 10:37 am
- Location: Germany
- Contact:
Re: [1.3b70] get active variables
If I understood OP right he wants all local variables inside the current macro.
The intended usage is to wrap all variables automatically in a json (variableName->variableValue) for easier parameter submitting to other functions/macros. (Personally I dont find it bad to create these json by hand for tidying up and not submitting unneeded information).
I myself like to see such a functions for its debugging capabilities.
The intended usage is to wrap all variables automatically in a json (variableName->variableValue) for easier parameter submitting to other functions/macros. (Personally I dont find it bad to create these json by hand for tidying up and not submitting unneeded information).
I myself like to see such a functions for its debugging capabilities.
Re: [1.3b70] get active variables
I too wish I could create scopes. I'm a coldfusion programmer and I defined every single one of my variables in a scope (local being L.varname) where passing L would give me access to all my local variables and it definitely helped in debugging. But other than defining the variables in my own custom scope there is no way in coldfusion to automatically get a list of locally defined variables. I don't see that as a common practice.
For MT, I've used in the past, but shy away from it now, Wiki: varsFromStrProp() to define a bunch of local variables quickly. I don't do it so much now because it's not evident what variables are accessible with in that segment of code, especially if the prop string is passed to the macro or pulled from a property.
For MT, I've used in the past, but shy away from it now, Wiki: varsFromStrProp() to define a bunch of local variables quickly. I don't do it so much now because it's not evident what variables are accessible with in that segment of code, especially if the prop string is passed to the macro or pulled from a property.
Last edited by aliasmask on Wed Jul 28, 2010 11:26 am, edited 1 time in total.
Downloads:
- Notepad++ MapTool addon
- RPEdit details (v1.3)
- Coding Tips: Modularity and Design
- Videos: Macro Writing Tools
Re: [1.3b70] get active variables
(Love the new avatar, alias. )
There is no way to get a list of "active" variables per se. If you wanted such a list, you would need to maintain it yourself. As alias points out, using L.* for local variables would at least help by letting you know at a glance whether a variable is expected to be local, but it doesn't help in retrieving a list of variable names.
There is no way to get a list of "active" variables per se. If you wanted such a list, you would need to maintain it yourself. As alias points out, using L.* for local variables would at least help by letting you know at a glance whether a variable is expected to be local, but it doesn't help in retrieving a list of variable names.
Re: [1.3b70] get active variables
Thanks. My last avatar was my last PC Zuul... now I have a new PC and I added some PSP glitz to it with some runes in the background using the Levitated Rune font. It actually spells out my name ). You can find a similar image in my gallery. Here's the base image I used for the token tool:Azhrei wrote:(Love the new avatar, alias. )
- Attachments
-
- rpAvatar.png (86.21 KiB) Viewed 805 times
Downloads:
- Notepad++ MapTool addon
- RPEdit details (v1.3)
- Coding Tips: Modularity and Design
- Videos: Macro Writing Tools
Re: [1.3b70] get active variables
Which is why he posted it in the feat request section . I second his request.Azhrei wrote: There is no way to get a list of "active" variables per se. If you wanted such a list, you would need to maintain it yourself. As alias points out, using L.* for local variables would at least help by letting you know at a glance whether a variable is expected to be local, but it doesn't help in retrieving a list of variable names.
GETTING STARTED WITH MAPTOOLS - TUTORIALS, DOCS, VIDEOS, TOOLS, ETC
DISCORD (the new MT forum!)
My stuff
Excel Tools: Table and Light editors
MT Tools: Bag of Tricks: Tools for Maptool, Dungeon Builder I, Dungeon Builder II,onMouseOverEvent.
Frameworks: Dark Heresy, Rogue Trader, Deathwatch, Black Crusade, Only War, SET Card Game, RoboRally
Wiki: Debugging Tutorial, Speed Up Your Macros, Working With Two CODE Levels, Shortcut Keys, Avoiding Stack Overflow, READ THIS
DISCORD (the new MT forum!)
My stuff
Excel Tools: Table and Light editors
MT Tools: Bag of Tricks: Tools for Maptool, Dungeon Builder I, Dungeon Builder II,onMouseOverEvent.
Frameworks: Dark Heresy, Rogue Trader, Deathwatch, Black Crusade, Only War, SET Card Game, RoboRally
Wiki: Debugging Tutorial, Speed Up Your Macros, Working With Two CODE Levels, Shortcut Keys, Avoiding Stack Overflow, READ THIS
Re: [1.3b70] get active variables
For macros where I will deal with and process several token properties, I usually do this:
- Define a list of all the property names
- Set local variables with a prefix with the contents of the token properties
- do some processing to the local variables
- set the properties with a loop.
You could do much the same thing with local variables only. I just found it easier to maintain a list, than repeating each option individually.
For example:
- Define a list of all the property names
- Set local variables with a prefix with the contents of the token properties
- do some processing to the local variables
- set the properties with a loop.
You could do much the same thing with local variables only. I just found it easier to maintain a list, than repeating each option individually.
For example:
Code: Select all
[H: varList = "var1, var2, var3" ]
[FOREACH( var, varList): set( var , "" )]<!-- to initialise. -->
[json.pkg = "{}" ]<!-- empty json container -->
[FOREACH( var, varList): json.set( json.pkg , var, eval( var ) )]<!-- package into a json object -->
[FOREACH( var, varList): setProperty( "bio."+var , eval( var ) )]<!-- set some properties. -->
"The trouble with communicating is believing you have achieved it"
[ d20 StatBlock Importer ] [ Batch Edit Macros ] [ Canned Speech UI ] [ Lib: Math ]
[ d20 StatBlock Importer ] [ Batch Edit Macros ] [ Canned Speech UI ] [ Lib: Math ]