at least VS2010 thinks it's cool (still producing mass errors, when trying to compile, but i will tend to them after fixing all the red underlined stuffs ^^)
The Big Programming Thread - Page 157
Forum Index > General Forum |
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. | ||
SiPa
Germany129 Posts
at least VS2010 thinks it's cool (still producing mass errors, when trying to compile, but i will tend to them after fixing all the red underlined stuffs ^^) | ||
omarsito
22 Posts
http://imgur.com/5D46K If anybody has the answer please pm or just reply! thanks. | ||
MisterD
Germany1338 Posts
On August 18 2012 01:11 omarsito wrote: Hey tlers, got a quick question about eclipse. I cant find the option to increase the "code window" (check picture) without dragging the slider. http://imgur.com/5D46K If anybody has the answer please pm or just reply! thanks. try "reset perspective" from the window menu. | ||
Thorakh
Netherlands1788 Posts
Why oh why is this + Show Spoiler + import java.util.*; giving me this + Show Spoiler + Please enter an integer: as console output? I suspect it has something to do with the Scanner because + Show Spoiler + import java.util.*; gives me + Show Spoiler + Please enter an integer: as expected. Why do I have to generate a new Scanner object for this to work? I am 100% sure I am making a dumb mistake here but I can't for the life of me seem to figure it out! I'm completely stumped. | ||
beamerkun
Poland112 Posts
| ||
Thorakh
Netherlands1788 Posts
On August 20 2012 05:55 beamerkun wrote: Ah, of course! Is there a more elegant solution than adding a variable that simply 'eats' the incorrect inputYou're leaving that 'b' character in buffer - look that in second example you make a new scanner (thus, a new buffer) every time somebody enters line. + Show Spoiler + import java.util.*; or is making a new Scanner object and closing it every loop an acceptable solution? | ||
Kambing
United States1176 Posts
On August 20 2012 06:05 Thorakh wrote: Ah, of course! Is there a more elegant solution than adding a variable that simply 'eats' the incorrect input + Show Spoiler + import java.util.*; or is making a new Scanner object and closing it every loop an acceptable solution? The rubbish variable is unnecessary. You can simply call sc.next() to consume the offending input without storing the returned value in a variable. Note you are only creating one Scanner object here (connected to System.in). Probably more importantly is that using a try-catch to handle the case where the input is not an integer is not good style. Instead, you should use the hasNextInt() method of the Scanner class to test to see if the next token in the input stream is an integer. If it is not, then you can repeatedly prompt the user until they enter a number. (Note that ripping out input from System.in by token is a little weird as it is not entirely clear when the prompting occurs. You could argue that it would be better to use readLine() to explicitly grab a line of input from the user and then test that resulting String to see if it is an integer.) | ||
green.at
Austria1459 Posts
| ||
Kambing
United States1176 Posts
| ||
![]()
white_horse
1019 Posts
+ Show Spoiler + #include <iostream> #include <cstdlib> using namespace std; void randomgen(char ch1, char ch2) { for(int i = 1; i <= 100; i++) { cout << static_cast<char>('ch1' + rand() % ('ch2' - 'ch1' + 1)); cout << " "; if (i % 10 == 0) { cout << endl; } } } int main() { char a, z; randomgen(a, z); return 0; } edit: It's not letting me indent any of the code -_- | ||
tec27
United States3690 Posts
But anyway, first thing, you shouldn't be single-quoting your variable names, single quotes are only for char literals. Secondly, you never initialized your a and z variables. If you intend them to be equal to 'a' and 'z', you need to do something like: char a = 'a'; Alternatively you could just pass those values in ( randomgen('a', 'z') ) and not store them in variables. Judging from your code, it looks like you don't quite understand the difference between variable names and variable values. Variable names are like an address on a mailbox. They tell the compiler what location you're referring to, but the compiler can make no assumptions from the name as to what the location contains. Thus, if you have a char variable named 'a', for all the compiler knows you're storing the value 'f' there. Similarly, if you quote a variable name as a literal (IE: 'ch2' in your code) the compiler will look at this as a literal and nothing else. It will not replace this with either value or the name of what was passed into your function. | ||
IreScath
Canada521 Posts
code:
I've also tried WaitWindowLike() to no avail. Its not even like the app just isnt launching.. It is, however the program never waits and just prints 'found window' immediately. output when run:
After Launching app, the script should wait until Musemage window has launched (takes about 8 seconds), and THEN out put the rest... however "found window.5372" prints the same time as "launching app", then the perl script finishes... THEN about 4 seconds after that Musemage finally opens. The only thing I'm thinking is I'm using WaitWindow wrong? I've tested with wait time at 3 - 3000000. | ||
IreScath
Canada521 Posts
| ||
supereddie
Netherlands151 Posts
Additionally, WaitWindow has a return value. try print_r(WaitWindow(.....)) to see what it returns; I guess it is an array of window handles that match the name. | ||
SilSol
Sweden2744 Posts
![]() | ||
IreScath
Canada521 Posts
On August 22 2012 02:05 supereddie wrote: There is a difference between the app loading and the app creating it's main window. The window can be created immediately (and hidden) while the app actually loads. I assume WaitWindow finds the hidden window. Additionally, WaitWindow has a return value. try print_r(WaitWindow(.....)) to see what it returns; I guess it is an array of window handles that match the name. Yea I think you are correct... Its spitting a number out (5835818 for example)... Anyone know of a wait to wait until the window is actually loaded up and visible? | ||
supereddie
Netherlands151 Posts
@SilSol: You start by thinking logically and linear; both in detail (individual lines/code blocks/methods) and in the large scale (complete program or even interfacing with other programs). If you can do that, you have the basics. | ||
![]()
white_horse
1019 Posts
On August 20 2012 11:20 tec27 wrote: Use code tags. But anyway, first thing, you shouldn't be single-quoting your variable names, single quotes are only for char literals. Secondly, you never initialized your a and z variables. If you intend them to be equal to 'a' and 'z', you need to do something like: char a = 'a'; Alternatively you could just pass those values in ( randomgen('a', 'z') ) and not store them in variables. Judging from your code, it looks like you don't quite understand the difference between variable names and variable values. Variable names are like an address on a mailbox. They tell the compiler what location you're referring to, but the compiler can make no assumptions from the name as to what the location contains. Thus, if you have a char variable named 'a', for all the compiler knows you're storing the value 'f' there. Similarly, if you quote a variable name as a literal (IE: 'ch2' in your code) the compiler will look at this as a literal and nothing else. It will not replace this with either value or the name of what was passed into your function. that helped thanks | ||
Deleted User 101379
4849 Posts
On August 22 2012 02:25 supereddie wrote: There probably is a way to query the visibility of a window by using the window handle - check the Perl docs. @SilSol: You start by thinking logically and linear; both in detail (individual lines/code blocks/methods) and in the large scale (complete program or even interfacing with other programs). If you can do that, you have the basics. I usually tell people to basically think about how they would solve a given problem by hand with pen&paper, then write it down step by step and after that turn every step into the corresponding code. The end result might not be perfect code or the best and fastest solution but it is a solution that works. Many people think of programming like something complex and obscure which scares them off since programmers tend to always talk about optimization, ideal sorting algorithms, program design, database normalization, RAII, OOP and all that stuff. Once they understand that programs actually just do stuff you would do yourself, just that computers do it a billion times faster, it gets easier for them to actually turn problems into codified solutions since they no longer try to understand programming but instead start to understand solving problems. | ||
supereddie
Netherlands151 Posts
| ||
| ||