[b91] [Solved] Bug Report - swich, if, jobj

Confirmed bugs should get a single post here. Check the READ ME FIRST sticky thread for the format.

Moderators: dorpond, trevor, Azhrei, giliath, jay, Mr.Ice, MapTool BugReport Manager

Forum rules
Posts that do not conform to the READ ME FIRST sticky thread are subject to deletion.
Post Reply
emforhsdpdlw
Kobold
Posts: 6
Joined: Thu Jun 11, 2015 9:22 pm

[b91] [Solved] Bug Report - swich, if, jobj

Post by emforhsdpdlw »

Sorry, I can't speak English.

I don't have the ability to explain this bug.

Even with the Google Translator.

So my report will helplessly simple.

[switch(1), CODE:
case "1":{
[if(1==1), CODE:{
[strformat('{"arg_lvl":0}')]
(very long jobj will continue. so i want to use strformat instead json.set for speed.)
};{}]
}]

Please try this command and give me answer.

At least I can read. So you don't need to worry about it.

And Thank you for your great works.
Last edited by emforhsdpdlw on Fri Jun 12, 2015 7:34 am, edited 1 time in total.

User avatar
aliasmask
RPTools Team
Posts: 9029
Joined: Tue Nov 10, 2009 6:11 pm
Location: Bay Area

Re: [b91] Bug Report - swich, if, jobj

Post by aliasmask »

The parser thinks you have 3 {} which isn't allowed because it counts {} inside single quotes ('). If you change ' to " then it works. But I still recommend using json.set.

Code: Select all

[switch(1), code:
   case "1":{
      [if(1 == 1), CODE: {
         [strformat("{'arg_lvl':0}")]
      };{}]
   }
]
json.set works very well with long arguments. It's too easy to make mistakes creating a json object manually and the difference in speed isn't that much unless you have many nested objects which I also don't recommend.

Code: Select all

[switch(1), code:
   case "1":{
      [if(1 == 1), CODE: {
         [json.set("{}","arg_1",0,"arg_2",0,"arg_3",0,"arg_4",0)]
      };{}]
   }
]

emforhsdpdlw
Kobold
Posts: 6
Joined: Thu Jun 11, 2015 9:22 pm

Re: [b91] Bug Report - swich, if, jobj

Post by emforhsdpdlw »

aliasmask wrote:The parser thinks you have 3 {} which isn't allowed because it counts {} inside single quotes ('). If you change ' to " then it works. But I still recommend using json.set.

Code: Select all

[switch(1), code:
   case "1":{
      [if(1 == 1), CODE: {
         [strformat("{'arg_lvl':0}")]
      };{}]
   }
]
json.set works very well with long arguments. It's too easy to make mistakes creating a json object manually and the difference in speed isn't that much unless you have many nested objects which I also don't recommend.

Code: Select all

[switch(1), code:
   case "1":{
      [if(1 == 1), CODE: {
         [json.set("{}","arg_1",0,"arg_2",0,"arg_3",0,"arg_4",0)]
      };{}]
   }
]
Thank you for your answer to my silly report.

I'll take your advice.

Anyway, This post has been resolved.

But I don't know how to edit subject.

User avatar
aliasmask
RPTools Team
Posts: 9029
Joined: Tue Nov 10, 2009 6:11 pm
Location: Bay Area

Re: [b91] Bug Report - swich, if, jobj

Post by aliasmask »

You need two posts to have permission to update. You can now edit your posts.

Post Reply

Return to “Bug Reports”