Bay 12 Games Forum

Please login or register.

Login with username, password and session length
Advanced search  
Pages: 1 [2] 3 4 ... 91

Author Topic: Programming Help Thread (For Dummies)  (Read 95611 times)

olemars

  • Bay Watcher
    • View Profile
Re: Programming Help Thread (For Dummies)
« Reply #15 on: May 03, 2011, 07:16:00 am »

Makes it a lot easier to find your block when debugging, as opposed to.

statement;
statement;
statement;
if (condition) statement;
statement;

I usually do it this way:
Code: [Select]
statement;
statement;
statement;
if (condition)
    statement;
else
    statement;
statement;
Logged

Siquo

  • Bay Watcher
  • Procedurally generated
    • View Profile
Re: Programming Help Thread (For Dummies)
« Reply #16 on: May 03, 2011, 07:26:07 am »

As personal preference, even with one line blocks inside an if statment, I still use {}
Yeah, I do this, too, but I put the opening bracket on the same line as the opening clause/statement/thingy:
Code: [Select]
if(true) {
  statement;
}
To each his own, and everyone thinks his way is best. As long as it's readable, you're fine. Oh, and try to use the "code" tags, it makes it more readable here on the forums :)
Logged

This one thread is mine. MIIIIINE!!! And it will remain a happy, friendly, encouraging place, whether you lot like it or not. 
will rena,eme sique to sique sxds-- siquo if sucessufil
(cant spel siqou a. every speling looks wroing (hate this))

Max White

  • Bay Watcher
  • Still not hollowed!
    • View Profile
Re: Programming Help Thread (For Dummies)
« Reply #17 on: May 03, 2011, 07:31:08 am »

(condition){
   statment;
}

makes me rage to work with, and I will always change it to my way. Propper bow formatting makes it faster to read when your going in and out of code blocks. Although yea, this is some what of a subjective subject.

Unless your working in python.  :P

Siquo

  • Bay Watcher
  • Procedurally generated
    • View Profile
Re: Programming Help Thread (For Dummies)
« Reply #18 on: May 03, 2011, 07:49:18 am »

Unless your working in python.  :P
But nobody does that and I just saw that there's another thread for that discussion ;)
Logged

This one thread is mine. MIIIIINE!!! And it will remain a happy, friendly, encouraging place, whether you lot like it or not. 
will rena,eme sique to sique sxds-- siquo if sucessufil
(cant spel siqou a. every speling looks wroing (hate this))

Nadaka

  • Bay Watcher
    • View Profile
    • http://www.nadaka.us
Re: Programming Help Thread (For Dummies)
« Reply #19 on: May 03, 2011, 10:19:42 am »

Max White: in javascript, using the brace on the same line is not just a format option, failure to do so can cause some messy errors because it may occasionally produce a valid grammar that parses in a way that you don't expect.
Logged
Take me out to the black, tell them I ain't comin' back...
I don't care cause I'm still free, you can't take the sky from me...

I turned myself into a monster, to fight against the monsters of the world.

MaximumZero

  • Bay Watcher
  • Stare into the abyss.
    • View Profile
Re: Programming Help Thread (For Dummies)
« Reply #20 on: May 03, 2011, 10:43:52 am »

Okay, so I ran into another snag whilst trying to clean up that mess of code I made.

"expected constructor, destructor, or type conversion before ';' token "

What does that even mean?
Logged
  
Holy crap, why did I not start watching One Punch Man earlier? This is the best thing.
probably figured an autobiography wouldn't be interesting

Siquo

  • Bay Watcher
  • Procedurally generated
    • View Profile
Re: Programming Help Thread (For Dummies)
« Reply #21 on: May 03, 2011, 10:51:08 am »

A syntax error :) Could be anything.
Logged

This one thread is mine. MIIIIINE!!! And it will remain a happy, friendly, encouraging place, whether you lot like it or not. 
will rena,eme sique to sique sxds-- siquo if sucessufil
(cant spel siqou a. every speling looks wroing (hate this))

MaximumZero

  • Bay Watcher
  • Stare into the abyss.
    • View Profile
Re: Programming Help Thread (For Dummies)
« Reply #22 on: May 03, 2011, 10:58:25 am »

Well, crap.
Logged
  
Holy crap, why did I not start watching One Punch Man earlier? This is the best thing.
probably figured an autobiography wouldn't be interesting

qwertyuiopas

  • Bay Watcher
  • Photoshop is for elves who cannot use MSPaint.
    • View Profile
    • uristqwerty.ca, my current (barren) site.
Re: Programming Help Thread (For Dummies)
« Reply #23 on: May 03, 2011, 11:00:39 am »

If it gives a line number, look there. Also, see if your editor has a "go to line" command, so you don't have to look for it.
Logged
Eh?
Eh!

MaximumZero

  • Bay Watcher
  • Stare into the abyss.
    • View Profile
Re: Programming Help Thread (For Dummies)
« Reply #24 on: May 03, 2011, 11:03:25 am »

The only thing from that line until the end of the program is :

getchar();getchar();
return 0;
}

Which I have been doing successfully since the beginning of the class. WTF?


Nevermind, I fixed it. I had the curly brace in the wrong spot. Anyway, now that it compiles again, is there any way for me to speed up compiles?
« Last Edit: May 03, 2011, 11:05:40 am by MaximumZero »
Logged
  
Holy crap, why did I not start watching One Punch Man earlier? This is the best thing.
probably figured an autobiography wouldn't be interesting

qwertyuiopas

  • Bay Watcher
  • Photoshop is for elves who cannot use MSPaint.
    • View Profile
    • uristqwerty.ca, my current (barren) site.
Re: Programming Help Thread (For Dummies)
« Reply #25 on: May 03, 2011, 11:06:24 am »

Hmm, while in that case, it's something further up in the program, perhaps (and I don't know enough C++ to do more than take a random guess) what it is interpreting as a function or something, so when it sees the semicolon at the end, it is confused?
Logged
Eh?
Eh!

olemars

  • Bay Watcher
    • View Profile
Re: Programming Help Thread (For Dummies)
« Reply #26 on: May 03, 2011, 11:13:04 am »

Nevermind, I fixed it. I had the curly brace in the wrong spot. Anyway, now that it compiles again, is there any way for me to speed up compiles?

With a single sourcefile program like this, no there is not. Shouldn't be taking more than a few seconds even on an old, arthritic computer in any case.

What compiler and editor/IDE are you using?
Logged

MaximumZero

  • Bay Watcher
  • Stare into the abyss.
    • View Profile
Re: Programming Help Thread (For Dummies)
« Reply #27 on: May 03, 2011, 11:15:03 am »

Bloodshed C++

I have a feeling that I should be compiling like a boss, considering my computer, but it's just. so. slow. Took almost a minute and a half to compile this.
Logged
  
Holy crap, why did I not start watching One Punch Man earlier? This is the best thing.
probably figured an autobiography wouldn't be interesting

Nadaka

  • Bay Watcher
    • View Profile
    • http://www.nadaka.us
Re: Programming Help Thread (For Dummies)
« Reply #28 on: May 03, 2011, 11:19:00 am »

Wow. even my half million line java project at work only takes a couple minutes to actually compile if you don't count run the xdoclet crap. Bloodshed C++ should allow you to select a different compiler if you want to swap it out, but I wouldn't know what to recommend for compile time, GCC?
Logged
Take me out to the black, tell them I ain't comin' back...
I don't care cause I'm still free, you can't take the sky from me...

I turned myself into a monster, to fight against the monsters of the world.

MaximumZero

  • Bay Watcher
  • Stare into the abyss.
    • View Profile
Re: Programming Help Thread (For Dummies)
« Reply #29 on: May 03, 2011, 11:20:08 am »

I wonder if there's a compiler that will actually utilize my 6 core processor...
Logged
  
Holy crap, why did I not start watching One Punch Man earlier? This is the best thing.
probably figured an autobiography wouldn't be interesting
Pages: 1 [2] 3 4 ... 91