Query regd file handling in System verilog

In reply to Lina.Lin:

Hi lina thanks for the reply…

I am doing the below thing in my code to use the values from the file after it is read and traversed.i am setting the txn_count from my test case.i stil. Dont see any values being applied from the file to these fields. Kindly advise.

for (int i=0;i<txn_count;i++) begin : file_block
file = $fopen(“rand_Inputs_generator.txt”,“r”);
while (!$feof(file)) begin
r = $fscanf(file, " %d %d %d", Opcodes, price_rand, OrderId_rand);
trans.cmdcode=opcodes;
trans.ORDER_BOOK.OrderNmbr=OrderId_rand;
trans.newprice=price_rand ;
$display(" %d %d %d", Opcodes, price_rand, OrderId_rand);
end // while not EOF
$fclose(file);
end