Thanks. That should work quite well!
On 6/7/06, Justin McConnell <boolean gmail.com> wrote:
>
> One option is to use a function closure. That way the
inner function
> has access to the variables of the outer function:
> for(n=0; n<=3; n++)
> {
> _IG_FetchContent(url[n], function() {
> // I can see everything that is visible outside the
> _IG_FetchContent call
> });
> }
>
> Another option is to set n as a global variable so it
is in scope of
> every function. Looking at your code, unless you
defined var n
> earlier, n is a global and you should be able to see it
in function f
> already. If you did go this route, you would want to
rename n to
> something more unique -- n is such a simple variable
name you might
> have namespace collisions with other variables on the
page.
>
> Personally, I'd lean towards a function closure since
global variables
> are aguablely insecure and the source of potential
bugs.
>
> gurkesaft wrote:
> > Hello,
> >
> > Is it possible to call _IG_FetchContent(url, f)
with additional
> > arguments sent to f? I need to send f more
information than the URL
> > string returned by the fetch. Ideally, I'd like
to be able to do
> > something like this
> >
> > for(n=0; n<=3; n++)
> > {
> > _IG_FetchContent(url[n], f(__returned_string__,
n))
> > }
> >
> > or something, so that f can know what n is as well
as the content
> > string. I really have no clue how to do something
like this.
> >
> > Can anyone help? If not, is there a code
structuring philosophy I
> > should change? I'd use globals, but this
function seems to run in a
> > thread, finishing in its own time, so that the
above code quickly loops
> > before f is even called the first time (and n
changes).
> >
> > I'm thinking of **kwargs from python as I write
this
> >
> > Thanks,
> > -Jack
>
>
> >
>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the
Google Groups "Google Homepage API" group.
To post to this group, send email to Google-Homepage-API googlegroups.com
To unsubscribe from this group, send email to
Google-Homepage-API-unsubscribe googlegroups.com
For more options, visit this group at ht
tp://groups.google.com/group/Google-Homepage-API
-~----------~----~----~----~------~----~------~--~---
|