Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

input() PROPS option no longer works. #1278

Closed
aliasmask opened this issue Feb 15, 2020 · 16 comments
Closed

input() PROPS option no longer works. #1278

aliasmask opened this issue Feb 15, 2020 · 16 comments
Assignees
Labels
bug feature Adding functionality that adds value macro changes This issue adds or changes macro functions. Extra work is required (testing, wiki, code editor) tested This issue has been QA tested by someone other than the developer.

Comments

@aliasmask
Copy link

aliasmask commented Feb 15, 2020

Describe the bug
I'm getting an error in alpha 6 that I don't get in 1.5.12. Apparently the PROPS option no longer works. Gives null pointer exception error.

To Reproduce
[input("test|one=1;two=2;|Test|props")]

Expected behavior
Should give me fields "one" and "two" with their values.

MapTool Info

  • Version: 1.6.0-alpha-6

Other
I thought alpha 6 and 1.5.12 was the same build, but with html5 stuff. I do recall mention a change to input() to include json options. Maybe that change was implemented in alpha 6 and has a bug in it.

@aliasmask aliasmask added the bug label Feb 15, 2020
@Phergus Phergus changed the title Alpha 6 input() PROPS option no longer works. input() PROPS option no longer works. Feb 15, 2020
@Phergus
Copy link
Contributor

Phergus commented Feb 15, 2020

Not the same build at all.

@Phergus
Copy link
Contributor

Phergus commented Feb 15, 2020

@Merudo Appears to be a casualty of the input() changes.

@aliasmask
Copy link
Author

BTW, having a json option for "props" where it uses the key value for the label and value for the data would be awesome. Then I could have multiple word labels.

@Merudo
Copy link
Member

Merudo commented Feb 15, 2020

@aliasmask it might be doable. What do you suggest the option be called?

@aliasmask
Copy link
Author

aliasmask commented Feb 15, 2020

I figured it just keep the PROPS option and just note if the format is a JSON object rather than a string prop then it just use that.

I would hate to try and write the raw json part out would likely always use strformat to put in the json. But maybe it's easier to specify it as an option like type=json. So, given the above:

[H: a = json.set("{}","one",1"two",2)]
[H: input(strformat("test|%{a}|Test|PROPS|type=json"))]

@aliasmask
Copy link
Author

aliasmask commented Feb 15, 2020

I think if it could determine the type between the |'s, type=json would actually specify the return type. So, you could have "a" as a string prop and test would return a json object. Going the other way doesn't work well with the limitations of string props, ie a is a json and test is a string prop.

@Merudo
Copy link
Member

Merudo commented Feb 15, 2020

So there would be two parameters, one for the values to display and one for the return type?

Or do you suggest the type for the values to display be automatically determined?

Merudo added a commit to Merudo/maptool that referenced this issue Feb 15, 2020
- Fix props type not working with input()
- Add option WIDTH to props. It works the same as WIDTH for text, except it defaults to 14 instead of 16
- Default behavior of props is left unchanged compared to 1.5.12
- Close RPTools#1278
@Merudo
Copy link
Member

Merudo commented Feb 15, 2020

PR #1280 fixes the bug with PROPS.

@Phergus Phergus added documentation needed Missing, out-of-date or bad documentation macro changes This issue adds or changes macro functions. Extra work is required (testing, wiki, code editor) labels Feb 15, 2020
@Phergus
Copy link
Contributor

Phergus commented Feb 15, 2020

New Option for PROPS type: WIDTH . Same as for TEXT with a default of 14.

@Phergus
Copy link
Contributor

Phergus commented Feb 15, 2020

Tested. PROPS input type working as expected. New WIDTH option working.

@Phergus Phergus added the tested This issue has been QA tested by someone other than the developer. label Feb 15, 2020
Merudo added a commit to Merudo/maptool that referenced this issue Feb 15, 2020
- Add json support to input() props: a json object can now hold the labels and values instead of a string property list
- Remove ParserException try/catch for cases where no ParserException could be thrown
- Discussed in RPTools#1278

- Example:
[H: a = json.set("{}","one",1,"two",2)]
[H: input(strformat("test|%{a}|Test|PROPS"))]
@Merudo
Copy link
Member

Merudo commented Feb 15, 2020

BTW, having a json option for "props" where it uses the key value for the label and value for the data would be awesome. Then I could have multiple word labels.

PR #1283 adds the feature.

Example:

[H: a = json.set("{}","one",1,"two",2)]
[H: input(strformat("test|%{a}|Test|PROPS"))]

@aliasmask
Copy link
Author

Does "test" become a json object or remain a string prop when a json is used for key/value pairs? I just tested the json functions for converting and they would work fine if not converted to json with an invalid string prop key like "two words=1;"

@Phergus
Copy link
Contributor

Phergus commented Feb 16, 2020

[H: a = json.set("{}","Little Jon",1,"Friar Tuck",2)]
[H: input(strformat("test|%{a}|Test|PROPS"))]
[r: test]<br>
[r: getstrprop(test, "Little Jon")]<br>
[r: json.fromStrProp(test)]

returns

Little Jon=4 ;  Friar Tuck=5 ; 
4 
{"Little Jon":4,"Friar Tuck":5}

Merudo added a commit to Merudo/maptool that referenced this issue Feb 16, 2020
- Add option TYPE=JSON to input() PROPS, in which case the input will store the output as a json instead of a string property list
- Discussed in RPTools#1278
@Merudo
Copy link
Member

Merudo commented Feb 16, 2020

PR #1286 adds option TYPE=JSON to return the result as a json instead of a string property list.

Example:

[H: a = json.set("{}","Little Jon",1,"Friar Tuck",2)]
[H: input(strformat("test|%{a}|Test|PROPS|TYPE=JSON"))]
[r: test]

returns {"Little Jon":1,"Friar Tuck":2}.

@aliasmask
Copy link
Author

Yeah, I noticed the string prop was more forgiving. Not sure when that happened. Something like "Little Jon=1" would only display "Little" and "1" for value. But now it seems fine. Still happy about the type=json option. I never use it, but I wonder how using setvars=unsuffixed would work with an "invalid" name for a local property assignment.

@Phergus Phergus added the feature Adding functionality that adds value label Feb 16, 2020
@Phergus Phergus removed the documentation needed Missing, out-of-date or bad documentation label Feb 20, 2020
@Phergus
Copy link
Contributor

Phergus commented Feb 20, 2020

New options tested. Wiki page updated. Closing.

@Phergus Phergus closed this as completed Feb 20, 2020
Phergus added a commit that referenced this issue Feb 21, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug feature Adding functionality that adds value macro changes This issue adds or changes macro functions. Extra work is required (testing, wiki, code editor) tested This issue has been QA tested by someone other than the developer.
Projects
None yet
Development

No branches or pull requests

3 participants