How to check if strProp is null? (Solved)

Discuss macro implementations, ask for macro help (to share your creations, see User Creations, probably either Campaign Frameworks or Drop-in Resources).

Moderators: dorpond, trevor, Azhrei, giliath, jay, Mr.Ice

Post Reply
LarryHunsaker
Kobold
Posts: 24
Joined: Wed Oct 06, 2010 10:35 am

How to check if strProp is null? (Solved)

Post by LarryHunsaker »

I want to check if a key exists in a strProp and if it does not, create it (with setStrProp), but if it does exist, just get its value (getStrProp). So how do I test this?
Last edited by LarryHunsaker on Thu Apr 24, 2014 4:22 pm, edited 1 time in total.

User avatar
aliasmask
RPTools Team
Posts: 9031
Joined: Tue Nov 10, 2009 6:11 pm
Location: California

Re: How to check if strProp is empty (null)?

Post by aliasmask »

You can use Wiki: getStrProp(). You can set a value for default when the key isn't found. For example:

Code: Select all

[getStrProp("a=1;b=2","c",-1)]
Would return -1 because there is no "c" key.

LarryHunsaker
Kobold
Posts: 24
Joined: Wed Oct 06, 2010 10:35 am

Re: How to check if strProp is empty (null)?

Post by LarryHunsaker »

Perfect, thanks. Too bad that is not in the Wiki, seems a simple enough addition.

User avatar
aliasmask
RPTools Team
Posts: 9031
Joined: Tue Nov 10, 2009 6:11 pm
Location: California

Re: How to check if strProp is empty (null)?

Post by aliasmask »

It describes it in the wiki under parameters, default.

LarryHunsaker
Kobold
Posts: 24
Joined: Wed Oct 06, 2010 10:35 am

Re: How to check if strProp is empty (null)?

Post by LarryHunsaker »

I guess I did not realize that is what it meant, I was thinking it was talking about the key not being in the campaign property list but just added later to the token. Perhaps if it said, result returned when key does not exist, rather then key is not found.

Post Reply

Return to “Macros”