I am trying to choose random row in a table and then a random column associated with that row and then print that row/column combination.
The following code below does not compile, I am just including it as an example of how I have tried to approach the problem. Actually, the first three lines compile just fine. Anyway, what I have is:
carry out singing:
choose a random row in the Table of Radio Songs;
let N be the title entry;
say "[N]";
choose a random column in the table of radio songs;
say "[random column in the table of radio songs]";
I also tried:
carry out singing:
choose a random row in the Table of Radio Songs;
let N be the title entry;
say "[N]";
choose a random column entry of N;
say "[column entry]";
I can’t figure out how to choose the column associated with the row.
As always, your help is greatly appreciated. My
CREDITS list is consistenly growing…
Unfortunately, there’s no way to choose a random column. Columns can have different types, and expressions in I7 always have to have one specific type.
As a workaround, you can put a list in a table column, and choose a random entry from that.
choose a random row in the foo table;
if a random number from 1 to 5 is:
-- 1: decide on the col1 entry;
-- 2: decide on the col2 entry;
-- 3: decide on the col3 entry;
-- 4: decide on the col4 entry;
-- 5: decide on the col5 entry;
As long as all five named columns have the same type, this will work.
It’s kind of involved. In all honesty, you’re probably better off re-configuring the data structure of your table. Can you describe it (or something analogous to it) here?