0
Nested Functions
Participant
,
/t5/dreamweaver-discussions/nested-functions/td-p/639163
Feb 26, 2007
Feb 26, 2007
Copy link to clipboard
Copied
I am trying to use nested functions in a floater i am
building, and right after I edit the js document and reload
dreamweaver the functions work, but if I reload dreamweaver again
without making any changes to the file it says the nested function
does not exist. Can anyone help me figure this out? Thanks
TOPICS
Extensions
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
Contributor
,
/t5/dreamweaver-discussions/nested-functions/m-p/639164#M144205
Feb 27, 2007
Feb 27, 2007
Copy link to clipboard
Copied
Exit DW and try deleting the cache fle located in the
configuration folder. Then open dreamweaver and try the floater,
but don't reload it, just restart it and see if it makes a
difference.
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
SClukey
AUTHOR
Participant
,
/t5/dreamweaver-discussions/nested-functions/m-p/639165#M144206
Feb 28, 2007
Feb 28, 2007
Copy link to clipboard
Copied
That works the first time also, but as soon as I restart DW
it has recreated the cache file so it stops working again. So, I
would have to delete the cache file every time I exit dreamweaver
for that to work.
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
LEGEND
,
/t5/dreamweaver-discussions/nested-functions/m-p/639166#M144208
Mar 01, 2007
Mar 01, 2007
Copy link to clipboard
Copied
What do you mean by "nested functions"?
Randy
> I am trying to use nested functions in a floater i am building, and right after
> I edit the js document and reload dreamweaver the functions work, but if I
> reload dreamweaver again without making any changes to the file it says the
> nested function does not exist. Can anyone help me figure this out?
Randy
> I am trying to use nested functions in a floater i am building, and right after
> I edit the js document and reload dreamweaver the functions work, but if I
> reload dreamweaver again without making any changes to the file it says the
> nested function does not exist. Can anyone help me figure this out?
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
SClukey
AUTHOR
Participant
,
/t5/dreamweaver-discussions/nested-functions/m-p/639167#M144210
Mar 02, 2007
Mar 02, 2007
Copy link to clipboard
Copied
For Example:
number1.number2()
number1.number2()
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
LEGEND
,
/t5/dreamweaver-discussions/nested-functions/m-p/639179#M144222
Mar 06, 2007
Mar 06, 2007
Copy link to clipboard
Copied
Are you trying to call these from your main floater code? In
your example,
number2 is a local function that will only work from inside number1.
--
Tom Muck
co-author Dreamweaver MX 2004: The Complete Reference
http://www.tom-muck.com/
Cartweaver Development Team
http://www.cartweaver.com
Extending Knowledge Daily
http://www.communitymx.com/
"Clukey" <webforumsuser@macromedia.com> wrote in message
news:esa7e7$m4n$1@forums.macromedia.com...
> For Example:
>
> number1.number2()
>
>
>
> function number1() {
> function number2() {
> alert("this is function number 2")
> }
> }
number2 is a local function that will only work from inside number1.
--
Tom Muck
co-author Dreamweaver MX 2004: The Complete Reference
http://www.tom-muck.com/
Cartweaver Development Team
http://www.cartweaver.com
Extending Knowledge Daily
http://www.communitymx.com/
"Clukey" <webforumsuser@macromedia.com> wrote in message
news:esa7e7$m4n$1@forums.macromedia.com...
> For Example:
>
> number1.number2()
>
>
>
> function number1() {
> function number2() {
> alert("this is function number 2")
> }
> }
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
SClukey
AUTHOR
Participant
,
LATEST
/t5/dreamweaver-discussions/nested-functions/m-p/639180#M144223
Mar 06, 2007
Mar 06, 2007
Copy link to clipboard
Copied
Right, I realized that just recently, because originally I
was using Dreamweaver MX to make my extension and it actually
worked. So, now I have 8 and it doesn't work so I looked into it
and realized that can't be done. Thanks
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
Contributor
,
/t5/dreamweaver-discussions/nested-functions/m-p/639168#M144211
Mar 02, 2007
Mar 02, 2007
Copy link to clipboard
Copied
Why are you doing a nested function? Why not just create 2
seperate functions and call one of the functions inside the
other.
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
SClukey
AUTHOR
Participant
,
/t5/dreamweaver-discussions/nested-functions/m-p/639169#M144212
Mar 02, 2007
Mar 02, 2007
Copy link to clipboard
Copied
Because I need two versions of most every function. What I
mean is if a=b then I have to use a different set of functions then
if a=c; and both sets of functions accomplish the same goal, but
they have to do it in different ways. And since I would rather not
have to go through every function and put that IF statement, I just
nested them and call the one I need.
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
Contributor
,
/t5/dreamweaver-discussions/nested-functions/m-p/639170#M144213
Mar 03, 2007
Mar 03, 2007
Copy link to clipboard
Copied
Would an overloaded function be useful? I honelsty have never
used or have experience with nested functions. Sorry I couldn't be
of more help.
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
SClukey
AUTHOR
Participant
,
/t5/dreamweaver-discussions/nested-functions/m-p/639171#M144214
Mar 03, 2007
Mar 03, 2007
Copy link to clipboard
Copied
What do you mean an "overloaded" function?
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
Contributor
,
/t5/dreamweaver-discussions/nested-functions/m-p/639172#M144215
Mar 03, 2007
Mar 03, 2007
Copy link to clipboard
Copied
An overloaded function is are functions that have the same
name but different input parameters list. like:
function tellMeAJoke()
{
arguments
}
function tellMeAJoke(int a, int b)
{
arguments
}
function tellMeAJoke(string a, string b)
{
arguments
}
As you can see each funtion has the same name and will perform the same taks, but based on the different input parameters. If I didn't explain it well enough, you good do a google search for overloaded functions. Maybe someone else could explain it better than me.
function tellMeAJoke()
{
arguments
}
function tellMeAJoke(int a, int b)
{
arguments
}
function tellMeAJoke(string a, string b)
{
arguments
}
As you can see each funtion has the same name and will perform the same taks, but based on the different input parameters. If I didn't explain it well enough, you good do a google search for overloaded functions. Maybe someone else could explain it better than me.
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
Contributor
,
/t5/dreamweaver-discussions/nested-functions/m-p/639173#M144216
Mar 03, 2007
Mar 03, 2007
Copy link to clipboard
Copied
I just noticed that you might be calling your nested function
incorrectly. You just have to call the container function. So if
you had your function:
function number1() {
function number2() {
alert("this is function number 2")
}
}
simply call number1()
Have a peak at this link:
http://developer.mozilla.org/en/docs/Core_JavaScript_1.5_Reference:Functions#Nested_functions_and_cl...
function number1() {
function number2() {
alert("this is function number 2")
}
}
simply call number1()
Have a peak at this link:
http://developer.mozilla.org/en/docs/Core_JavaScript_1.5_Reference:Functions#Nested_functions_and_cl...
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
SClukey
AUTHOR
Participant
,
/t5/dreamweaver-discussions/nested-functions/m-p/639174#M144217
Mar 03, 2007
Mar 03, 2007
Copy link to clipboard
Copied
I didn't know about overloaded functions, thanks, but I don't
think that would help because the functions basically have the same
args they just have parse the data differently.
If I simply called number1() it would not run number2() because all functions have to be called specifically, as with the link you gave, the container function always called the nested function. Also, I know it is possible to use number1.number2() because they work fine right after I edit the file.
If I simply called number1() it would not run number2() because all functions have to be called specifically, as with the link you gave, the container function always called the nested function. Also, I know it is possible to use number1.number2() because they work fine right after I edit the file.
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
Contributor
,
/t5/dreamweaver-discussions/nested-functions/m-p/639175#M144218
Mar 03, 2007
Mar 03, 2007
Copy link to clipboard
Copied
What if you were to create a function that would check your
values and return true or false. Something like:
function checkValues(a, b, c)
{
arguments
return whatever;
}
Then have your two functions. Then in your code just say something like:
if (checkValues(a,b,c) == something)
{
perform this function
}else{
perform the other function
}
I know you are using nested functions for a specific reason, but I am just trying to help you find a way around this problem you are having with the nested function.
Have you done a test? Maybe create a very simple behavior and use a nested function. See if you have the same problem with that nested function as well. If not, then there may be something else causing the problem.
function checkValues(a, b, c)
{
arguments
return whatever;
}
Then have your two functions. Then in your code just say something like:
if (checkValues(a,b,c) == something)
{
perform this function
}else{
perform the other function
}
I know you are using nested functions for a specific reason, but I am just trying to help you find a way around this problem you are having with the nested function.
Have you done a test? Maybe create a very simple behavior and use a nested function. See if you have the same problem with that nested function as well. If not, then there may be something else causing the problem.
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
SClukey
AUTHOR
Participant
,
/t5/dreamweaver-discussions/nested-functions/m-p/639176#M144219
Mar 04, 2007
Mar 04, 2007
Copy link to clipboard
Copied
Thanks, the reason I am using nested functions is because I
already have half the functions built for this extension and I
didn't want to have to go through all 39 (give or take) functions
and put a huge "if", it would take too long and make the code
harder to read, so I thought nesting them would be the easiest.
My other option I have thought might work is to have my code like this,
function number1(f, [arg1, arg2, ...])
switch(f) {
case 1:
number2();
break;
case 2:
number3(arg1, arg2, ...)
break;
}
function number2() {
...
}
function number3() {
...
}
Then call number1(...)
But I was really hoping to get the nested functions working because it would still be easier and simpler, but if there is any other better way to do this I would be fine with that.
I made a simple command that would just alert something, and the nested function didn't work, so maybe dreamweaver doesn't support them, but I still can't figure out why it works in the floater right after I edit the file.
My other option I have thought might work is to have my code like this,
function number1(f, [arg1, arg2, ...])
switch(f) {
case 1:
number2();
break;
case 2:
number3(arg1, arg2, ...)
break;
}
function number2() {
...
}
function number3() {
...
}
Then call number1(...)
But I was really hoping to get the nested functions working because it would still be easier and simpler, but if there is any other better way to do this I would be fine with that.
I made a simple command that would just alert something, and the nested function didn't work, so maybe dreamweaver doesn't support them, but I still can't figure out why it works in the floater right after I edit the file.
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
Contributor
,
/t5/dreamweaver-discussions/nested-functions/m-p/639177#M144220
Mar 04, 2007
Mar 04, 2007
Copy link to clipboard
Copied
Clukey,
I don't know what is your "comfort zone" or level of experience working with javascript coding.
As for your quoted statement, "...so maybe dreamweaver doesn't support them...", you know Dreamweaver is ideally a HTML authoring app. That is to say, you know some fundamentals of HTML and understand how it works, then your skill become more intitution with HTML works and what's not. With understanding of how HTML works, and that you would be able to "troubleshoot" when HTML acts up or why it doesn't work as intended.
That analogy with javascript as opposed to HTML, to code javascript, you need to have some fundemantals of javascript coding. The more comfort zone and knowledge, as well as hands-on coding with javascript will definitely be of an asset to you to develop some javascript code to perform specific task you want.
So if javascript coding is totally new enviornment for you, perhaps you want to go this route with possible two ways: search engine or book(s).
Have you tried to do a bit of research using Google or Yahoo to locate some possible tutorial and step by step? Or you might want to consider to buy a book about javascript. There are pretty darn good number of good books covering javascript.
Hope that helps, no? Cheers, DWD (Brian)
I don't know what is your "comfort zone" or level of experience working with javascript coding.
As for your quoted statement, "...so maybe dreamweaver doesn't support them...", you know Dreamweaver is ideally a HTML authoring app. That is to say, you know some fundamentals of HTML and understand how it works, then your skill become more intitution with HTML works and what's not. With understanding of how HTML works, and that you would be able to "troubleshoot" when HTML acts up or why it doesn't work as intended.
That analogy with javascript as opposed to HTML, to code javascript, you need to have some fundemantals of javascript coding. The more comfort zone and knowledge, as well as hands-on coding with javascript will definitely be of an asset to you to develop some javascript code to perform specific task you want.
So if javascript coding is totally new enviornment for you, perhaps you want to go this route with possible two ways: search engine or book(s).
Have you tried to do a bit of research using Google or Yahoo to locate some possible tutorial and step by step? Or you might want to consider to buy a book about javascript. There are pretty darn good number of good books covering javascript.
Hope that helps, no? Cheers, DWD (Brian)
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
SClukey
AUTHOR
Participant
,
/t5/dreamweaver-discussions/nested-functions/m-p/639178#M144221
Mar 04, 2007
Mar 04, 2007
Copy link to clipboard
Copied
Thanks for the advice, but javascript is by no means new to
me. Although thats not to say I know all there is to know, as I am
sure I sometimes don't do things in the most "proper" or efficient
way, but I am more than competent in the language.
What I have found out in recent learning is that calling a nested function in the manner "function1.function2()" actually is not supported within javascript itself, the reason I thought it was is that when I was first making my extension I was using Dreamweaver MX and for some reason it worked flawlessly. Although, now having upgraded to version 8 I realize they don't work quite as I thought.
Now what I am looking for is sort of a "best practices" help from other experienced javascripters on how to create two sets of functions with the same goal yet different methods of getting to that goal. And as I have already created one of the sets I would rather not have to do something to every function, and I was hoping there was a broader way of going about this.
Any help that can be provided on this would be much appreciated.
What I have found out in recent learning is that calling a nested function in the manner "function1.function2()" actually is not supported within javascript itself, the reason I thought it was is that when I was first making my extension I was using Dreamweaver MX and for some reason it worked flawlessly. Although, now having upgraded to version 8 I realize they don't work quite as I thought.
Now what I am looking for is sort of a "best practices" help from other experienced javascripters on how to create two sets of functions with the same goal yet different methods of getting to that goal. And as I have already created one of the sets I would rather not have to do something to every function, and I was hoping there was a broader way of going about this.
Any help that can be provided on this would be much appreciated.
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more

