Creating a stat based on two strings

Discuss how to create custom stats, reports and HUD profiles and share your creations.

Moderators: WhiteRider, kraada, Flag_Hippo, morny, Moderators

Creating a stat based on two strings

Postby miljön » Sun Nov 09, 2014 3:03 pm

Hi,

i build a column which collects the hole cards of villain (in case of a showdown) as a string.
E.g.: AKo2296oK3s...
Now i want to use this column for creating a stat which checks if for a certain hand and gives back a string.
if((strpos(str_hands, '22') > 0), '22', '__')
This one works fine - i get '22' back in case '22' is in the column str_hands, otherwise i get '__' back.
Now i am wondering if i could check within one stat more than one hand - '22', 'AKo'
But this doesn't work:
if((strpos(str_hands, '22') > 0), '22', '__') || if((strpos(str_hands, 'AKo') > 0), 'AKo', '__')
same with this one:
substr(if((strpos(str_hands, '22') > 0), '22', '__'), 01) || substr(if((strpos(str_hands, 'AKo') > 0), 'AKo', '__'), 01)

Is it simply not possible or is there just a minor mistake i am doing due to my lack of programming skills?

Thanks for your help!
miljön
miljön
 
Posts: 40
Joined: Tue Feb 18, 2014 9:26 am

Re: Creating a stat based on two strings

Postby sawwee » Sun Nov 09, 2014 9:03 pm

Stat editor can't understand postgres functions like ||
You have to do the merge in a column.
sawwee
 
Posts: 513
Joined: Thu Dec 18, 2008 11:59 pm

Re: Creating a stat based on two strings

Postby WhiteRider » Mon Nov 10, 2014 4:30 am

The other way to do it is with "format".
format( '{1}{2}', if(...), if(...) )
You can use as many {x} values as you like, just make sure each has a matching piece of data comma separated after it.
WhiteRider
Moderator
 
Posts: 54018
Joined: Sat Jan 19, 2008 7:06 pm
Location: UK

Re: Creating a stat based on two strings

Postby 4StarGen » Mon Nov 10, 2014 6:46 am

I brought up this issue some month ago...
Why PT4 isn't recognizing std postgresql functions?
4StarGen
 
Posts: 955
Joined: Sat Mar 08, 2014 6:58 am

Re: Creating a stat based on two strings

Postby miljön » Mon Nov 10, 2014 7:14 am

Works!

Thanks a lot for your help guys
miljön
 
Posts: 40
Joined: Tue Feb 18, 2014 9:26 am

Re: Creating a stat based on two strings

Postby kraada » Mon Nov 10, 2014 9:09 am

4StarGen: This is a known bug due to the comma in our parser - it's not that PT4 isn't "recognizing" the SQL it's that the parser misinterprets the comma and sends a malformed string.
kraada
Moderator
 
Posts: 54431
Joined: Wed Mar 05, 2008 2:32 am
Location: NY

Re: Creating a stat based on two strings

Postby miljön » Mon Nov 10, 2014 9:55 am

Is it possible to put in a new line within the format( '{1}{2}', if(...), if(...) ) expression?
For example i want to have {1} in one line and {2} in the next one...
miljön
 
Posts: 40
Joined: Tue Feb 18, 2014 9:26 am

Re: Creating a stat based on two strings

Postby 4StarGen » Mon Nov 10, 2014 9:58 am

miljön wrote:Is it possible to put in a new line within the format( '{1}{2}', if(...), if(...) ) expression?
For example i want to have {1} in one line and {2} in the next one...


No, I've asked before you... you have to build 2 stats and then place them in 2 different lines
4StarGen
 
Posts: 955
Joined: Sat Mar 08, 2014 6:58 am

Re: Creating a stat based on two strings

Postby miljön » Mon Nov 10, 2014 9:59 am

Okay already thought so... Thanks for your help!
miljön
 
Posts: 40
Joined: Tue Feb 18, 2014 9:26 am

Re: Creating a stat based on two strings

Postby 4StarGen » Mon Nov 10, 2014 10:40 am

kraada wrote:4StarGen: This is a known bug due to the comma in our parser - it's not that PT4 isn't "recognizing" the SQL it's that the parser misinterprets the comma and sends a malformed string.


ty, I didn't know that
4StarGen
 
Posts: 955
Joined: Sat Mar 08, 2014 6:58 am

Next

Return to Custom Stats, Reports and HUD Profiles

Who is online

Users browsing this forum: Google [Bot] and 10 guests

cron