Scoping with multiple .gs files

692 views
Skip to first unread message

Weston Boldt

unread,
Jul 25, 2018, 6:35:58 PM7/25/18
to AdWords Scripts Forum
Just looking for clarification on what the scoping is for multiple files in adwords scripts

it seems that i can write a function and have it visible in other .gs files but variables are not
ex:
function main() {
    foo()
}
function foo() {
   Logger.log("hello world!");
}
// this will out put a statement into the log that says
 hello world!

fine and dandy all is clear but what i'm unsure of is why this would not do the same
ex:
function main() {
    foo()
}
var foo = function () {
   Logger.log("hello world!");
}
// shouldnt this behave the same way?

Hiroyuki Miyauchi (AdWords Scripts Team)

unread,
Jul 25, 2018, 11:56:59 PM7/25/18
to AdWords Scripts Forum
Hello Weston,

It should be the same behavior. I tested the scripts you provided on my end and the behavior was the same for both function and inline function (e.g. var foo = function()). Could you confirm what is the issue you are encountering when you run the second script which is with an inline function?

Regards,
Hiroyuki
AdWords Scripts Team

Weston Boldt

unread,
Jul 26, 2018, 12:05:22 AM7/26/18
to AdWords Scripts Forum on behalf of Hiroyuki Miyauchi (AdWords Scripts Team)
sorry guys looks like i had accidentally written
`logger.Log`
instead of the correct
`Logger.log`
sorry for the mistake lol

--
-- You received this message because you are subscribed to the Google Groups AdWords Scripts Forum group. Please do not reply to this email. To post to this group or unsubscribe please visit https://developers.google.com/adwords/scripts/community.
---
You received this message because you are subscribed to the Google Groups "AdWords Scripts Forum" group.
To unsubscribe from this group and stop receiving emails from it, send an email to adwords-scrip...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/adwords-scripts/5e6b0de3-68db-474b-ba4f-9abb57f03738%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages