Tutorial: Macro Dialogs and Frames

Doc requests, organization, and submissions

Moderators: dorpond, trevor, Azhrei

User avatar
Azhrei
Site Admin
Posts: 12086
Joined: Mon Jun 12, 2006 1:20 pm
Location: Tampa, FL

Re: Tutorial: Macro Dialogs and Frames

Post by Azhrei »

Heh, well, I'll let someone using Windows ask him. :) As it's written in C# apparently (or at least, it requires .NET) I won't be downloading and using it any time soon. Although it looks like a pretty simple interface so it might make for a good test of Mono the next time I'm playing around with Kubuntu...

n3phrit
Cave Troll
Posts: 84
Joined: Mon Apr 21, 2008 7:30 am

Re: Tutorial: Macro Dialogs and Frames

Post by n3phrit »

Ok. So I have quite enough of this. MACROS are simply not working the way it should be. I spent 3 days now fidling around and most of my time was wasted to WRONG SYNTAX. I cant simply make this work. Even slightest change to code harm it somehow, if statements are almost all not working.

currently I am in NextWeaponNumber macro change.

Code: Select all

[h,if(isPropertyEmpty("Weapons")), code: {
[h: Weapons = setStrProp(Weapons, "NumWeapons", 0)]
[h: Weapons = setStrProp(Weapons, "UsedWeaponLeft", 0)]
[h: Weapons = setStrProp(Weapons, "UsedWeaponRight", 0)]
[h: numWeapons=1]}; code: {
[h: numWeapons=2]
[h: Weapons = setStrProp(Weapons, "NumWeapons", numWeapons)]
}]

[h: macro.return = numWeapons]
This is simply not working. Expected function:
Add 3 default string properties in Token property "Weapons", All 0 defaults
Getting:
Error in roll for IF option       Statement options (if any): h,if(isPropertyEmpty("Zbrane")), code       Statement body (first 200 characters): { [h: Weapons = setStrProp(Weapons, "NumWeapons", 0)] [h: Weapons = setStrProp(Weapons, "UsedWeaponLeft", 0)] [h: Weapons = setStrProp(Weapons, "UsedWeaponRight", 0)] [h: numWeapons=1]}; code: { [h: numWea

I guess the parser is not working the way it should be. Also I found strange behaviour when macro was not working due html markup, When I remove several <td>'s it went all-right. Also some html comments makes macro dont work. dont know exactly when, but it certainly do.

and the last thing, please, can you clarify somebody when exactly [h:] and [h,] should be used. I am getting really pissed and SEARCH function is NOT WORKING on this forum. GRRRRRRRRRRRRRRR!!!!!

User avatar
Rumble
Deity
Posts: 6235
Joined: Tue Jul 01, 2008 7:48 pm

Re: Tutorial: Macro Dialogs and Frames

Post by Rumble »

n3phrit wrote:Ok. So I have quite enough of this. MACROS are simply not working the way it should be. I spent 3 days now fidling around and most of my time was wasted to WRONG SYNTAX. I cant simply make this work. Even slightest change to code harm it somehow, if statements are almost all not working.

currently I am in NextWeaponNumber macro change.

Code: Select all

[h,if(isPropertyEmpty("Weapons")), code: {
[h: Weapons = setStrProp(Weapons, "NumWeapons", 0)]
[h: Weapons = setStrProp(Weapons, "UsedWeaponLeft", 0)]
[h: Weapons = setStrProp(Weapons, "UsedWeaponRight", 0)]
[h: numWeapons=1]}; code: {
[h: numWeapons=2]
[h: Weapons = setStrProp(Weapons, "NumWeapons", numWeapons)]
}]

[h: macro.return = numWeapons]
This is simply not working. Expected function:
Add 3 default string properties in Token property "Weapons", All 0 defaults
Getting:
Error in roll for IF option       Statement options (if any): h,if(isPropertyEmpty("Zbrane")), code       Statement body (first 200 characters): { [h: Weapons = setStrProp(Weapons, "NumWeapons", 0)] [h: Weapons = setStrProp(Weapons, "UsedWeaponLeft", 0)] [h: Weapons = setStrProp(Weapons, "UsedWeaponRight", 0)] [h: numWeapons=1]}; code: { [h: numWea

I guess the parser is not working the way it should be. Also I found strange behaviour when macro was not working due html markup, When I remove several <td>'s it went all-right. Also some html comments makes macro dont work. dont know exactly when, but it certainly do.

and the last thing, please, can you clarify somebody when exactly [h:] and [h,] should be used. I am getting really pissed and SEARCH function is NOT WORKING on this forum. GRRRRRRRRRRRRRRR!!!!!

Okay, hate to say it, but it's a syntax error. This should be:

Code: Select all

[h,if(isPropertyEmpty("Weapons")), code: {
[h: Weapons = setStrProp(Weapons, "NumWeapons", 0)]
[h: Weapons = setStrProp(Weapons, "UsedWeaponLeft", 0)]
[h: Weapons = setStrProp(Weapons, "UsedWeaponRight", 0)]
[h: numWeapons=1]};
{
[h: numWeapons=2]
[h: Weapons = setStrProp(Weapons, "NumWeapons", numWeapons)]
};]

[h: macro.return = numWeapons]
Note that you only put CODE in one time, before the colon in the block header. So you'd do:

h, if(isPropertyEmpty("Weapons")), code:

Code does not appear later - it is like a switch that tells the parser "everything enclosed in { } is a block of code to run; there may be multiple blocks, so pay attention).

Also, the second option for IF needs to end with a semicolon, as well. A template IF with code is:

Code: Select all

[IF(condition),CODE:
{
   [run some code here]
};
{
   [run some other code here]
};]
Finally: use h: if you only have a simple operation on the line; use h, if there are other things (like IF(), COUNT(), token(), FOREACH(), etc - basically, any branching or looping options) that go before the colon too.

n3phrit
Cave Troll
Posts: 84
Joined: Mon Apr 21, 2008 7:30 am

Re: Tutorial: Macro Dialogs and Frames

Post by n3phrit »

Ok thanks, i am going to test it tomorrow. It would be nice, if parser can handle that systax errors with something more debugable in chat window....

and one more thing. I dont know what is this html standard that is supported in dialogs and frames, but many of html directives simply dont work (like size in input fields). And It would be quite handy If there is possibility to see generated html source code, otherwise i cannot trace almost anything.

n3phrit
Cave Troll
Posts: 84
Joined: Mon Apr 21, 2008 7:30 am

Re: Tutorial: Macro Dialogs and Frames

Post by n3phrit »

I have found another bug, isPropertyEmpty() is not working,
if I try to check empty property it returns 0 instead of 1 or something cause I was not able to make condition

Code: Select all

if(isPropertyEmpty(Weapons)), code...
working. Also the documentation to this function is messy:
Returns 1 if the property is empty or 0 if it is not. An empty string ("")
will return 1 as its not an empty ptoperty.
There should be empty string with (" ") with whitespace, otherwise I dont see any reason why would "" return 0...

I have to change it to:

Code: Select all

if(getProperty(Weapons)==""), code...
and this works fine

n3phrit
Cave Troll
Posts: 84
Joined: Mon Apr 21, 2008 7:30 am

Re: Tutorial: Macro Dialogs and Frames

Post by n3phrit »

deleted...my fault
Last edited by n3phrit on Sun Dec 21, 2008 6:35 am, edited 1 time in total.

Craig
Great Wyrm
Posts: 2107
Joined: Sun Jun 22, 2008 7:53 pm
Location: Melbourne, Australia

Re: Tutorial: Macro Dialogs and Frames

Post by Craig »

n3phrit wrote:I have found another bug, isPropertyEmpty() is not working,
if I try to check empty property it returns 0 instead of 1 or something cause I was not able to make condition

Code: Select all

if(isPropertyEmpty(Weapons)), code...
working. Also the documentation to this function is messy:
Returns 1 if the property is empty or 0 if it is not. An empty string ("")
will return 1 as its not an empty ptoperty.
There should be empty string with (" ") with whitespace, otherwise I dont see any reason why would "" return 0...

I have to change it to:

Code: Select all

if(getProperty(Weapons)==""), code...
and this works fine
Its a bit confusing is you are not used to programing but the documentation is correct. Empty means nothing (or null in java and several other programing languages). An empty string is something so if the property contains an empty string its not nothing (and hence its not empty because it contains something). And my above explanation probably did not help.

Think of isPropertyEmpty() returning 1 if nothing has been assigned to the property or 0 if something has been assigned to the property. Since the only way you can get an empty string into a property is by assigning it to the property isPropertyEmpty() will return 0 for an empty string.

n3phrit
Cave Troll
Posts: 84
Joined: Mon Apr 21, 2008 7:30 am

Re: Tutorial: Macro Dialogs and Frames

Post by n3phrit »

An empty string is something so if the property contains an empty string its not nothing (and hence its not empty because it contains something
for usability purposes it would be better, if empty string was considered empty, however it is javaish normal. In php empty string is considered empty thus "" returns true if asked for it. I simply think, that in a macro world without variable casting possiblity it is simply bad.

if i had an option to have

Code: Select all

num = (int) getStrPropt(foo, bar)
than ok, but I dont see really any benefit of considering "" as an non-empty value...

I am PHP and Ruby advanced programmer :)

p.s. and NULL is something different than empty string...

Craig
Great Wyrm
Posts: 2107
Joined: Sun Jun 22, 2008 7:53 pm
Location: Melbourne, Australia

Re: Tutorial: Macro Dialogs and Frames

Post by Craig »

n3phrit wrote:
p.s. and NULL is something different than empty string...
And this is exactly the point. The property is empty if it is a null, if it is not a null it is not empty. The reason it is not isPropertyNull is because the macro language knows nothing of null. Its isPropertyEmpty, not isStringEmpty so returning 1 if the property contains a zero length string would be semantically wrong. Its use is simply to check if the property is null or not.

n3phrit
Cave Troll
Posts: 84
Joined: Mon Apr 21, 2008 7:30 am

Re: Tutorial: Macro Dialogs and Frames

Post by n3phrit »

It may sounds strange, but than the function should be called
isPropertyInitialized(), as now it only returns 1 if it was not used!

Because now, if you set property to something, no matter what, since that moment it won't be considered empty under any circumstances! Even if you edit it in your token properties and delete all content from it. I used to test the value of property, then deleted it and tried again. This function is not good for such operations.

isPropertyEmpty() should return true if content of property at ANY TIME contains
nothing independent of its scalar type.

Craig
Great Wyrm
Posts: 2107
Joined: Sun Jun 22, 2008 7:53 pm
Location: Melbourne, Australia

Re: Tutorial: Macro Dialogs and Frames

Post by Craig »

n3phrit wrote:It may sounds strange, but than the function should be called
isPropertyInitialized(), as now it only returns 1 if it was not used!
Because now, if you set property to something, no matter what, since that moment it won't be considered empty under any circumstances!
If you call resetProperty() then yes it will be considered empty again.
Even if you edit it in your token properties and delete all content from it. I used to test the value of property, then deleted it and tried again. This function is not good for such operations.
I can't use a hammer to change a light bulb either, but thats because I chose the wrong tool for the job, not because the hammer is broken.
isPropertyEmpty() should return true if content of property at ANY TIME contains
nothing independent of its scalar type.
No it shouldn't, let it go. "Something" is not empty full stop. If you want to check if the scalar type is empty then check the scalar type there are ways to do that. This is the way many computer languages work, if you check if a reference points to something or not you NEVER derefernce it and examine the value, NEVER. I will repeat the functions is isPropertyEmpty() not isPropertysValueEmpty().

n3phrit
Cave Troll
Posts: 84
Joined: Mon Apr 21, 2008 7:30 am

Re: Tutorial: Macro Dialogs and Frames

Post by n3phrit »

ok, I didnt noticed resetProperty() function, but still think that for many GM especially not programmers this will be issue. I hear a java programmer from you, not a macro designer :) no offense.

n3phrit
Cave Troll
Posts: 84
Joined: Mon Apr 21, 2008 7:30 am

Re: Tutorial: Macro Dialogs and Frames

Post by n3phrit »

Following code is not working, SUFFIXED, UNSUFFIXED seems to be broken.
varsFromStrProp accepts only 1 parameter...

Code: Select all

  [h, macro("GetWeapon@this"): 1]
  [h: wProp = macro.return]
  [h: varsFromStrProp(wProp, "SUFFIXED") ]
returns

Code: Select all

varsFromStrProp() requires 1 parameters

User avatar
PyroMancer2k
Dragon
Posts: 925
Joined: Thu Sep 11, 2008 2:04 pm

Re: Tutorial: Macro Dialogs and Frames

Post by PyroMancer2k »

n3phrit wrote:Following code is not working, SUFFIXED, UNSUFFIXED seems to be broken.
varsFromStrProp accepts only 1 parameter...

Code: Select all

  [h, macro("GetWeapon@this"): 1]
  [h: wProp = macro.return]
  [h: varsFromStrProp(wProp, "SUFFIXED") ]
returns

Code: Select all

varsFromStrProp() requires 1 parameters
That's cause those changes never went in. You just enter the variable name like so varsFromStrProp(wProp) . It's kinda annoying that the documentation was updated without verifying that the actually changes were in the build. People constantly having trouble with this the other similar non-implemented items.

Craig
Great Wyrm
Posts: 2107
Joined: Sun Jun 22, 2008 7:53 pm
Location: Melbourne, Australia

Re: Tutorial: Macro Dialogs and Frames

Post by Craig »

n3phrit wrote:ok, I didnt noticed resetProperty() function, but still think that for many GM especially not programmers this will be issue. I hear a java programmer from you, not a macro designer :) no offense.
Heh none taken, but the function to check if a property was empty was requested by several non programmers who were having errors occur during macros :)

Post Reply

Return to “Documentation Requests/Discussion”