• Log InLog In
  • Register
Liquid`
Team Liquid Liquipedia
EDT 20:09
CEST 02:09
KST 09:09
  • Home
  • Forum
  • Calendar
  • Streams
  • Liquipedia
  • Features
  • Store
  • EPT
  • TL+
  • StarCraft 2
  • Brood War
  • Smash
  • Heroes
  • Counter-Strike
  • Overwatch
  • Liquibet
  • Fantasy StarCraft
  • TLPD
  • StarCraft 2
  • Brood War
  • Blogs
Forum Sidebar
Events/Features
News
Featured News
Team TLMC #5 - Finalists & Open Tournaments0[ASL20] Ro16 Preview Pt2: Turbulence9Classic Games #3: Rogue vs Serral at BlizzCon9[ASL20] Ro16 Preview Pt1: Ascent10Maestros of the Game: Week 1/Play-in Preview12
Community News
Weekly Cups (Sept 8-14): herO & MaxPax split cups4WardiTV TL Team Map Contest #5 Tournaments1SC4ALL $6,000 Open LAN in Philadelphia8Weekly Cups (Sept 1-7): MaxPax rebounds & Clem saga continues29LiuLi Cup - September 2025 Tournaments3
StarCraft 2
General
#1: Maru - Greatest Players of All Time Weekly Cups (Sept 8-14): herO & MaxPax split cups Team Liquid Map Contest #21 - Presented by Monster Energy SpeCial on The Tasteless Podcast Team TLMC #5 - Finalists & Open Tournaments
Tourneys
Maestros of The Game—$20k event w/ live finals in Paris SC4ALL $6,000 Open LAN in Philadelphia Sparkling Tuna Cup - Weekly Open Tournament WardiTV TL Team Map Contest #5 Tournaments RSL: Revival, a new crowdfunded tournament series
Strategy
Custom Maps
External Content
Mutation # 491 Night Drive Mutation # 490 Masters of Midnight Mutation # 489 Bannable Offense Mutation # 488 What Goes Around
Brood War
General
BW General Discussion [ASL20] Ro16 Preview Pt2: Turbulence ASL20 General Discussion Diplomacy, Cosmonarchy Edition BGH Auto Balance -> http://bghmmr.eu/
Tourneys
[ASL20] Ro16 Group D [ASL20] Ro16 Group C [Megathread] Daily Proleagues SC4ALL $1,500 Open Bracket LAN
Strategy
Simple Questions, Simple Answers Muta micro map competition Fighting Spirit mining rates [G] Mineral Boosting
Other Games
General Games
Path of Exile Stormgate/Frost Giant Megathread General RTS Discussion Thread Nintendo Switch Thread Borderlands 3
Dota 2
Official 'what is Dota anymore' discussion LiquidDota to reintegrate into TL.net
League of Legends
Heroes of the Storm
Simple Questions, Simple Answers Heroes of the Storm 2.0
Hearthstone
Heroes of StarCraft mini-set
TL Mafia
TL Mafia Community Thread
Community
General
Things Aren’t Peaceful in Palestine US Politics Mega-thread Canadian Politics Mega-thread Russo-Ukrainian War Thread The Big Programming Thread
Fan Clubs
The Happy Fan Club!
Media & Entertainment
Movie Discussion! [Manga] One Piece Anime Discussion Thread
Sports
2024 - 2026 Football Thread Formula 1 Discussion MLB/Baseball 2023
World Cup 2022
Tech Support
Linksys AE2500 USB WIFI keeps disconnecting Computer Build, Upgrade & Buying Resource Thread High temperatures on bridge(s)
TL Community
BarCraft in Tokyo Japan for ASL Season5 Final The Automated Ban List
Blogs
The Personality of a Spender…
TrAiDoS
A very expensive lesson on ma…
Garnet
hello world
radishsoup
Lemme tell you a thing o…
JoinTheRain
RTS Design in Hypercoven
a11
Evil Gacha Games and the…
ffswowsucks
Customize Sidebar...

Website Feedback

Closed Threads



Active: 1266 users

The Big Programming Thread - Page 146

Forum Index > General Forum
Post a Reply
Prev 1 144 145 146 147 148 1031 Next
Thread Rules
1. This is not a "do my homework for me" thread. If you have specific questions, ask, but don't post an assignment or homework problem and expect an exact solution.
2. No recruiting for your cockamamie projects (you won't replace facebook with 3 dudes you found on the internet and $20)
3. If you can't articulate why a language is bad, don't start slinging shit about it. Just remember that nothing is worse than making CSS IE6 compatible.
4. Use [code] tags to format code blocks.
green.at
Profile Blog Joined January 2010
Austria1459 Posts
June 23 2012 20:00 GMT
#2901
does anyone have experience with multi-agent development, especially with JADE? If so, do you know how to connect directly to another platform over the net?
Inputting special characters into chat should no longer cause the game to crash.
ranshaked
Profile Blog Joined August 2010
United States870 Posts
Last Edited: 2012-06-24 03:24:05
June 24 2012 03:03 GMT
#2902
On June 22 2012 07:00 Abductedonut wrote:
Show nested quote +
On June 22 2012 06:12 ranshaked wrote:
I'm typing from my phone, so please bare with me. I had an assignment that I handed in that was not complete because I could not figure out how to do division. Basically the assignment is like this:
Randomly generate a math sign (+*/-) and two random numbers and ask the user to solve the problem. Everything works properly except the division. I know that it is because I'm using integers, but when I caste them as floats in my if or switch statements (tried both) it either gets 0.000000 all the time or it messes up the other integers. The final line needs to print the answer. Because it is random, I'm struggling with the final answer, everything will wok except division

I'll post the code later. Thanks


I whipped up some quick code for you. It's by no means pretty. Here you go. Assuming you're using C, same principles should apply in C++. Next time, specify which language you use!

+ Show Spoiler +


#include <stdio.h>
#include <stdlib.h>
#include <time.h>

int main(int argc, char *argv[]
{
int randomNum = 0, randomNum2 = 0, mathOperator = 0;
float result = 0, answer = 0;
srand ( time(NULL) );

char map[4] = {'-','+','*','/'};

while( 1 )
{
randomNum = rand()%100; //Truncated it to a limit of 100, so that you don't get ridiculous numbers...
printf("%i ",randomNum);
mathOperator = rand()%4;
printf("%c ",map[mathOperator] );
randomNum2 = rand()%100;
printf("%i",randomNum2);

switch ( map[mathOperator] )
{
case '-':
result = randomNum - randomNum2;
break;
case '+':
result = randomNum + randomNum2;
break;
case '*':
result = randomNum * randomNum2;
break;
case '/':
result = (float)randomNum / ( (float)randomNum2 );
printf(" Result is: %f ",result);
break;
}

//How come the divison never works??
//It's because of round-off errors within the computer. Trying looking at:
//http://www.cygnus-software.com/papers/comparingfloats/comparingfloats.htm
printf(" \nWhat is the answer? ");
scanf("%f",&answer);
printf("you entered: %f \n",answer);
fflush(stdin);

if ( answer == result )
printf("Correct! \n");
}

return 0;
}



The basic idea between comparing floats is that you must have a general "error" range that you're okay with.

Most floats, when printed, will get rounded off. So it may seem like the answer is 1.3333334 but in memory its actually stored as 1.333333333333333333333. So when you do the comparison, it gets jacked up. Read the article I commented in the code.

Also, does anyone have expierence with Microsoft's Media Foundation? I've been trying to use MF to capture to a hwnd using D3D and I'm having a really hard time. Would appreciate any help.



Thank you very much, it definitely helped. Would also happen to know why when I type in an answer to a division problem exactly the way I printf the answer, that it still doesn't read it in as correct? Basically this is what is happening: I'll post an image. I have it set to debug in which it gives me the answer, then I type in the answer and it should say "correct!", but for some reason, I type in EXACTLY what it prints out the answer to be, and it's still reading it as wrong. Here's an image.
[image loading]

Thanks. I've tried using %.2f to limit it, %f, %lf and it's always random, some division problems will read my answers properly, and some won't. I marked the two that are not are opposite

Edit: I'm reading that you cannot directly compare floats :/ unless you use a function, but unfortunately I was never taught this!

Edit again: This happens with both your code, and my original "if" statements. The problem is this: If it's not division, the answer has to be an integer, but if it's division it has to be two decimal places, like 2.12...

When you're casting floats or doubles with (double) x / ((double)y) can you cast that directly to two decimal places? Like doing (double.2)x ?
Abductedonut
Profile Blog Joined December 2010
United States324 Posts
Last Edited: 2012-06-24 03:56:19
June 24 2012 03:54 GMT
#2903
On June 24 2012 12:03 ranshaked wrote:
Show nested quote +
On June 22 2012 07:00 Abductedonut wrote:
On June 22 2012 06:12 ranshaked wrote:
I'm typing from my phone, so please bare with me. I had an assignment that I handed in that was not complete because I could not figure out how to do division. Basically the assignment is like this:
Randomly generate a math sign (+*/-) and two random numbers and ask the user to solve the problem. Everything works properly except the division. I know that it is because I'm using integers, but when I caste them as floats in my if or switch statements (tried both) it either gets 0.000000 all the time or it messes up the other integers. The final line needs to print the answer. Because it is random, I'm struggling with the final answer, everything will wok except division

I'll post the code later. Thanks


I whipped up some quick code for you. It's by no means pretty. Here you go. Assuming you're using C, same principles should apply in C++. Next time, specify which language you use!

+ Show Spoiler +


#include <stdio.h>
#include <stdlib.h>
#include <time.h>

int main(int argc, char *argv[]
{
int randomNum = 0, randomNum2 = 0, mathOperator = 0;
float result = 0, answer = 0;
srand ( time(NULL) );

char map[4] = {'-','+','*','/'};

while( 1 )
{
randomNum = rand()%100; //Truncated it to a limit of 100, so that you don't get ridiculous numbers...
printf("%i ",randomNum);
mathOperator = rand()%4;
printf("%c ",map[mathOperator] );
randomNum2 = rand()%100;
printf("%i",randomNum2);

switch ( map[mathOperator] )
{
case '-':
result = randomNum - randomNum2;
break;
case '+':
result = randomNum + randomNum2;
break;
case '*':
result = randomNum * randomNum2;
break;
case '/':
result = (float)randomNum / ( (float)randomNum2 );
printf(" Result is: %f ",result);
break;
}

//How come the divison never works??
//It's because of round-off errors within the computer. Trying looking at:
//http://www.cygnus-software.com/papers/comparingfloats/comparingfloats.htm
printf(" \nWhat is the answer? ");
scanf("%f",&answer);
printf("you entered: %f \n",answer);
fflush(stdin);

if ( answer == result )
printf("Correct! \n");
}

return 0;
}



The basic idea between comparing floats is that you must have a general "error" range that you're okay with.

Most floats, when printed, will get rounded off. So it may seem like the answer is 1.3333334 but in memory its actually stored as 1.333333333333333333333. So when you do the comparison, it gets jacked up. Read the article I commented in the code.

Also, does anyone have expierence with Microsoft's Media Foundation? I've been trying to use MF to capture to a hwnd using D3D and I'm having a really hard time. Would appreciate any help.



Thank you very much, it definitely helped. Would also happen to know why when I type in an answer to a division problem exactly the way I printf the answer, that it still doesn't read it in as correct? Basically this is what is happening: I'll post an image. I have it set to debug in which it gives me the answer, then I type in the answer and it should say "correct!", but for some reason, I type in EXACTLY what it prints out the answer to be, and it's still reading it as wrong. Here's an image.

Thanks. I've tried using %.2f to limit it, %f, %lf and it's always random, some division problems will read my answers properly, and some won't. I marked the two that are not are opposite

Edit: I'm reading that you cannot directly compare floats :/ unless you use a function, but unfortunately I was never taught this!

Edit again: This happens with both your code, and my original "if" statements. The problem is this: If it's not division, the answer has to be an integer, but if it's division it has to be two decimal places, like 2.12...

When you're casting floats or doubles with (double) x / ((double)y) can you cast that directly to two decimal places? Like doing (double.2)x ?


You're thinking of it the wrong way. How you PRINT decimals to the screen and how the computer actually stores them are two completely different things. When you use printf, cout, whatever output you use, those functions are written to take the value inside the computer and print it in a way you specify. The printf family of functions doesn't particularly care if the value inside the computer is 2.999999999 or 3.0000000001. It will print out 3 if specify it to one digit.

Now when you do a comparison inside your program, such as:

if ( float1 == float2 )

Then the computer assumes that they must be the same at EVERY SINGLE DECIMAL SPACE PAST THE DECIMAL POINT. So as a concrete example, if float1 = 1.9999999999999999 and float2 = 1.9999999999999998 then as far as the computer is concerned, they are not equal. Whoops, your above if statement would fail. That is why floats need an acceptable margin for error. To you, float1 and float2 are pretty much the same. I mean, who cares about the 10th or 11th decimal place not being the same, right?

That is why the more LOGICAL equivalent for the comparison above is like this:

if ( ABSOLUTEVALUE( float1 - float2 ) <= 0.000000000001 )

This above comparison basically says "okay look, if these floats are the same up till this decimal point, then I pretty much consider them equal."

Well guess what? Everytime you call scanf, the value the user puts in, such as 1.24, it can actually get stored as 1.2399999999999999999999999. That is precisely why your program is failing, and that is precisely what that exercise is supposed to teach you. Here's working code, in case you need an even more concrete example:

+ Show Spoiler +

Here are some of the results when you run the code in the spoiler:
43 / 3 Result is: 14.33
What is the answer? 14.33
you entered: 14.3299999237
But trancted to two decimal places.. you entererd: 14.33
Correct!
50 / 4 Result is: 12.50
What is the answer? 12.50
you entered: 12.5000000000
But trancted to two decimal places.. you entererd: 12.50
Correct!
89 / 96 Result is: 0.93
What is the answer? 0.93
you entered: 0.9300000072
But trancted to two decimal places.. you entererd: 0.93
Correct!
38 / 44 Result is: 0.86
What is the answer? 0.86
you entered: 0.8600000143
But trancted to two decimal places.. you entererd: 0.86
Correct!
60 / 8 Result is: 7.50
What is the answer?

+ Show Spoiler +


#include <stdio.h>
#include <stdlib.h>
#include <time.h>

int main(int argc, char *argv[] )
{
int randomNum = 0, randomNum2 = 0, mathOperator = 0;
float result = 0, answer = 0;
srand ( time(NULL) );

char map[4] = {'-','+','*','/'};

while( 1 )
{
randomNum = rand()%100; //Truncated it to a limit of 100, so that you don't get ridiculous numbers...
printf("%i ",randomNum);
mathOperator = 3;
printf("%c ",map[mathOperator] );
randomNum2 = rand()%100;
printf("%i",randomNum2);


result = (float)randomNum / ( (float)randomNum2 );
printf(" Result is: %.2f ",result);

printf(" \nWhat is the answer? ");
scanf("%f",&answer);
printf("you entered: %.10f \n",answer);
printf("But trancted to two decimal places.. you entererd: %.2f \n",answer);
fflush(stdin);


if ( map[mathOperator] == '/' && ( (answer-result) <= 0.001 || result-answer <= 0.001) )
printf("Correct! \n");
}

return 0;
}


ranshaked
Profile Blog Joined August 2010
United States870 Posts
June 24 2012 04:03 GMT
#2904
On June 24 2012 12:54 Abductedonut wrote:
Show nested quote +
On June 24 2012 12:03 ranshaked wrote:
On June 22 2012 07:00 Abductedonut wrote:
On June 22 2012 06:12 ranshaked wrote:
I'm typing from my phone, so please bare with me. I had an assignment that I handed in that was not complete because I could not figure out how to do division. Basically the assignment is like this:
Randomly generate a math sign (+*/-) and two random numbers and ask the user to solve the problem. Everything works properly except the division. I know that it is because I'm using integers, but when I caste them as floats in my if or switch statements (tried both) it either gets 0.000000 all the time or it messes up the other integers. The final line needs to print the answer. Because it is random, I'm struggling with the final answer, everything will wok except division

I'll post the code later. Thanks


I whipped up some quick code for you. It's by no means pretty. Here you go. Assuming you're using C, same principles should apply in C++. Next time, specify which language you use!

+ Show Spoiler +


#include <stdio.h>
#include <stdlib.h>
#include <time.h>

int main(int argc, char *argv[]
{
int randomNum = 0, randomNum2 = 0, mathOperator = 0;
float result = 0, answer = 0;
srand ( time(NULL) );

char map[4] = {'-','+','*','/'};

while( 1 )
{
randomNum = rand()%100; //Truncated it to a limit of 100, so that you don't get ridiculous numbers...
printf("%i ",randomNum);
mathOperator = rand()%4;
printf("%c ",map[mathOperator] );
randomNum2 = rand()%100;
printf("%i",randomNum2);

switch ( map[mathOperator] )
{
case '-':
result = randomNum - randomNum2;
break;
case '+':
result = randomNum + randomNum2;
break;
case '*':
result = randomNum * randomNum2;
break;
case '/':
result = (float)randomNum / ( (float)randomNum2 );
printf(" Result is: %f ",result);
break;
}

//How come the divison never works??
//It's because of round-off errors within the computer. Trying looking at:
//http://www.cygnus-software.com/papers/comparingfloats/comparingfloats.htm
printf(" \nWhat is the answer? ");
scanf("%f",&answer);
printf("you entered: %f \n",answer);
fflush(stdin);

if ( answer == result )
printf("Correct! \n");
}

return 0;
}



The basic idea between comparing floats is that you must have a general "error" range that you're okay with.

Most floats, when printed, will get rounded off. So it may seem like the answer is 1.3333334 but in memory its actually stored as 1.333333333333333333333. So when you do the comparison, it gets jacked up. Read the article I commented in the code.

Also, does anyone have expierence with Microsoft's Media Foundation? I've been trying to use MF to capture to a hwnd using D3D and I'm having a really hard time. Would appreciate any help.



Thank you very much, it definitely helped. Would also happen to know why when I type in an answer to a division problem exactly the way I printf the answer, that it still doesn't read it in as correct? Basically this is what is happening: I'll post an image. I have it set to debug in which it gives me the answer, then I type in the answer and it should say "correct!", but for some reason, I type in EXACTLY what it prints out the answer to be, and it's still reading it as wrong. Here's an image.

Thanks. I've tried using %.2f to limit it, %f, %lf and it's always random, some division problems will read my answers properly, and some won't. I marked the two that are not are opposite

Edit: I'm reading that you cannot directly compare floats :/ unless you use a function, but unfortunately I was never taught this!

Edit again: This happens with both your code, and my original "if" statements. The problem is this: If it's not division, the answer has to be an integer, but if it's division it has to be two decimal places, like 2.12...

When you're casting floats or doubles with (double) x / ((double)y) can you cast that directly to two decimal places? Like doing (double.2)x ?


You're thinking of it the wrong way. How you PRINT decimals to the screen and how the computer actually stores them are two completely different things. When you use printf, cout, whatever output you use, those functions are written to take the value inside the computer and print it in a way you specify. The printf family of functions doesn't particularly care if the value inside the computer is 2.999999999 or 3.0000000001. It will print out 3 if specify it to one digit.

Now when you do a comparison inside your program, such as:

if ( float1 == float2 )

Then the computer assumes that they must be the same at EVERY SINGLE DECIMAL SPACE PAST THE DECIMAL POINT. So as a concrete example, if float1 = 1.9999999999999999 and float2 = 1.9999999999999998 then as far as the computer is concerned, they are not equal. Whoops, your above if statement would fail. That is why floats need an acceptable margin for error. To you, float1 and float2 are pretty much the same. I mean, who cares about the 10th or 11th decimal place not being the same, right?

That is why the more LOGICAL equivalent for the comparison above is like this:

if ( ABSOLUTEVALUE( float1 - float2 ) <= 0.000000000001 )

This above comparison basically says "okay look, if these floats are the same up till this decimal point, then I pretty much consider them equal."

Well guess what? Everytime you call scanf, the value the user puts in, such as 1.24, it can actually get stored as 1.2399999999999999999999999. That is precisely why your program is failing, and that is precisely what that exercise is supposed to teach you. Here's working code, in case you need an even more concrete example:

+ Show Spoiler +

Here are some of the results when you run the code in the spoiler:
43 / 3 Result is: 14.33
What is the answer? 14.33
you entered: 14.3299999237
But trancted to two decimal places.. you entererd: 14.33
Correct!
50 / 4 Result is: 12.50
What is the answer? 12.50
you entered: 12.5000000000
But trancted to two decimal places.. you entererd: 12.50
Correct!
89 / 96 Result is: 0.93
What is the answer? 0.93
you entered: 0.9300000072
But trancted to two decimal places.. you entererd: 0.93
Correct!
38 / 44 Result is: 0.86
What is the answer? 0.86
you entered: 0.8600000143
But trancted to two decimal places.. you entererd: 0.86
Correct!
60 / 8 Result is: 7.50
What is the answer?

+ Show Spoiler +


#include <stdio.h>
#include <stdlib.h>
#include <time.h>

int main(int argc, char *argv[] )
{
int randomNum = 0, randomNum2 = 0, mathOperator = 0;
float result = 0, answer = 0;
srand ( time(NULL) );

char map[4] = {'-','+','*','/'};

while( 1 )
{
randomNum = rand()%100; //Truncated it to a limit of 100, so that you don't get ridiculous numbers...
printf("%i ",randomNum);
mathOperator = 3;
printf("%c ",map[mathOperator] );
randomNum2 = rand()%100;
printf("%i",randomNum2);


result = (float)randomNum / ( (float)randomNum2 );
printf(" Result is: %.2f ",result);

printf(" \nWhat is the answer? ");
scanf("%f",&answer);
printf("you entered: %.10f \n",answer);
printf("But trancted to two decimal places.. you entererd: %.2f \n",answer);
fflush(stdin);


if ( map[mathOperator] == '/' && ( (answer-result) <= 0.001 || result-answer <= 0.001) )
printf("Correct! \n");
}

return 0;
}



Thank you, this is much easier to understand than the things I've been reading. I understand now, I assumed that by using a float it automatically limited the answer to only 6 decimal places, I didn't realize that even though it doesn't show, it's still checking down the line.

I will try this and let you know. This stuff is fascinating, and challenging. I dislike how I've been stuck on this all day, but i'll play with it now. I actually enjoy spending hours trying to figure stuff out and playing with it, but sometimes I get stuck like this!
Abductedonut
Profile Blog Joined December 2010
United States324 Posts
June 24 2012 04:19 GMT
#2905
On June 24 2012 13:03 ranshaked wrote:
Thank you, this is much easier to understand than the things I've been reading. I understand now, I assumed that by using a float it automatically limited the answer to only 6 decimal places, I didn't realize that even though it doesn't show, it's still checking down the line.

I will try this and let you know. This stuff is fascinating, and challenging. I dislike how I've been stuck on this all day, but i'll play with it now. I actually enjoy spending hours trying to figure stuff out and playing with it, but sometimes I get stuck like this!


No problem. That's what this thread is for! Here's another really creative way you could have solved this problem, btw.

I feel like you'd like this.



#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>

int main(int argc, char *argv[] )
{
int randomNum = 0, randomNum2 = 0, mathOperator = 0;
float result = 0, answer = 0;
srand ( time(NULL) );

char map[4] = {'-','+','*','/'};
char cool1[10], cool2[10];

while( 1 )
{
randomNum = rand()%100; //Truncated it to a limit of 100, so that you don't get ridiculous numbers...
printf("%i ",randomNum);
mathOperator = 3;
printf("%c ",map[mathOperator] );
randomNum2 = rand()%100;
printf("%i",randomNum2);


result = (float)randomNum / ( (float)randomNum2 );

sprintf(cool1,"%.2f",result);
printf(" Your answer: ");
scanf("%f",&answer);
sprintf(cool2,"%.2f",answer);
fflush(stdin);

if ( !strcmp(cool1,cool2) )
printf("Correct! \n");

}

return 0;
}
Ghad
Profile Blog Joined April 2010
Norway2551 Posts
June 24 2012 21:21 GMT
#2906
The official Video Torrent from NDC Oslo 2012 with 87 gigs of free development videos is now up. You are welcome.

http://www.ndcoslo.com/Article/News/2012video
forgottendreams: One underage girl, two drunk guys, one gogo dancer and starcraft 2. Apparently just another day in Europe.
Iwbhs
Profile Blog Joined May 2009
United States195 Posts
June 25 2012 00:12 GMT
#2907
http://pastebin.com/myhvzy1q

Any idea on why my tooltip breaks when I include html?
Everyone loves Milano cookies.
berated-
Profile Blog Joined February 2007
United States1134 Posts
June 25 2012 00:19 GMT
#2908
On June 25 2012 09:12 Iwbhs wrote:
http://pastebin.com/myhvzy1q

Any idea on why my tooltip breaks when I include html?


Looks like you need to escape your quotes.

onmouseover="doStuff(\"escape me \")"
Iwbhs
Profile Blog Joined May 2009
United States195 Posts
Last Edited: 2012-06-25 00:24:10
June 25 2012 00:22 GMT
#2909
<div id="shoulder" ONMOUSEOVER="ddrivetip('1 Armor<br /><a href="/class.php?c=Monk&d=Shoulder">Shoulder</a><br />&nbsp;&nbsp;&nbsp;All Resistance: 1<br />','black')"; ONMOUSEOUT="hideddrivetip()" style="background-image: url(images/Shoulder.png);"></div>


where is the mistake in quotes?

<div id="shoulder" ONMOUSEOVER="ddrivetip('1 Armor<br /><a href=\"/class.php?c=Monk&d=Shoulder\">Shoulder</a><br />&nbsp;&nbsp;&nbsp;All Resistance: 1\n','black')"; ONMOUSEOUT="hideddrivetip()" style="background-image: url(images/Shoulder.png);"></div>


not working.
Everyone loves Milano cookies.
berated-
Profile Blog Joined February 2007
United States1134 Posts
Last Edited: 2012-06-25 00:59:56
June 25 2012 00:45 GMT
#2910
On June 25 2012 09:22 Iwbhs wrote:
<div id="shoulder" ONMOUSEOVER="ddrivetip('1 Armor<br /><a href="/class.php?c=Monk&d=Shoulder">Shoulder</a><br />&nbsp;&nbsp;&nbsp;All Resistance: 1<br />','black')"; ONMOUSEOUT="hideddrivetip()" style="background-image: url(images/Shoulder.png);"></div>


where is the mistake in quotes?

<div id="shoulder" ONMOUSEOVER="ddrivetip('1 Armor<br /><a href=\"/class.php?c=Monk&d=Shoulder\">Shoulder</a><br />&nbsp;&nbsp;&nbsp;All Resistance: 1\n','black')"; ONMOUSEOUT="hideddrivetip()" style="background-image: url(images/Shoulder.png);"></div>


not working.


yeah mental lapse, you can't use \ in html, you would have to escape it using html &quot;. The best way to avoid this is probably restructure your code a little bit, but thats a different argument.

To get it working pick one quote for the outside and one for the inside, what I mean by that is..

<div id="shoulder" ONMOUSEOVER='ddrivetip("1 Armor<br /><a href=\"/class.php?c=Monk&d=Shoulder\">Shoulder</a><br />&nbsp;&nbsp;&nbsp;All Resistance: 1\n","black");' ONMOUSEOUT="hideddrivetip()" style="background-image: url(images/Shoulder.png);"></div>


You also have to escape the quote for the js


Edit: Yeah okay this is painful a couple questions...

1) Is there any reason you aren't using jquery?

2) Even if you aren't using jquery you can still accomplish this. It would probably be cleaner if you hid the html that you wanted to use in a div somewhere on the page and then grabbed it load the tip.

Example: ( I didn't test this, just trying to show the general concept )

<div id="shoulder" ONMOUSEOVER="ddrivetip('tooltiptext','black');" ONMOUSEOUT="hideddrivetip()" style="background-image: url(images/Shoulder.png);"></div>



<div id="tooltiptext" style="display:none">
1 Armor<br /><a href="/class.php?c=Monk&d=Shoulder">Shoulder</a><br />&nbsp;&nbsp;&nbsp;All Resistance: 1
</div>



function ddrivetip(theid, thecolor, thewidth){
if (typeof thewidth!="undefined") tipobj.style.width=thewidth+"px"
if (typeof thecolor!="undefined" && thecolor!="") tipobj.style.backgroundColor=thecolor
tipobj.innerHTML=document.findElementById(theid).innerHTML
enabletip=true
return false
}




3FFA
Profile Blog Joined February 2010
United States3931 Posts
June 25 2012 01:24 GMT
#2911
I'm starting to learn programming today with Java. I am being taught the basics by my older brother and he gave me a program to use called Eclipse. Is there any good tips I could get for someone starting out learning Java? Has anyone used Eclipse before? I also am testing myself as I learn with codingbat.com. Is there any other sites like that for Java? Do note that I didn't read the thread other than the OP. Sorry for that.
"As long as it comes from a pure place and from a honest place, you know, you can write whatever you want."
tofucake
Profile Blog Joined October 2009
Hyrule19086 Posts
June 25 2012 01:30 GMT
#2912
Eclipse is pretty standard for Java. Unfortunately it's got a lot of features you'll probably not use which slow it down considerably. Just poke around some tutorials. Buy a Java book if you're serious about learning Java. If you're like me (learn by doing), I suggest a mid level book rather than a For Dummies or whatever. Check this out
Liquipediaasante sana squash banana
3FFA
Profile Blog Joined February 2010
United States3931 Posts
Last Edited: 2012-06-25 01:39:41
June 25 2012 01:37 GMT
#2913
Ok thanks a lot! Also, I will be learning C++ come September in my High School because I got the highest test grades in my class and was able to qualify for it (of course said yes immediately as I've always been interested in programming) so that led to me asking my brother if I could learn a language that he knows. My plan is to learn a good amount of Java this summer and many years down the road my plan is to make an RTS game. However, I will of course make a lot of much simpler stuff first.

I've already been told how things like a 1 instead of an i can mess up coding so much that you may spend hours asking people to help you look through it, possibly even a whole day.
"As long as it comes from a pure place and from a honest place, you know, you can write whatever you want."
Blisse
Profile Blog Joined July 2010
Canada3710 Posts
June 25 2012 01:43 GMT
#2914
Wait until you can't find the = that's supposed to be a == ....

-_____-"
There is no one like you in the universe.
Azerbaijan
Profile Blog Joined January 2010
United States660 Posts
June 25 2012 02:46 GMT
#2915
Can anyone reccomend a good book for learning C? The one I have is from the 70s.
jergason
Profile Joined May 2010
United States37 Posts
June 25 2012 04:56 GMT
#2916
The C Programming Language is the best book on C, and one of the best programming books ever written.

http://www.amazon.com/C-Programming-Language-2nd-Edition/dp/0131103628/ref=sr_1_1?ie=UTF8&qid=1340600201&sr=8-1&keywords=the c programming language
supereddie
Profile Joined March 2011
Netherlands151 Posts
Last Edited: 2012-06-25 10:00:35
June 25 2012 09:59 GMT
#2917
On June 25 2012 09:45 berated- wrote:

2) Even if you aren't using jquery you can still accomplish this. It would probably be cleaner if you hid the html that you wanted to use in a div somewhere on the page and then grabbed it load the tip.

Example: ( I didn't test this, just trying to show the general concept )

<div id="shoulder" ONMOUSEOVER="ddrivetip('tooltiptext','black');" ONMOUSEOUT="hideddrivetip()" style="background-image: url(images/Shoulder.png);"></div>



<div id="tooltiptext" style="display:none">
1 Armor<br /><a href="/class.php?c=Monk&d=Shoulder">Shoulder</a><br />&nbsp;&nbsp;&nbsp;All Resistance: 1
</div>



function ddrivetip(theid, thecolor, thewidth){
if (typeof thewidth!="undefined") tipobj.style.width=thewidth+"px"
if (typeof thecolor!="undefined" && thecolor!="") tipobj.style.backgroundColor=thecolor
tipobj.innerHTML=document.findElementById(theid).innerHTML
enabletip=true
return false
}



Even easier is just use CSS.

<style type="text/css">
.tooltiptext{ display: none; position: fixed; top: 0; right: 0; }
.tt:hover .tooltiptext{ display: block; }
</style>

...

<div class="tt" id="shoulder" style="background-image: url(images/Shoulder.png);">
<div class="tooltiptext">
1 Armor<br /><a href="/class.php?c=Monk&d=Shoulder">Shoulder</a><br />&nbsp;&nbsp;&nbsp;All Resistance: 1
</div>
</div>

Ofcourse, this won't work in Internet Explorer < 8, but it works in any recent browser so who cares?
"Do not try to make difficult things possible, but make simple things simple." - David Platt on Software Design
Poltergeist-
Profile Blog Joined May 2010
Sweden336 Posts
June 25 2012 10:10 GMT
#2918
What are the latest and greatest/upcoming programming languages, if any? Anyone have any idea? Does it differ possibly between the US and EU?
Joefish
Profile Joined July 2010
Germany314 Posts
June 25 2012 17:03 GMT
#2919
On June 25 2012 19:10 Poltergeist- wrote:
What are the latest and greatest/upcoming programming languages, if any? Anyone have any idea? Does it differ possibly between the US and EU?


According to this website, the top 3 are C/Java/C++.
And I don' think there is any difference between different regions. But haven't found any data about it.
I'm actually surprised C being at the top of the charts. Thought top 3 would look like this C++/Java/PHP.
Isualin
Profile Joined March 2011
Germany1903 Posts
June 25 2012 17:13 GMT
#2920
any idea why C is getting bigger? isn't it quite old?
| INnoVation | The literal god TY | ByuNjwa | LRSL when? |
Prev 1 144 145 146 147 148 1031 Next
Please log in or register to reply.
Live Events Refresh
PiGosaur Monday
00:00
#49
davetesta55
Liquipedia
OSC
23:00
OSC Elite Rising Star #16
Liquipedia
[ Submit Event ]
Live Streams
Refresh
StarCraft 2
Nina 124
trigger 26
StarCraft: Brood War
Artosis 754
Backho 135
NaDa 14
Dota 2
monkeys_forever413
Counter-Strike
fl0m831
kRYSTAL_40
Super Smash Bros
C9.Mang0266
Mew2King0
Heroes of the Storm
NeuroSwarm127
Other Games
summit1g8349
Grubby3546
shahzam754
Day[9].tv651
ToD228
Sick162
Maynarde122
Trikslyr61
XaKoH 57
ViBE50
Organizations
Other Games
gamesdonequick627
StarCraft 2
Blizzard YouTube
StarCraft: Brood War
BSLTrovo
sctven
[ Show 14 non-featured ]
StarCraft 2
• intothetv
• AfreecaTV YouTube
• Kozan
• IndyKCrew
• LaughNgamezSOOP
• Migwel
• sooper7s
StarCraft: Brood War
• BSLYoutube
• STPLYoutube
• ZZZeroYoutube
Dota 2
• masondota22121
Other Games
• Scarra1178
• imaqtpie865
• Day9tv651
Upcoming Events
LiuLi Cup
10h 51m
OSC
18h 51m
RSL Revival
1d 9h
Maru vs Reynor
Cure vs TriGGeR
The PondCast
1d 12h
RSL Revival
2 days
Zoun vs Classic
Korean StarCraft League
3 days
BSL Open LAN 2025 - War…
3 days
RSL Revival
3 days
BSL Open LAN 2025 - War…
4 days
RSL Revival
4 days
[ Show More ]
Online Event
4 days
Wardi Open
5 days
Sparkling Tuna Cup
6 days
Liquipedia Results

Completed

Proleague 2025-09-10
Chzzk MurlocKing SC1 vs SC2 Cup #2
HCC Europe

Ongoing

BSL 20 Team Wars
KCM Race Survival 2025 Season 3
BSL 21 Points
ASL Season 20
CSL 2025 AUTUMN (S18)
LASL Season 20
RSL Revival: Season 2
Maestros of the Game
FISSURE Playground #2
BLAST Open Fall 2025
BLAST Open Fall Qual
Esports World Cup 2025
BLAST Bounty Fall 2025
BLAST Bounty Fall Qual
IEM Cologne 2025
FISSURE Playground #1

Upcoming

2025 Chongqing Offline CUP
BSL World Championship of Poland 2025
IPSL Winter 2025-26
BSL Season 21
SC4ALL: Brood War
BSL 21 Team A
Stellar Fest
SC4ALL: StarCraft II
EC S1
ESL Impact League Season 8
SL Budapest Major 2025
BLAST Rivals Fall 2025
IEM Chengdu 2025
PGL Masters Bucharest 2025
MESA Nomadic Masters Fall
Thunderpick World Champ.
CS Asia Championships 2025
ESL Pro League S22
StarSeries Fall 2025
TLPD

1. ByuN
2. TY
3. Dark
4. Solar
5. Stats
6. Nerchio
7. sOs
8. soO
9. INnoVation
10. Elazer
1. Rain
2. Flash
3. EffOrt
4. Last
5. Bisu
6. Soulkey
7. Mini
8. Sharp
Sidebar Settings...

Disclosure: This page contains affiliate marketing links that support TLnet.

Advertising | Privacy Policy | Terms Of Use | Contact Us

Original banner artwork: Jim Warren
The contents of this webpage are copyright © 2025 TLnet. All Rights Reserved.