[Javascript] Function scope question

Robert Pollard rpollard at apple.com
Tue Oct 7 10:16:12 CDT 2003


Hello Dave,

Would you mind sending an example of what you are talking about?  How 
do you "include the file with function definitions into the second 
file?"  I don't believe I've seen this syntax.  What's interesting is 
one file can see a function from the other but not the other way 
around.  Maybe it's syntax and the error is seeing the function but 
something else is causing problems.

Thanks for the response,

Robert

On Tuesday, October 7, 2003, at 06:16 AM, David T. Lovering wrote:

> I hope I am not missing part of this thread -- some of my email got 
> eaten by my ISP...
>
> About the only sticking point I can see is that you may need to 
> "include" the file with the function definitions into the second file 
> in order to satisfy the function references. I usually put all my 
> "common" JavaScript functions into a single common.js
> file, and then include it in BOTH files at the start within the header 
> block.  However, that is only my personal preference and isn't 
> universally necessary.
>
> -- Dave Lovering
>
> Chris Tifer wrote:
>>
>> If you included script files like you said in a different e-mail, 
>> then I
>> don't see any problem with what you've done. Do something very simple 
>> just
>> to verify.
>>
>> In your first file just put:
>>
>> function test(){
>>     alert("it works")
>> }
>>
>> In your 2nd file, put:
>>
>> test()
>>
>> You should see it get called.
>>
>> Chris Tifer
>> http://micclub.net
>>
>> ----- Original Message -----
>> From: "Robert Pollard" <rpollard at apple.com>
>> To: <Javascript at LaTech.edu>
>> Sent: Wednesday, October 01, 2003 6:32 PM
>> Subject: [Javascript] Function scope question
>>
>>> Hello all,
>>>
>>> I have 2 files that has several functions that are related.  I 
>>> needed 2
>>> of the functions in one file to be available in the other.  Can you 
>>> not
>>> have a function in 1 file and call it from another file?
>>>
>>> Thanks,
>>>
>>> Robert Pollard
>>>
>>> _______________________________________________
>>> Javascript mailing list
>>> Javascript at LaTech.edu
>>> https://lists.LaTech.edu/mailman/listinfo/javascript
>>
>> _______________________________________________
>> Javascript mailing list
>> Javascript at LaTech.edu
>> https://lists.LaTech.edu/mailman/listinfo/javascript
> _______________________________________________
> Javascript mailing list
> Javascript at LaTech.edu
> https://lists.LaTech.edu/mailman/listinfo/javascript




More information about the Javascript mailing list