just so you know, "shortcodes" are not a real PHP thing. They're just something (of debatable merit) that WP invented. If you already understood that, I apologize; I mention it because I see a lot of confusion on this topic. There are many WP users who don't even realize that WordPress and PHP are *different things*, and it really complicates the process of helping them fix problems.
(On that note, you may be able to get better help on a WordPress forum, where there are more people who use these functions all the time.)
From reading through the shortcode functions, I don't think there's a "good way" to do what you want. You can hack it using the $_GLOBAL superglobal array, but it will confuse things and can cause unexpected problems (such as existing variables being overwritten (or not!) at various points in your script, not to mention no convenient way of knowing if the variables you wanted have been created/updated/ornot at any particular time).
Keeping in mind everything Daniel said...
I would not recommend trying this without better understanding how WP works in general.
I've tried to minimize the risk, but you still might break something important.
PHP Code:
<?php
function GenerateSitemap($params = array()) {
// default parameters
extract(shortcode_atts(array(
'title' => 'Site map',
'id' => 'sitemap',
'depth' => 2
), $params));
// create sitemap
$sitemap = wp_list_pages("title_li=&depth=$depth&sort_column=menu_order&echo=0");
if ($sitemap != '') {
$sitemap =
($title == '' ? '' : "<h2>$title</h2>") .
'<ul' . ($id == '' ? '' : " id=\"$id\"") . ">$sitemap</ul>";
}
## HERE's THE NEW PART ##
$_GLOBALS['vars_from_GenerateSitemap'] = array( 'title'=>$title,'id'=>$id,'depth'=>$depth );
## all done ##
return $sitemap;
}
Later, after you've called this function (and assuming it ran successfully), you'd be able to access those values in the array $vars_from_GenerateSitemap (for example, $vars_from_GenerateSitemap['title']).
Bookmarks