Bay 12 Games Forum

Please login or register.

Login with username, password and session length
Advanced search  
Pages: 1 ... 53 54 [55] 56 57 ... 91

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

Shades

  • Bay Watcher
    • View Profile
Re: Programming Help Thread (For Dummies)
« Reply #810 on: October 08, 2012, 04:33:52 am »

I use Eclipse for most stuff. It's terrible and slow but it's better than most of the other IDE's I've used. For Java or C++ at least, although it's syntax parsing of C++ is appalling. I use Netbeans for PHP which also has Java support, but I don't know how good it is for that.

I also spend a lot of time in Vim, with it's vast collection of plugins you can pretty much customise it how you like. Although it's autocomplete functions for programming suffers somewhat imo. However it is installed everywhere so always to hand, very fast and easy to use.
Logged
Its like playing god with sentient legos. - They Got Leader
[Dwarf Fortress] plays like a dizzyingly complex hybrid of Dungeon Keeper and The Sims, if all your little people were manic-depressive alcoholics. - tv tropes
You don't use science to show that you're right, you use science to become right. - xkcd

Silfurdreki

  • Bay Watcher
    • View Profile
Re: Programming Help Thread (For Dummies)
« Reply #811 on: October 08, 2012, 06:54:20 am »

I'm back with more noob problems!

I've gotten far enough that I now have a single line file consisting of roughly 8 million hexadecimal numbers, separated by spaces, stored as text in a temporary file. Something like this, only longer:

Code: [Select]
ffff 5a7 53ef 816 54 e7f
I want to read these and convert them to decimal numbers. I've tested the function fscanf, but I'm not quite sure it does what I want it to do (my own testing has yielded strange results). What I want is simple, read 1 to 4 characters, treat them as a hexadecimal number and then write them to another file. Any advice?

I appreciate any and all advice!
Logged
Quote
Entropy is not what it used to be.

The Watcher

  • Bay Watcher
    • View Profile
Re: Programming Help Thread (For Dummies)
« Reply #812 on: October 08, 2012, 06:59:57 am »

Assume each number is four hex characters.
Us whatever i/o library to read them into a [4] sized array, then convert all letters to number values and number characters to values. Then, do 16^3*[0] + 16^2*[1] + 16^1*[2] + [3].
[n] is the nth position in that array.

The result of the above should be assigned to a variable, then converted to a string and output.


Note that the above may be far from optimal.
Logged

RulerOfNothing

  • Bay Watcher
    • View Profile
Re: Programming Help Thread (For Dummies)
« Reply #813 on: October 08, 2012, 07:20:55 am »

So fscanf(file,"%s ",&str) doesn't load characters up to the next space? What "strange results" have you been getting? If it doesn't do what I think it does I might be able to give you some better advice after a bit of thought.
Logged

Silfurdreki

  • Bay Watcher
    • View Profile
Re: Programming Help Thread (For Dummies)
« Reply #814 on: October 08, 2012, 11:14:10 am »

Now that I see your post there, I might have made the mistake of supplying fscanf with a variable rather than the pointer to said variable. I'll check it out once I get back to uni tomorrow.

For the record, I get a very large number as output (something like ffaa5000, I can't quite remember), the first input is supposed to be ffff.

Assume each number is four hex characters.
Us whatever i/o library to read them into a [4] sized array, then convert all letters to number values and number characters to values. Then, do 16^3*[0] + 16^2*[1] + 16^1*[2] + [3].
[n] is the nth position in that array.

The result of the above should be assigned to a variable, then converted to a string and output.


Note that the above may be far from optimal.

I might be able to work with something like this if fscanf turns out to be too much trouble, thanks for the suggestion.
Logged
Quote
Entropy is not what it used to be.

DeadlyLintRoller

  • Bay Watcher
    • View Profile
Re: Programming Help Thread (For Dummies)
« Reply #815 on: October 08, 2012, 11:19:41 pm »

I'm back with more noob problems!

I've gotten far enough that I now have a single line file consisting of roughly 8 million hexadecimal numbers, separated by spaces, stored as text in a temporary file. Something like this, only longer:

Code: [Select]
ffff 5a7 53ef 816 54 e7f
I want to read these and convert them to decimal numbers. I've tested the function fscanf, but I'm not quite sure it does what I want it to do (my own testing has yielded strange results). What I want is simple, read 1 to 4 characters, treat them as a hexadecimal number and then write them to another file. Any advice?

I appreciate any and all advice!

Even though folk don't seem to take kindly to java around here. here is how to do it in that.

Code: [Select]
import java.io.FileNotFoundException;
import java.io.PrintWriter;
import java.io.File;
import java.util.Scanner;
public class ReadHex {

public static void main(String[] args) throws FileNotFoundException {

Scanner input = new Scanner(new File(args[0]));

String output = "";
PrintWriter out = new PrintWriter(args[1]);

while(input.hasNext()){
String hex = input.next();
out.print(Integer.parseInt(hex,16)+" ");
}

out.close();

}
}

It takes arguments in through the command line, but you could modify for a prompt.
Logged
I'm back!

Thendash

  • Bay Watcher
    • View Profile
Re: Programming Help Thread (For Dummies)
« Reply #816 on: October 09, 2012, 03:48:11 am »

Why don't people like java around here? I like it... That being said, c# is my go to language right now.
Logged
Thendash's Livestream

This game could honestly give out hand jobs for free and people would still bitch.

MorleyDev

  • Bay Watcher
  • "It is not enough for it to just work."
    • View Profile
    • MorleyDev
Re: Programming Help Thread (For Dummies)
« Reply #817 on: October 09, 2012, 03:54:30 am »

Why don't people like java around here? I like it... That being said, c# is my go to language right now.

It's pretty common for programmers who don't exclusively code in Java to have lots of complaints with Java that seem small by themselves but when combined together form a wall of pain.

If I'll be permitted, I present a rant I did elsewhere about some of my issues: I don't like the way it's built up as a language.

Spoiler (click to show/hide)
« Last Edit: October 09, 2012, 01:49:35 pm by MorleyDev »
Logged

Valid_Dark

  • Bay Watcher
  • If you wont let me Dream, I wont let you sleep.
    • View Profile
Re: Programming Help Thread (For Dummies)
« Reply #818 on: October 09, 2012, 12:26:09 pm »

http://me.veekun.com/blog/2012/04/09/php-a-fractal-of-bad-design/

fixed that for you


Spoiler: quote from article (click to show/hide)
« Last Edit: October 09, 2012, 12:29:35 pm by Valid_Dark »
Logged
There are 10 types of people in this world. Those that understand binary and those that don't


Quote
My milkshake brings all the criminals to justice.

DeadlyLintRoller

  • Bay Watcher
    • View Profile
Re: Programming Help Thread (For Dummies)
« Reply #819 on: October 09, 2012, 12:30:21 pm »

I'm not out to advocate java over other languages. Learning it was a pragmatic choice. I wanted to enroll in a reputable master's program with in-state tuition, which lead me to Virginia Tech's M.I.T. which is all about the java. Same goes for php, which I use for work. php is pretty bad in a lot of ways, but given that it was conceived by some random Dutch-Canadian guy for his personal website, can you blame it?

I don't yet have the experience to articulate the shortcomings/strengths it has over other languages, but I would agree that java was tough to start off on as a complete beginner programmer. There are a lot things happening that you just need to accept as the way it's done until you have built out the context within your knowledge to understand why that's happening. But, I'd guess that is true for many languages. Like anything it just requires experience.

In the DF skill level measuring system (assuming 1 xp = 1 hour practicing a given craft), I guess I am a Competent Programmer. but that time is split between php, javascript and java, plus other mundane tasks that relate to being a developer, but not necessarily actual coding, like setting up a vhost, releases, version control etc.
Logged
I'm back!

Levi

  • Bay Watcher
  • Is a fish.
    • View Profile
Re: Programming Help Thread (For Dummies)
« Reply #820 on: October 09, 2012, 01:05:41 pm »

In sheer "get stuff done fast" power, Ruby is still my favorite.  I can translate what is in my head to code so quickly with it.  Its not appropriate for everything, but man is it ever useful. 

I actually didn't mind java much until after I learned Ruby.  Now I'm spoiled and everything in java just seems like too much work.   :P
Logged
Avid Gamer | Goldfish Enthusiast | Canadian | Professional Layabout

Urist McScoopbeard

  • Bay Watcher
  • Damnit Scoopz!
    • View Profile
Re: Programming Help Thread (For Dummies)
« Reply #821 on: October 09, 2012, 05:20:05 pm »

My question is what IDE should I be using?
Tip #1: Don't learn Java.
But if you do, IntelliJ is quite a good IDE.

I dont have a choice, that's what taught in comp sci H/AP

... And to be honest i'm not looking to create the world's most processing intensive game.

EDIT: although to be honest i would have rather liked to take class for c/c++/c#
« Last Edit: October 09, 2012, 05:25:42 pm by Urist McScoopbeard »
Logged
This conversation is getting disturbing fast, disturbingly erotic.

MorleyDev

  • Bay Watcher
  • "It is not enough for it to just work."
    • View Profile
    • MorleyDev
Re: Programming Help Thread (For Dummies)
« Reply #822 on: October 09, 2012, 05:46:33 pm »

I'll tell you what I tell everybody else who does Computer Science:

Don't bother with the lectures. Well, bother with them. But find the time, completely separate from course and obligation, to program and learn to program. Use a different language even! I maintain lectures and academia are as fitting a place to learn programming as they are to learn painting. You can pick up useful tid-bits, get help with technique and understanding, but ultimately, you need to do the self-study to actually develop any skill.

Working in a team is also very useful. Find someone who knows about as much as you and pair with them. Sit at one computer and take turns coding to get something working, communicate, share ideas and understanding, ask each other for help when you hit a wall.
Logged

Urist McScoopbeard

  • Bay Watcher
  • Damnit Scoopz!
    • View Profile
Re: Programming Help Thread (For Dummies)
« Reply #823 on: October 09, 2012, 08:49:09 pm »

This is high school comp sci, there are no 'lectures' infact the teacher doesn't talk too much about coding at all, most of the learning is conceptual, then we're asked to write a program. Goes on like that, and then we have short quizzes.

However, I like your suggestion, only problem now is most of the kids in the class are either terrible or terribly unsocialable. (my only close friend in the class doesnt really get the logic)
Logged
This conversation is getting disturbing fast, disturbingly erotic.

Valid_Dark

  • Bay Watcher
  • If you wont let me Dream, I wont let you sleep.
    • View Profile
Re: Programming Help Thread (For Dummies)
« Reply #824 on: October 09, 2012, 08:57:33 pm »

I've always wanted someone to code with :(
Logged
There are 10 types of people in this world. Those that understand binary and those that don't


Quote
My milkshake brings all the criminals to justice.
Pages: 1 ... 53 54 [55] 56 57 ... 91