Code snippets in column definitions ?

Forum for users that want to write their own custom queries against the PT database either via the Structured Query Language (SQL) or using the PT3 custom stats/reports interface.

Moderator: Moderators

Code snippets in column definitions ?

Postby Parket » Wed Jul 13, 2011 7:40 am

I was wondering whether it's possible to write some code snippets in the column definitions.

I have a custom column that uses the same expression multiple times like this:
if [..., some_expression, if [..., 2*some_expression, 3*some_expression] ]

Now I'd like to even extend the whole column definition making the repetition of the expression even more annoying. What I'd like to do instead is something like:

int x = some expression;
if [.., x, if [..., 2*x, 3*x ]]

Is this possible in the column definitions ?
Parket
 
Posts: 367
Joined: Mon Mar 24, 2008 1:03 pm

Re: Code snippets in column definitions ?

Postby kraada » Wed Jul 13, 2011 9:37 am

Unfortunately that is not possible - I agree it would be nice but it's not something the custom stats engine can handle at this point in time.
kraada
Moderator
 
Posts: 54430
Joined: Wed Mar 05, 2008 2:32 am
Location: NY

Re: Code snippets in column definitions ?

Postby Parket » Wed Jul 13, 2011 9:52 am

Ok thanks.
Already thought of a work-around though: I can assign the calculation of some_expression into its own column variable and then refer to that new column for the actual expression.
Parket
 
Posts: 367
Joined: Mon Mar 24, 2008 1:03 pm

Re: Code snippets in column definitions ?

Postby kraada » Wed Jul 13, 2011 10:45 am

I'm not sure exactly what you mean . . . you can't refer to one column in another column except in the Hand section.
kraada
Moderator
 
Posts: 54430
Joined: Wed Mar 05, 2008 2:32 am
Location: NY

Re: Code snippets in column definitions ?

Postby Parket » Wed Jul 13, 2011 10:56 am

Well, it does seem to work just fine. ;)

Created 2 columns :
stat_base = some_expression
stat = if [.., stat_base, if [..., 2*stat_base, 3*stat_base ]]

The Cashout custom stat I've uploaded to the repository uses this trick.
Parket
 
Posts: 367
Joined: Mon Mar 24, 2008 1:03 pm

Re: Code snippets in column definitions ?

Postby kraada » Wed Jul 13, 2011 12:01 pm

That's really good to know - I see from your thread about the stat that it's in the Tournaments section - that makes more sense. I'd still not expect it to work 100% properly in the Player Statistics section . . . but maybe I'll have to tinker with it again to see if it does. It opens up a few doors if we can make columns this way.
kraada
Moderator
 
Posts: 54430
Joined: Wed Mar 05, 2008 2:32 am
Location: NY

Re: Code snippets in column definitions ?

Postby Parket » Thu Jul 14, 2011 3:47 am

Well, when I clicked Insert, to insert a value/operator/function in the formula, my other column was just there :).
Interesting question though: what would happen if columns were mutually referenced :p. Would it cause PT3 to hang/crash ??
Parket
 
Posts: 367
Joined: Mon Mar 24, 2008 1:03 pm

Re: Code snippets in column definitions ?

Postby kraada » Thu Jul 14, 2011 8:53 am

I'm not sure, the only way to find that out would be to test . . .
kraada
Moderator
 
Posts: 54430
Joined: Wed Mar 05, 2008 2:32 am
Location: NY


Return to Custom Stats, Reports, and SQL [Read Only]

Who is online

Users browsing this forum: No registered users and 0 guests