I use a function for this. Once you've loaded the function, simply call it like this:
if (table_exists("Output"),
// append to journal
,
// don't append
);
Here's the function:
/*
Function Name: table_exists
Description: Returns 1 if the table exists, 0 if not
Arguments:
table_name Table to check existence of
*/
table_exists = Function( {table_name},
{Default Local},
tbl_exists_flag = 0;
// Loop over all tables and see if this one exists
num_tables = ntable();
For (i = 1, i <= num_tables, i++,
one_name = Data Table(i) << Get Name;
if (one_name == table_name,
tbl_exists_flag = 1;
break(); // jump out of the loop now that we found the table
);
);
tbl_exists_flag;
); // end table_exists function