Connecting Tech Pros Worldwide Help | Site Map

Virtual function ?

 
LinkBack Thread Tools Search this Thread
  #1  
Old February 10th, 2006, 04:45 PM
David
Guest
 
Posts: n/a
Default Virtual function ?

Hi,

I have an interesting problem. I have created an html based interface that
links to an external .js file with only functions in it. The functions set
an arrays values depending on which function is called by the interface....

The external .js file looks like this below:

function myFunction1(){
arryEntry[0] = "some value1";
arryEntry[1] = "some value2";
arryEntry[2] = "some value3";
arryEntry[3] = "some value4";
}

function myFunction2(){
arryEntry[0] = "other value1";
arryEntry[1] = "other value2";
arryEntry[2] = "other value3";
arryEntry[3] = "other value4";
}
etc...

In the html interface I am calling the function(s) depending on a list
selection. This functions one arg (functionNumber) depends on a list
selection.

function getArryEntries(functionNumber){
eval("myFunction"+parseInt(functionNumber)+"()");
var value0 = arryEntry[0];
var value1 = arryEntry[1];
var value2 = arryEntry[2];
var value3 = arryEntry[3];
}

This all works well so far and the array entries are changed successfully
depending on the getArryEntries(functionNumber) selection.

However, at some time in the session I am adding (actually writing)
additional functions to the external .js file. Appending to the file. The
problem is that the interface will not pick up the newly written functions
on runtime. If the interface is closed and opened again, then it can see the
new functions.

I thought of initiating an array of the existing functions when the
interface loads and append to the array when the new functions are created.
It would then write to the file, but use the array at runtime. No success so
far.

What would be recommended here?

Thanks
David


















  #2  
Old February 11th, 2006, 12:05 AM
David
Guest
 
Posts: n/a
Default Re: Virtual function ?

I found a solution. When loading the interface I am reading the external .js
file and have used RegExps to extract the values from each of the functions
in the external file. For each group of these values I place an entry in a
new Array() ...

var groupVals = new Array();
groupVals [0] = "some value1","some value2","some value3","some
value4";
groupVals [1] = "other value1","other value2","other value3","other
value4";
groupVals [2] = "other value1","other value2","other value3","other
value4";
etc...

New entires that are now added are written to the external file and at the
same time, appending to the groupVals array. I don't have to worry about
accessing the actual external file for the values when new ones are added to
it. Now I have all of the original data plus any new data added, from which
I can use at runtime. The next time the interface launches it will have the
new data written to it and it starts the process all over again.

var groupNeeded = groupVals[0][0];
var groupNeeded = groupVals[0][1];
var groupNeeded = groupVals[0][2];
etc...

Thought I would share my solution.

David





 

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Popular Articles

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over 220,989 network members.