• Log InLog In
  • Register
Liquid`
Team Liquid Liquipedia
EST 10:56
CET 16:56
KST 00:56
  • 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
RSL Revival - 2025 Season Finals Preview8RSL Season 3 - Playoffs Preview0RSL Season 3 - RO16 Groups C & D Preview0RSL Season 3 - RO16 Groups A & B Preview2TL.net Map Contest #21: Winners12
Community News
Weekly Cups (Dec 15-21): Classic wins big, MaxPax & Clem take weeklies3ComeBackTV's documentary on Byun's Career !10Weekly Cups (Dec 8-14): MaxPax, Clem, Cure win4Weekly Cups (Dec 1-7): Clem doubles, Solar gets over the hump1Weekly Cups (Nov 24-30): MaxPax, Clem, herO win2
StarCraft 2
General
Weekly Cups (Dec 15-21): Classic wins big, MaxPax & Clem take weeklies ComeBackTV's documentary on Byun's Career ! Micro Lags When Playing SC2? When will we find out if there are more tournament Weekly Cups (Dec 8-14): MaxPax, Clem, Cure win
Tourneys
$100 Prize Pool - Winter Warp Gate Masters Showdow $5,000+ WardiTV 2025 Championship Sparkling Tuna Cup - Weekly Open Tournament Winter Warp Gate Amateur Showdown #1 RSL Offline Finals Info - Dec 13 and 14!
Strategy
Custom Maps
Map Editor closed ?
External Content
Mutation # 505 Rise From Ashes Mutation # 504 Retribution Mutation # 503 Fowl Play Mutation # 502 Negative Reinforcement
Brood War
General
BW General Discussion FlaSh on: Biggest Problem With SnOw's Playstyle soO on: FanTaSy's Potential Return to StarCraft BGH Auto Balance -> http://bghmmr.eu/ Anyone remember me from 2000s Bnet EAST server?
Tourneys
[Megathread] Daily Proleagues [BSL21] LB QuarterFinals - Sunday 21:00 CET Small VOD Thread 2.0 [BSL21] WB SEMIFINALS - Saturday 21:00 CET
Strategy
Simple Questions, Simple Answers Game Theory for Starcraft Current Meta Fighting Spirit mining rates
Other Games
General Games
Nintendo Switch Thread Stormgate/Frost Giant Megathread Beyond All Reason Path of Exile General RTS Discussion Thread
Dota 2
Official 'what is Dota anymore' discussion
League of Legends
Heroes of the Storm
Simple Questions, Simple Answers Heroes of the Storm 2.0
Hearthstone
Deck construction bug Heroes of StarCraft mini-set
TL Mafia
Mafia Game Mode Feedback/Ideas Survivor II: The Amazon Sengoku Mafia TL Mafia Community Thread
Community
General
US Politics Mega-thread Russo-Ukrainian War Thread The Games Industry And ATVI Things Aren’t Peaceful in Palestine YouTube Thread
Fan Clubs
White-Ra Fan Club
Media & Entertainment
Anime Discussion Thread [Manga] One Piece Movie Discussion!
Sports
2024 - 2026 Football Thread Formula 1 Discussion
World Cup 2022
Tech Support
Computer Build, Upgrade & Buying Resource Thread
TL Community
The Automated Ban List TL+ Announced Where to ask questions and add stream?
Blogs
The (Hidden) Drug Problem in…
TrAiDoS
I decided to write a webnov…
DjKniteX
James Bond movies ranking - pa…
Topin
Thanks for the RSL
Hildegard
Customize Sidebar...

Website Feedback

Closed Threads



Active: 804 users

The Big Programming Thread - Page 146

Forum Index > General Forum
Post a Reply
Prev 1 144 145 146 147 148 1032 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
Hyrule19182 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 1032 Next
Please log in or register to reply.
Live Events Refresh
WardiTV Invitational
12:00
Christmas Eve Games
Creator vs ScarlettLIVE!
WardiTV1460
Rex148
Liquipedia
[ Submit Event ]
Live Streams
Refresh
StarCraft 2
Lowko516
Rex 148
trigger 48
StarCraft: Brood War
Britney 51852
Horang2 1904
Aegong 1435
Bisu 1200
Shuttle 522
Larva 497
Stork 484
Hyun 307
firebathero 284
Mini 234
[ Show more ]
actioN 231
Snow 183
hero 126
sorry 75
ToSsGirL 40
soO 21
HiyA 20
zelot 20
Terrorterran 19
ggaemo 18
Movie 16
Sacsri 12
scan(afreeca) 11
SilentControl 9
JulyZerg 5
Noble 5
Dota 2
XcaliburYe1040
syndereN990
420jenkins32
League of Legends
rGuardiaN115
C9.Mang086
Super Smash Bros
Mew2King102
Other Games
singsing2245
hiko627
Mlord365
Livibee107
XaKoH 100
Organizations
StarCraft 2
Blizzard YouTube
StarCraft: Brood War
BSLTrovo
sctven
[ Show 15 non-featured ]
StarCraft 2
• Light_VIP 23
• AfreecaTV YouTube
• intothetv
• Kozan
• IndyKCrew
• LaughNgamezSOOP
• Migwel
• sooper7s
StarCraft: Brood War
• 80smullet 14
• XenOsky 1
• BSLYoutube
• STPLYoutube
• ZZZeroYoutube
Dota 2
• WagamamaTV1723
League of Legends
• Nemesis4186
Upcoming Events
Replay Cast
17h 4m
WardiTV Invitational
20h 4m
ByuN vs Solar
Clem vs Classic
Cure vs herO
Reynor vs MaxPax
Big Brain Bouts
2 days
Elazer vs Nicoract
Reynor vs Scarlett
Replay Cast
2 days
Sparkling Tuna Cup
3 days
Krystianer vs TBD
TriGGeR vs SKillous
Percival vs TBD
ByuN vs Nicoract
Replay Cast
4 days
Wardi Open
4 days
Liquipedia Results

Completed

Proleague 2025-12-22
WardiTV 2025
META Madness #9

Ongoing

C-Race Season 1
IPSL Winter 2025-26
KCM Race Survival 2025 Season 4
BSL Season 21
Slon Tour Season 2
CSL Season 19: Qualifier 2
eXTREMESLAND 2025
SL Budapest Major 2025
ESL Impact League Season 8
BLAST Rivals Fall 2025
IEM Chengdu 2025
PGL Masters Bucharest 2025
Thunderpick World Champ.
CS Asia Championships 2025
ESL Pro League S22

Upcoming

CSL 2025 WINTER (S19)
BSL 21 Non-Korean Championship
Acropolis #4
IPSL Spring 2026
Bellum Gens Elite Stara Zagora 2026
HSC XXVIII
Big Gabe Cup #3
OSC Championship Season 13
Nations Cup 2026
ESL Pro League Season 23
PGL Cluj-Napoca 2026
IEM Kraków 2026
BLAST Bounty Winter 2026
BLAST Bounty Winter Qual
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.