Where should I pwrite variable which can be configed?

I have a function (my_random) in the transactiion which randomize one of the transaction’s fields.

In the sequence I want to write some condiotion which will decide if the my_random() should be call or not. Something like

if (to_random == 1)
trx.my_random(); //trx is transaction instance
else
trx.delay = const_config;

Where I should write the to_random and const_config variable?

p.s
I created this function because I use modelSim which doesn’t support random().

In reply to saritr:

I’m not sure what your objective is doing things complicated which can be done simply?
Any data field in a transaction class which has the rand keyword at the beginning of the declaration will be automatically randomized when you call the randomize method on the class object. If you want to take influence on the randomization you can do this by passing constraint to this data field or switching of the randomizaion of this data field.

In reply to chr_sue:

I use ModelSim, and it doesn’t support random function.