let rec get_value_of_var_at_step (name : string) (var : string) (step : int) : string =
(* let test =
if (step<1)
then 0
else (
let rec aux_test l =
match l with [] -> 0
|(x::ls) -> let (sender,reciever,_) = actionTreatment x in
if(name=sender) then 1
else if(name=reciever) then 0
else aux_test ls ;
in
aux_test (List.rev (Listbox.get_range story ~first:(`Num 0) ~last:(`Num (step-1))))
);
in *)
let var_aux = if (is_a_test_var var) then (get_name_of_test_var var) else var in
let variable = (name,var_aux) in
let all_value_of_variable = Hashtbl.find_all var_value variable in
let rec give_number_of_occur n l res =
match l with [] -> res
|(x::ls) -> if(n=x)
then give_number_of_occur n ls (res+1)
else give_number_of_occur n ls res
in
if(all_value_of_variable=[]) then var_aux
else (
let all_variables_story = (!variable_current_change)::(!variable_story) in
let rec aux l step pos_res =
match l with [] -> pos_res
|(x::ls) ->
if (step<=0)
then pos_res
else(
if(List.mem variable x)
then aux ls (step-1) (pos_res+(give_number_of_occur variable x 0))
else aux ls (step-1) pos_res;
);
in
(* prerr_int step; prerr_string "; prerr_int((min (List.length all_value_of_variable) (aux (List.rev all_variables_story) step 0))-1);
prerr_string";*)
let pos = ((min (List.length all_value_of_variable) (aux (List.rev all_variables_story) step 0))-1) in
let res = List.nth (List.rev all_value_of_variable) (max 0 pos)
in
if(pos<0) then res
else if(is_an_aggregation res)
then (res^"->"^(get_value_of_var_at_step "x" res step))
else res;
)