you are close....

Code:

random_var()

WriteLine(5, '# Rays D, NumPolys, NumStreaks, OuterRadius, Colour, ColourTemp'+Chr(13))
WriteLine(5, 'Rays '+ $NumPolys + ', '+ $NumStreaks +', '+ $OuterRadius +', '+ $OuterOpacity +', 0x00'+ $KeyColor[$dd] +', '+ $ColourTemp +''+Chr(13))
WriteLine(5, Chr(13))

function random_var()
dim $dd
$dd = 5 * rnd(30)
formatnumber($NumPolys,0.00) = 0.0
$NumPolys = 1.1 * rnd(10)
$NumStreaks = rnd(20)
$OuterRadius = rnd(10)
$InnerOpacity = 1.1 * rnd(10)
$OuterOpacity = 1.1 * rnd(10)
endfunction