473,698 Members | 2,440 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

integers and arrays in Java - how?

I used Google and found some references for integer in Java.
But "int" not only does not work, it also prevents reading X and Y
coordinates of the mouse.
What i would like to do:
1) Get X and Y mouse coordinates into a variable that i can do real math on.
So far, i can do math on the values "read" and that result goes into
a "variable" that is useful *only* for display.
If i try "int" in that math, the values are then zero for everything
- even those where i do no calculation.
2) Use the calculated integer values as an index to a table or array.
It is acceptable to use an HTML "table" as the source for the lookup;
W(CalcFromX) and P(CalcFromX) would be the resulting values to be
displayed on the screen somewhere.

Can this be done, and eXactly how?
Mar 30 '06
36 2072
VK

Robert Baer wrote:
I used Google and found some references for integer in Java.
But "int" not only does not work, it also prevents reading X and Y
coordinates of the mouse.
What i would like to do:
1) Get X and Y mouse coordinates into a variable that i can do real math on.
So far, i can do math on the values "read" and that result goes into
a "variable" that is useful *only* for display.
If i try "int" in that math, the values are then zero for everything
- even those where i do no calculation.
2) Use the calculated integer values as an index to a table or array.
It is acceptable to use an HTML "table" as the source for the lookup;
W(CalcFromX) and P(CalcFromX) would be the resulting values to be
displayed on the screen somewhere.


Sorry but you are looking like Rad Hat in that dark forest - lost any
coordinates of anything.

Shockwave #1
JavaScript is not Java (despite the equal first syllable). Unlike Java
- JavaScript is a loose typed language with current variable type
interpreted based on the current variable value.

Shockwave #2
JavaScript execution environment (where var c = a+b) is completely
separate from DOM (Document Object Model) where say mouse pointer is
hanging out over x120 y220 where element with id "myStuff" happened to
be located.

Truthfully I am not even sure that your problem is within JavaScript -
because it can be interpreted as a misplaced *Java* question.

If it is not, please narrow your problem description to a particular
language with a possible code stamp / URL/

Mar 31 '06 #11
Robert Baer wrote:
I used Google and found some references for integer in Java.
But "int" not only does not work, it also prevents reading X and Y
coordinates of the mouse.
What i would like to do:
1) Get X and Y mouse coordinates into a variable that i can do real math
on.
So far, i can do math on the values "read" and that result goes into a
"variable" that is useful *only* for display.
If i try "int" in that math, the values are then zero for everything -
even those where i do no calculation.
2) Use the calculated integer values as an index to a table or array.
It is acceptable to use an HTML "table" as the source for the lookup;
W(CalcFromX) and P(CalcFromX) would be the resulting values to be
displayed on the screen somewhere.

Can this be done, and eXactly how? Here is the code i have so far:
<html code starts here; this is altered to help protect some>
<head>
<title>Test page</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link rel="stylesheet " type="text/css" href="style.css ">
</head>

<!--
var with "Netscape" makes Netscape happy
adding "int" or "integer" in any way totally kills operation
-->
<SCRIPT LANGUAGE="JavaS cript">
<!--
var isNav = (navigator.appN ame.indexOf("Ne tscape") !=-1);
function handlerMM(e){
Xmm = (isNav) ? e.pageX : event.clientX;
Ymm = (isNav) ? e.pageY : event.clientY;
document.dataho lder.mmX.value= ((Xmm-173)/6.8+1938);
document.dataho lder.mmY1.value =Ymm;
document.dataho lder.mmY2.value =Xmm;
document.dataho lder.mmZ.value= ((Xmm-173)/6.8+1938);
}
if (isNav) {
document.captur eEvents(Event.M OUSEMOVE);
}
document.onmous emove = handlerMM;
// -->
</SCRIPT>

<body>
<center>
<form name="dataholde r">
<table border=1>
<tr>
<td><i>Year(wid e)</i></td>
<td><input type="text" size=9 name="mmX" value="0"></td>
<td><i>Year(nar row)</i></td>
<td><input type="number" size=3.8 name="mmX" value="0"></td>
<td><i>Number of wells</i></td>
<td><input type="text" size=5 name="mmY1" value="0"></td>
<td><i>Producti on BBLs</i></td>
<td><input type="text" size=5 name="mmY2" value="0"></td>
<td><i>Z value</i></td>
<td><input type="text" size=9 name="mmZ" value="0"></td>
</tr>
</table>
</form>
</div>

<!--
This code *used to* work, showing a calculated year in the first 2 boxes; the width
of the second box was made narrow to visually "truncate" the numbers to integer.
I have no idea as to why they no longer work.
I added "Z value" and *that* works (!!). Go figure.
-->

<table align="center">
<tr>
<td align=center>
<center>
<div><i>&copy 2006 Oil 4 Less LLC</i></div>
</center>
</td>
</tr>
</table>

<!-- style and then img src as seperate items makes IE happy; GIF is 90% BMP -->
<div style="position : absolute; height: 316px; width: 697px; top: 100px; left: 20px; "
<style="heigh t: 316px; width: 697px; top: 100px; left: 20px; " >
<img src="Arkansas.g if" alt="" usemap="#AK" style="border-style:none" >
</div>

</body>
</html>

Mar 31 '06 #12
Randy Webb wrote:
Robert Baer said the following on 3/31/2006 6:28 AM:
Randy Webb wrote:
Thomas 'PointedEars' Lahn said the following on 3/30/2006 12:42 PM:

RobG wrote:

> Robert Baer wrote:
>
>> But "int" not only does not work, it also prevents reading X and
>> Y coordinates of the mouse.
>
>
> There is no 'int' type in JavaScript. Variables are typeless, their
> values have types.

Not quite true. There is an `int' type, and variables can be strictly
typed, in JavaScript 2.0. However, that is not implemented in a
browser
yet.

And as such, even mentioning it is useless other than a waste of
bandwidth and time for anybody who reads it.

Incorrect; the info explained why i had so much trouble.

You had trouble because you were using, or attempting to use, a feature
that is not part of the language. Not because of a feature that might be
in a future release of the language unless you were reading a draft copy
of JavaScript2.0 in which case you should have known it wasn't in use yet.

I had no idea that the "int" "feature" was not a part of the language.
I consider that short-sighted at best and ignorantly stupid.
All languages i have seen or heard of that pretend to do some math
*have* either different numeric variable types, or type conversion
(almost always both).
And that has been the case before the PCs came out (1980)!
Draft copy? You mean that there is some kind of (?readable and
understandable? ) document that covers Java?
Would such a thing help me?
Mar 31 '06 #13
VK wrote:
Robert Baer wrote:
I used Google and found some references for integer in Java.
But "int" not only does not work, it also prevents reading X and Y
coordinates of the mouse.
What i would like to do:
1) Get X and Y mouse coordinates into a variable that i can do real math on.
So far, i can do math on the values "read" and that result goes into
a "variable" that is useful *only* for display.
If i try "int" in that math, the values are then zero for everything
- even those where i do no calculation.
2) Use the calculated integer values as an index to a table or array.
It is acceptable to use an HTML "table" as the source for the lookup;
W(CalcFromX ) and P(CalcFromX) would be the resulting values to be
displayed on the screen somewhere.

Sorry but you are looking like Rad Hat in that dark forest - lost any
coordinates of anything.

Shockwave #1
JavaScript is not Java (despite the equal first syllable). Unlike Java
- JavaScript is a loose typed language with current variable type
interpreted based on the current variable value.

Shockwave #2
JavaScript execution environment (where var c = a+b) is completely
separate from DOM (Document Object Model) where say mouse pointer is
hanging out over x120 y220 where element with id "myStuff" happened to
be located.

Truthfully I am not even sure that your problem is within JavaScript -
because it can be interpreted as a misplaced *Java* question.

If it is not, please narrow your problem description to a particular
language with a possible code stamp / URL/

I have posted a reply that includes the code i am presently trying.
It seems i am using Java Script, inside HTML code in an attempt to do
something.
If anyone has used Excel to create a chart, and then "visits" a dot
or point on that chart, a yellow box shows up giving the value of that
point.
*That* is what i want to do, or an equivalent.
Mar 31 '06 #14
Robert Baer wrote:
Randy Webb wrote:
Robert Baer said the following on 3/31/2006 6:28 AM:
Randy Webb wrote:
Thomas 'PointedEars' Lahn said the following on 3/30/2006 12:42 PM:
> RobG wrote:
>> There is no 'int' type in JavaScript. Variables are typeless, their
>> values have types.
> Not quite true. There is an `int' type, and variables can be strictly
> typed, in JavaScript 2.0. However, that is not implemented in a
> browser
> yet.
And as such, even mentioning it is useless other than a waste of
bandwidth and time for anybody who reads it.
Incorrect; the info explained why i had so much trouble. You had trouble because you were using, or attempting to use, a feature
that is not part of the language. Not because of a feature that might be
in a future release of the language unless you were reading a draft copy
of JavaScript2.0 in which case you should have known it wasn't in use
yet.


I had no idea that the "int" "feature" was not a part of the language.


AFAIK, it is merely not part of a language version that is implemented _in
Web browsers_. You could have RTFM first, and even if you had not, you
could have read and followed <URL:http://jibbering.com/faq/#FAQ4_43> before
you posted anything.
I consider that short-sighted at best and ignorantly stupid.
You should reconsider that. The dynamic nature of J(ava)Script versions,
and other implementations of ECMAScript Editions 1 to 3, made it possible
that they became such widely supported languages.

See also <URL:http://www.mindview.ne t/WebLog/log-0025>
All languages i have seen or heard of that pretend to do some math
*have* either different numeric variable types, or type conversion
(almost always both).
J(ava)Script implemented client-side *has* type conversion, both explicit
and implicit.
And that has been the case before the PCs came out (1980)!
Are you trolling, or are you just seeking another opportunity to demonstrate
your incompetence in public? ...
Draft copy? You mean that there is some kind of (?readable and
understandable? ) document that covers Java?
.... Oh well, apparently the latter. The first thing you have to understand
is that JavaScript is not Java. That is *beginner's knowledge*, you know.
Would such a thing help me?


If you would develop using a language that implements it, such as
Microsoft JScript.NET (AFAIK server-side only), it certainly would.
PointedEars
Mar 31 '06 #15
Robert Baer wrote:
It seems i am using Java Script, [...]


Yes, it only seems to be so. There is no "Java Script".
See my other followup.
PointedEars
Apr 1 '06 #16
Robert Baer wrote:
[...]
What you have given looks like it may be very useful; i had no idea
that different browsers would have to be treated differently.
The posted code deals with the two most common cases, it should work in
just about any post-version 4 browser with scripting enabled.

I do know that there are webpages that are browser *hostile* (causes
them to hang and requires a power off reset); those &^%#$&#$ pages work
only with InfuriatingExas perator.
In the early days of scripted browsers, MS headed off at 1,000kph to do
their own thing without thinking too clearly - flooding the browser script
environment with everything they could think of - in an attempt to
overwhelm Netscape. It achieved the business outcome they were after at
the expense of everything else. Now we live with that legacy.

Some of the stuff they added is good, some has been standardised and some
is downright garbage. But MS refuse to orphan any of their legacy stuff
and many old pages haven't been updated, so there is a significant inertia
to overcome before the old stuff gets cleaned up.

But that seems to be changing, or at least moving on. No doubt a similar
battle will ensue if Google or someone similar ever deliver a reasonable
on-line web application.

Can the Mafia be hired for a hit on M$?
Why bother? Outside their Windows and Office franchises, they are just
another (very well funded) competitor.

Better yet, can a few good programmers be hired to make an OS like
Windows that accepts all the programs that WinQQ without the bloat and
bugs?
The next task would be a decent bug-free browser that follows all of
the standards.


There are browsers that follow standards much more closely and fully than
IE (most are already ahead of the yet-to-be-officially-released IE 7), but
none that fully and faultlessly implement everything W3C/ECMA. There
likely never will be.
--
Rob
Apr 1 '06 #17
Thomas 'PointedEars' Lahn wrote:
Robert Baer wrote:

Randy Webb wrote:
Robert Baer said the following on 3/31/2006 6:28 AM:

Randy Webb wrote:

>Thomas 'PointedEars' Lahn said the following on 3/30/2006 12:42 PM:
>
>>RobG wrote:
>>
>>>There is no 'int' type in JavaScript. Variables are typeless, their
>>>values have types.
>>
>>Not quite true. There is an `int' type, and variables can be strictly
>>typed, in JavaScript 2.0. However, that is not implemented in a
>>browser
>>yet.
>
>And as such, even mentioning it is useless other than a waste of
>bandwidt h and time for anybody who reads it.

Incorrect; the info explained why i had so much trouble.

You had trouble because you were using, or attempting to use, a feature
that is not part of the language. Not because of a feature that might be
in a future release of the language unless you were reading a draft copy
of JavaScript2.0 in which case you should have known it wasn't in use
yet.
I had no idea that the "int" "feature" was not a part of the language.

AFAIK, it is merely not part of a language version that is implemented _in
Web browsers_. You could have RTFM first, and even if you had not, you
could have read and followed <URL:http://jibbering.com/faq/#FAQ4_43> before
you posted anything.

** ?RTFM? what is that? And how would a complete newbie know where to
look or know anything about that URL?

I consider that short-sighted at best and ignorantly stupid.

You should reconsider that. The dynamic nature of J(ava)Script versions,
and other implementations of ECMAScript Editions 1 to 3, made it possible
that they became such widely supported languages.

See also <URL:http://www.mindview.ne t/WebLog/log-0025>
All languages i have seen or heard of that pretend to do some math
*have* either different numeric variable types, or type conversion
(almost always both).

J(ava)Script implemented client-side *has* type conversion, both explicit
and implicit.

** Well, i would like to learn about how that can be done.
Any suggestions, since "int" or "integer" does not work?

And that has been the case before the PCs came out (1980)!

Are you trolling, or are you just seeking another opportunity to demonstrate
your incompetence in public? ...

Draft copy? You mean that there is some kind of (?readable and
understandabl e?) document that covers Java?

... Oh well, apparently the latter. The first thing you have to understand
is that JavaScript is not Java. That is *beginner's knowledge*, you know.

** Well, i *now* know that, but was not aware of the distinction earlier.
Incompetent? Well,concerning Java Script, absolutely *yes*, hence the
dumb questions.

Would such a thing help me?

If you would develop using a language that implements it, such as
Microsoft JScript.NET (AFAIK server-side only), it certainly would.

** Only interested i client side - *unless* - you know that it would be
easier to do a server side implimentation and can tell me how i get
someone's server to do whatever tricks are needed...


PointedEars

Apr 1 '06 #18
Thomas 'PointedEars' Lahn wrote:
Robert Baer wrote:

It seems i am using Java Script, [...]

Yes, it only seems to be so. There is no "Java Script".
See my other followup.
PointedEars

Well, i am using some kind of Java code of some sort...
And you mentioned Java Script 2.0 so one might conclude that either
it does exist or that someone is a liar somewhere...
Apr 1 '06 #19
RobG wrote:
Robert Baer wrote:
[...]
What you have given looks like it may be very useful; i had no idea
that different browsers would have to be treated differently.

The posted code deals with the two most common cases, it should work in
just about any post-version 4 browser with scripting enabled.

I do know that there are webpages that are browser *hostile* (causes
them to hang and requires a power off reset); those &^%#$&#$ pages
work only with InfuriatingExas perator.

In the early days of scripted browsers, MS headed off at 1,000kph to do
their own thing without thinking too clearly - flooding the browser
script environment with everything they could think of - in an attempt
to overwhelm Netscape. It achieved the business outcome they were after
at the expense of everything else. Now we live with that legacy.

Some of the stuff they added is good, some has been standardised and
some is downright garbage. But MS refuse to orphan any of their legacy
stuff and many old pages haven't been updated, so there is a significant
inertia to overcome before the old stuff gets cleaned up.

But that seems to be changing, or at least moving on. No doubt a
similar battle will ensue if Google or someone similar ever deliver a
reasonable on-line web application.

Can the Mafia be hired for a hit on M$?

Why bother? Outside their Windows and Office franchises, they are just
another (very well funded) competitor.

Better yet, can a few good programmers be hired to make an OS like
Windows that accepts all the programs that WinQQ without the bloat and
bugs?
The next task would be a decent bug-free browser that follows all of
the standards.

There are browsers that follow standards much more closely and fully
than IE (most are already ahead of the yet-to-be-officially-released IE
7), but none that fully and faultlessly implement everything W3C/ECMA.
There likely never will be.

Well, closer implimentation would be nice, but having thousands of
potential customers complaining to each browser-hostile URL owner (and
taking their business elsewhere) would seem to be even better.
Apr 1 '06 #20

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

12
885
by: Elijah Bailey | last post by:
I have two char arrays of size k. I want to know which one is bigger (exactly like for instance I compare two ints/longs/etc.). What is the fastest way to do this? k <= 10 usually for my application. I tried bcmp / a loop for comparison, but it seems they are very slow compared to comparing longs...Any ideas? I tried splitting the array into longs and comparing, but then I face the high endian/low endian problem on some machines.
16
3382
by: aruna | last post by:
Given a set of integers, how to write a program in C to sort these set of integers using C, given the following conditions a. Do not use arrays b. Do not use any comparison function like if/then or switch-case c. you can use pointers only d. you cannot use any of the loops either.
15
6994
by: Paul Morrison | last post by:
Hi all, I need to come up with some differences between arrays in Java and C, I have searched Google and so far all I have found is the following: Arrays in Java are reference types with automatic allocation of memory. In C, arrays are groups of variables of the same type in adjacent memory. Allocation for dynamic arrays is handled by the programmer. This is an 8 mark question in an old exam paper, so I am assuming there are
3
7066
by: John Bend | last post by:
Hello. Can anyone please suggest some good tutorial links where Java Vectors and Arrays are explained and compared? I'm a proficient programmer but fairly new to Java. Whilst I understand arrays I don't fully understand Vectors and when to use them. Many thanks.
1
8703
by: Rob Griffiths | last post by:
Can anyone explain to me the difference between an element type and a component type? In the java literature, arrays are said to have component types, whereas collections from the Collections Framework are said to have an element type. http://java.sun.com/docs/books/jls/second_edition/html/arrays.doc.html
17
3580
by: Robert Baer | last post by:
I used Google and found some references for integer in Java. But "int" not only does not work, it also prevents reading X and Y coordinates of the mouse. What i would like to do: 1) Get X and Y mouse coordinates into a variable that i can do real math on. So far, i can do math on the values "read" and that result goes into a "variable" that is useful *only* for display. If i try "int" in that math, the values are then zero for everything...
1
4672
by: susheela s | last post by:
Hi, Im doing a multiplication of two large integers which are store in arrays(such as 2345 is in array as 2 in a, 3 in a and so on)like this im storing integers in two arrays.The logic i have used is explained with code below, class large{ int no; //array is used to store the large number. Each digit of a the number is stored as an element.. // 123 is stored as no={1,2,3} public: large operator *(large& x){ // overload...
0
8676
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9161
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8897
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8867
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7732
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6522
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5860
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4370
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
3050
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.