Tables in conditional evaluation

I’m trying to exectute a simple conditional evaluation statement. I have a table t listed in tables.

 $ [t; [action one]; [action two]

I keep getting a type error. Is there some unique way to use tables in conditional evaluation?? I’ve tried if t not null, t in tables,  count t > 0, etc, It keeps giving me the same error.  Evaluation works for variables but I can’t get it to recognise the table, and this is the only way I can think to get the function to work.

I just need to check if the table exists. i know this is probably pretty simple i just can’t figure it out.

All help appreciated.

q)$[t in key .;present;missing]

`missing

q)t:(a:0 1)

q)$[t in key .;present;missing]

`present

or with tables cmd

q)$[`t in tables;`present;`missing]

`present

q)delete t from `.;

q)$[`t in tables;`present;`missing]

`missing

You can use .Q.qt also to know if its table or not. It returns bollean result.

On May 12, 2014 12:32 AM, “Daniel o keeffe” <doktordiversity@gmail.com> wrote:
>
> I’m trying to exectute a simple conditional evaluation statement. I have a table t listed in tables.
>
>  $ [t; [action one]; [action two]
>
> I keep getting a type error. Is there some unique way to use tables in conditional evaluation?? I’ve tried if t not null, t in tables,  count t > 0, etc, It keeps giving me the same error.  Evaluation works for variables but I can’t get it to recognise the table, and this is the only way I can think to get the function to work.
>
> I just need to check if the table exists. i know this is probably pretty simple i just can’t figure it out.
>
> All help appreciated.
>
> –
> Submitted via Google Groups

$[count tableName;…

q)a:(a:ab`c;b:1 2 3)

q)

q)

q)a

a b


a 1

b 2

c 3

q)$[a in tables;true;false]

`true

q)

Thanks guys. It was, inevitably, a backtick before the tablename. But I’d still be here clueless if it wasn’t pointed out:)

Just out of interest, the difference between tables in system “a” and system “b”, a being function local and b being global is that about it?? If tables is system “a” I assume there is an alternative command for system “b”? Its just when i define a table in my function I don’t see why it should still be available outside the function, wheras variables are not.

Thanks

system"b" is not tables its views, equivalent to views, or \b.
http://code.kx.com/wiki/Reference/SystemCommands#.5Cb\_-\_views.2Fdependencies

http://code.kx.com/wiki/Reference/view

http://code.kx.com/wiki/Reference/views

HTH,

Sean