@StatusQ3: Go
the reason for the + for the strings is because you're adding "strings" to numbers. Like when you wrote
"The square root of "+letterX
You can't write "The square root of letterX ", because that would display "The square root of letterX", instead of "The square root of 225". The + operator inadvertently does all the conversion of integers to string for you. Basically, the data type that the print function prints out is suppose to be a string, and the + actually converts the integer letterX into a string for you, and adds it to the rest of the string. Hope that makes sense.
@StatusQ3: Go
For the parse error, you probably have an open bracket somewhere. Scan through your whole code, make sure you indent and format everything correctly, and check for brackets that don't have an end. { } and ( )
When you see an error, usually you wanna fix it. xD When you go out of your way to fix errors in your code as well as other people's, you start developing a compiler in your head. That's when you know you're on the path to becoming a good programmer.
Also make sure you start practicing good habits when you're first learning. Bad habits die hard. Habits like formatting/indenting code correctly, commenting effectively as you code, and using good names for variables and functions. There are other key concepts too, but i'm sure you'll find out along the way.
@SouLCarveRR: Go The correct way to comment is implied in the following code samples.
voidInitMap(){InitLibs();InitTriggers();// This essentially creates the trigger functionality, threads for each trigger.DoTheMath();// Yes, this is how you call a function with no parameters.}voidDoTheMath(){intletterX;intletterY;letterX=225;letterY=412;UIDisplayMessage(PlayerGroupAll(),c_messageAreaSubtitle,(StringToText("The square root of ")+IntToText(letterX)+StringToText(" is ")+IntToText(SquareRootI(IntToFixed(letterX)))+StringToText(".")));UIDisplayMessage(PlayerGroupAll(),c_messageAreaSubtitle,(StringToText("The square root of ")+IntToText(letterY)+StringToText(" is ")+IntToText(SquareRootI(IntToFixed(letterY)))+StringToText(".")));}returntrue;// see Note below}
Note: The custom script action injects your code in the middle of a bool function, so thats why my previous post says to put a
returntrue;}// to close the bool function that it injected the custom script into
and then you type your function right after, like this
boolDoTheMath(){// make sure its a bool functionintletterX;intletterY;intletterZ;letterX=225;letterY=412;letterZ=letterX+letterY;// exclude the "return;" and close bracket "}"
If that wasn't clear enough, a custom script action puts your code like the following ->
boolgt_MeleeInitialization_Func(booltestConds,boolrunActions){// Actionsif(!runActions){returntrue;}// this is where EVERYTHING inside the custom script box gets dumped into.// You wanna close the above function with a "return true"// Then you write your function to make use of the "return true" below, hence why it must be a bool function.returntrue;}
Dunno why someone said "Oracle not maintaining Java". Quite the opposite, they're pushing the development of Java 7/8 along. The main issue with Java/Oracle right now is that licensing / openness with the technology. Apache just withdrew from the JCP. Java will be around for a long time but its pretty much a 'bread and butter' language.
Also... FYI oracle killed Java FX Script, but not Java FX. Can't say it was a bad decision since I think they're going to integrate Java FX into the base JDK, which is what most Java developers wanted in the first place. Not like Java FX ever had a chance the way they did it against silverlight / flash.
I heard learning that was hard. I hope your learning java first. :P
P.S Onisagi, what does the, "else if" condition do? I don't understand why I keep that in one line instead of doing an if statement then make a new line and do else statement.
I learned C+ + before Java its not as pretty but I would not say its harder to use. as for else if
if(condition){}elseif(othercondition){}
if the first condition is false than and the second condition is true then the second code block will run. It is different from "if " in that it will have an if statement before it and will not run unless that statement is false and it is different from "else" in that else will always run as long as the statement before is false.
For me it was C -> C+ + -> Java -> ASM -> Basic. Now that i think about it, i went from the hardest to the easiest...
i'm not sure if i'm qualified to explain the fundamental difference, it may be that "else if" and "else { if" run differently on the machine code level. But in practice, they function the same and most if not all people use "else if"
Example:
if(condition){// statement}elseif(condition){// statement}// is in practice the same as the following, the above is just simpler to "nest" together, without too many curly braces { }.if(condition){// statement}else{if(condition){// statement}}
classjavamath{publicstaticvoidmain(String[]args){intnumber=225;Stringtext="Hello.";chartext1='A';if(number==225){System.out.println("The square root of "+number+" is "+Math.sqrt(number));}else{intnumber2=230;System.out.println("The square root of "+number2+" could not be found.");}}}
Here I tried out if and else statements for some practice with them. But I have had an issue...
classjavamath{publicstaticvoidmain(String[]args){intnumber=225;Stringtext="Hello.";chartext1='A';if(number==225){System.out.println("The square root of "+number+" is "+Math.sqrt(number));
Everything fine is here, but look at the integer.
else{intnumber2=225System.out.println("The square root of "+number2+" could not be found.");}}}
In the else statement it will not let me call on the integer called number, so I made a new integer...But it just does not seem right, I almost know for sure I should be calling on the first integer instead of making another one.
P.S: I realize my strings don't make a lot of sense, it was just a quick test in java coding as I stated.
classjavamath{publicstaticvoidmain(String[]args){intnumber=123;if(number==123){System.out.println("The square root of "+number+" is "+Math.sqrt(number));}}
I need to know what you were trying to do when it didn't work, did you try to do another
intnumber=225;
inside the else statement? Try just number = 225; by itself, then have the print function for it.
classjavamath{publicstaticvoidmain(String[]args){intnumber=225;Stringtext="Hello.";chartext1='A';if(number==225){System.out.println("The square root of "+number+" is "+Math.sqrt(number));}else{number=225;System.out.println("The square root of "+number+" could not be found.");}}}
So this is what you got? This is syntactically perfectly fine code, so if you get an error it's because of the program you're using.
@StatusQ3: Go the reason for the + for the strings is because you're adding "strings" to numbers. Like when you wrote
You can't write "The square root of letterX ", because that would display "The square root of letterX", instead of "The square root of 225". The + operator inadvertently does all the conversion of integers to string for you. Basically, the data type that the print function prints out is suppose to be a string, and the + actually converts the integer letterX into a string for you, and adds it to the rest of the string. Hope that makes sense.
@StatusQ3: Go For the parse error, you probably have an open bracket somewhere. Scan through your whole code, make sure you indent and format everything correctly, and check for brackets that don't have an end. { } and ( )
When you see an error, usually you wanna fix it. xD When you go out of your way to fix errors in your code as well as other people's, you start developing a compiler in your head. That's when you know you're on the path to becoming a good programmer.
Also make sure you start practicing good habits when you're first learning. Bad habits die hard. Habits like formatting/indenting code correctly, commenting effectively as you code, and using good names for variables and functions. There are other key concepts too, but i'm sure you'll find out along the way.
@SouLCarveRR: Go The correct way to comment is implied in the following code samples.
Note: The custom script action injects your code in the middle of a bool function, so thats why my previous post says to put a
and then you type your function right after, like this
If that wasn't clear enough, a custom script action puts your code like the following ->
FYI about Java:
Dunno why someone said "Oracle not maintaining Java". Quite the opposite, they're pushing the development of Java 7/8 along. The main issue with Java/Oracle right now is that licensing / openness with the technology. Apache just withdrew from the JCP. Java will be around for a long time but its pretty much a 'bread and butter' language.
Also... FYI oracle killed Java FX Script, but not Java FX. Can't say it was a bad decision since I think they're going to integrate Java FX into the base JDK, which is what most Java developers wanted in the first place. Not like Java FX ever had a chance the way they did it against silverlight / flash.
@Ultimaswc3: Go
I think that person just didn't like the direction that Java went after it merged with Oracle. Best not to take "maintaining" too literally.
Java, C
++
, Python: All languages that i'm trying to learn without any real help :DEdit: C with 2 +'s after it gets green underlined text? Wtf?
I heard learning that was hard. I hope your learning java first. :P
P.S Onisagi, what does the, "else if" condition do? I don't understand why I keep that in one line instead of doing an if statement then make a new line and do else statement.
I learned C+ + before Java its not as pretty but I would not say its harder to use. as for else if
if the first condition is false than and the second condition is true then the second code block will run. It is different from "if " in that it will have an if statement before it and will not run unless that statement is false and it is different from "else" in that else will always run as long as the statement before is false.
@StatusQ3: Go
For me it was C -> C+ + -> Java -> ASM -> Basic. Now that i think about it, i went from the hardest to the easiest...
i'm not sure if i'm qualified to explain the fundamental difference, it may be that "else if" and "else { if" run differently on the machine code level. But in practice, they function the same and most if not all people use "else if"
Example:
Thanks guys, that made it easy to understand. ^^.
I believe the technical term is squiggly bracket marks. ^^
Here I tried out if and else statements for some practice with them. But I have had an issue...
Everything fine is here, but look at the integer.
In the else statement it will not let me call on the integer called number, so I made a new integer...But it just does not seem right, I almost know for sure I should be calling on the first integer instead of making another one.
P.S: I realize my strings don't make a lot of sense, it was just a quick test in java coding as I stated.
format the code correctly -> http://java.sun.com/docs/codeconv/CodeConventions.pdf
like this:
I need to know what you were trying to do when it didn't work, did you try to do another
inside the else statement? Try just number = 225; by itself, then have the print function for it.
It wont let me use the number = 225 in the else statement. That's my issue.
@StatusQ3: Go
You forgot the semi-colon at the end?
@s3rius: Go
Nope. It's there alright.
So this is what you got? This is syntactically perfectly fine code, so if you get an error it's because of the program you're using.
@s3rius: Go
If that is perfect code, like you said it is probably the wrong program then or I wrote a mistook a statement for another. Oh well. Thanks anyway. :)