How to access $variables in a module function where $variables is not passed to it. (D7)
Call your function from inside your module's preprocess_page() hook.  Eg, in your custom module, let's say your function that calls your view is mymodule_call_view().  Let's further assume it returns the value you want to set your page variable to.  You could do it this way:

mymodule_preprocess_page(&amp;$variables) {

  // any other preprocessing you are doing goes here

  $variables['variable_you_want_to_set']=mymodule_call_view();

}


Then, when drupal is building the page, it would call your preprocess function, which would call your function that iterates through the view, etc...