View Full Version : Feeling Stoopid
GateKeeper
09-08-2002, 11:05 PM
It is not being a good hair day today. . . but where can I find info on the do/while statement?
GK
Spookster
09-08-2002, 11:11 PM
A do/while loop feature is pretty general in any programming language so just ask specific questions. In the meantime here is the exerpt from the manual:
http://developer.netscape.com/docs/manuals/communicator/jsguide/states.htm#1005592
GateKeeper
09-08-2002, 11:14 PM
I knew it was pretty simpe, but for some reason my brain seems to be on vacation. Thanks!
GK
GateKeeper
09-08-2002, 11:32 PM
okay, here is the script I am using, what I want it to do is wait until there are values other than zero for the dx, dy, ox and oy coords. For some reason, it is jumping right to the distance calculation as soon as a single click event occurs. what have I got wrong in this?
<script language="javascript">
var dxcoord = 0
var dycoord = 0
var oxcoord = 0
var oycoord = 0
var dist = 0
function getpoints()
{
do
{
if (window.event.shiftKey == true)
{
dxcoord=window.event.offsetX
dycoord=window.event.offsetY
}
else
{
oxcoord=window.event.offsetX
oycoord=window.event.offsetY
}
}
while (dxcoord!=0 && dycoord!=0 && oxcoord!=0 && oycoord!=0)
finddist()
}
function finddist()
{
dist=Math.sqrt(Math.pow((oxcoord-dxcoord),2)-Math.pow((oycoord-dycoord),2))
display()
}
function display()
{
document.write('The distance between point '+oxcoord+','+oycoord+' and point '+dxcoord+','+dycoord+' is '+dist+' pixels')
}
</script>
vBulletin® v3.8.2, Copyright ©2000-2012, Jelsoft Enterprises Ltd.