473,406 Members | 2,378 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

Look Up Table Help

Here is my code for look up table - where i am planning to built 10 colums and 8 rows and put [x,y] array values in the table boxes. Problem is - it is only printing the last array valules instead of all

Expand|Select|Wrap|Line Numbers
  1.     var maxRow = 10;
  2.     var maxCol = 8;
  3.     var height1 = 480;
  4.     var width1 = 640;
  5.  
  6. function CenteringError(Xe, Ye){
  7.  
  8. var table = new Array             ( ([5,0],    [2,-3],    [2,-3],    [1,-2],    [0,-2],    [0,-1],    [1,-1],    [1,-1],    [0,-1],    [-5,2]),
  9.                                                             ([3,-2],   [-1,-3],   [-1,-3],   [1,-2],    [-1,-2],   [1,-1],    [1,-1],    [2,-2],    [2,-2],    [-3,-1]),
  10.                                                             ([1,-3],   [-2,-3],   [-2,-3],   [-2,-2],   [-1,-2],   [0,0],     [1,-1],    [2,-1],    [2,-1],    [1,-2]),
  11.                                                             ([-2,0],   [-2,-1],   [-2,-1],   [-2,0],    [-1,0],    [1,0],     [2,0],     [2,0],     [2,0],     [2,0]),
  12.                                                             ([-2,-1],  [-2,-1],   [-2,-1],   [-2,0],    [-1,0],    [1,0],     [3,0],     [2,1],     [2,1],     [2,0]),
  13.                                                             ([-1,1],   [-2,0],    [-2,0],    [-2,1],    [-1,1],    [1,1],     [2,1],     [2,1],     [2,2],     [1,2]),
  14.                                                             ([-1,2],   [-2,1],    [-2,1],    [-2,1],    [-1,2],    [-1,1],    [1,1],     [1,3],     [1,2],     [-2,3]),
  15.                                                             ([4,1],    [0,0],     [-1,0],    [-1,0],    [-1,0],    [0,2],     [0,1],     [-1,2],    [-1,3],    [-4,2])
  16.                                                         );
  17. var correct = [0,0];
  18.  
  19. //this math function gets mouse pos and builts Rows and Colums in Viewer
  20.  
  21. correct[0] = table[Math.round((maxRow* Ye)/height1)];
  22. correct[1] = table[Math.round((maxCol* Xe)/width1)];
  23.  
  24. var x = correct[0];
  25. var y = correct[1];
  26.  
  27. alert(x + "     " + y);
  28. }
  29.  
I am alerting x and y values but it only prints certain numbers and repeats it. This program is not working properly. I dont know why.

Help would be appreciated...

Thanks
May 14 '08 #1
2 1215
rnd me
427 Expert 256MB
change your parens to array brackets and try again.
May 15 '08 #2
acoder
16,027 Expert Mod 8TB
Harshpandya, please enclose your posted code in [code] tags (See How to Ask a Question).

This makes it easier for our Experts to read and understand it. Failing to do so creates extra work for the moderators, thus wasting resources, otherwise available to answer the members' questions.

Please use [code] tags in future. Thanks!
May 15 '08 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: FAQPoster | last post by:
An HTML version of this document is available at: http://www.mvps.org/access/netiquette.htm Feeling left out? Alone? Wondering why everyone's ignoring you? Or why you're being flamed for what...
0
by: FAQPoster | last post by:
An HTML version of this document is available at: http://www.mvps.org/access/netiquette.htm Feeling left out? Alone? Wondering why everyone's ignoring you? Or why you're being flamed for what...
0
by: FAQPoster | last post by:
An HTML version of this document is available at: http://www.mvps.org/access/netiquette.htm Feeling left out? Alone? Wondering why everyone's ignoring you? Or why you're being flamed for what...
0
by: FAQPoster | last post by:
An HTML version of this document is available at: http://www.mvps.org/access/netiquette.htm Feeling left out? Alone? Wondering why everyone's ignoring you? Or why you're being flamed for what...
0
by: FAQPoster | last post by:
An HTML version of this document is available at: http://www.mvps.org/access/netiquette.htm Feeling left out? Alone? Wondering why everyone's ignoring you? Or why you're being flamed for what...
0
by: FAQPoster | last post by:
An HTML version of this document is available at: http://www.mvps.org/access/netiquette.htm Feeling left out? Alone? Wondering why everyone's ignoring you? Or why you're being flamed for what...
0
by: FAQPoster | last post by:
An HTML version of this document is available at: http://www.mvps.org/access/netiquette.htm Feeling left out? Alone? Wondering why everyone's ignoring you? Or why you're being flamed for what...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.