[QUOTE=Loli;25513882]Hey guys, minor problem. I have a file Content/Names/Last.txt but according to C# that file doesn't exist. I have stopped compiling and recompiled and checked it is in the precise destination. My code for loading it is...
[code]
int lineCount = File.ReadAllLines(@"Content/Names/Last").Length;
[/code]
I get the error
Could not find file 'C:\Users\Oli\Documents\Visual Studio 2010\Projects\Random Characters\Random Characters\Random Characters\bin\x86\Debug\Content\Names\Last'.
It doesn't work if I add the file extension either, any ideas?[/QUOTE]
Trace this [url]http://msdn.microsoft.com/en-us/library/07wt70x2.aspx[/url]
see what file names it gives you.
[QUOTE=BlkDucky;25514850]std::string something("Whatever");
sprintf(something.c_str());
Wouldn't that work?[/QUOTE]
If by s you mean f, then yes (with some more args). my example is actually slightly wrong :3 its more hassle for file input, not output (string, char, load into char make string equal to.)
I think the point for me is, that i dont entirely need to use a string
[QUOTE=Loli;25513882]Hey guys, minor problem. I have a file Content/Names/Last.txt but according to C# that file doesn't exist. I have stopped compiling and recompiled and checked it is in the precise destination. My code for loading it is...
[code]
int lineCount = File.ReadAllLines(@"Content/Names/Last").Length;
[/code]
I get the error
Could not find file 'C:\Users\Oli\Documents\Visual Studio 2010\Projects\Random Characters\Random Characters\Random Characters\bin\x86\Debug\Content\Names\Last'.
It doesn't work if I add the file extension either, any ideas?[/QUOTE]
Try [b]File.ReadAllLines(Directory.GetCurrentDirectory() + "\\Content\\Names\\Last.FILEEXTENSION").Length;[/b]
What i do when i read files, is use a streamreader, let me show you.
[cpp]using System.IO;
try
{
TextReader textReader = new StreamReader(PathToFile);
}
catch(Exception e)
{
Console.WriteLine(e.Message);
}
textReader.ReadToEnd(); // Can be used in a foreach loop to read through a file, for example, foreach(string line in textReader.ReadToEnd().Split('\n')) { Console.WriteLine(line); }.
textReader.ReadLine(); // Read the current line.
textReader.Close() // Be sure to close it!![/cpp]
Not sure if this is "the right way", but it works perfectly fine for me.
[QUOTE=Icedshot;25514970]If by s you mean f, then yes (with some more args). my example is actually slightly wrong :3 its more hassle for file input, not output (string, char, load into char make string equal to.)
I think the point for me is, that i dont entirely need to use a string[/QUOTE]
I still see no reason to ever use a char array over a string...
I'm using PDCurses atm and the functions only accept char arrays and I still use strings and just .c_str() when needed.
Sometimes it's a stringstream.str().c_str(), actually.
[QUOTE=Icedshot;25514622]Its not a matter that i dont know how to use them, its that im purposefully not using them because then i would have to deal with pieces of code like:
std::string something("W/e");
char somethingelse[100]={0};
sprintf(somethingelse, "%s",something.c_str());
fprintf(somethingelse, number, stream);
whereas i could could just use an array. Its probably because im doing it all Cstyle, as opposed to using streams etc.
Yeah, ordering probably is the norm, with implementations etc etc, but this way its easier for me to find things. for me at least
True, but i can tell if i destructed it, or if it was destructed by me. If it wasnt destructed by me, there is a problem. Player is rarely used not on the heap, so is slightly irrelevant anyway. Half of my programming is purely to learn new things, and to come up with new concepts of things i could do, like this destructing-ness. Oh and also, if something goes wrong, delete whatever is called (which just deletes the memory, and ignores the invalid acc info), and if something doesnt, it saves the account, then deletes the memory. Thats mostly why i use both.
Yeah, i know what you mean.[/QUOTE]
Why use c-strings at all?
Also, fprintf(something.c_str(), number, stream);
Finding stuff when it is structured inside header and implementation files might just be something that takes a little time. So just start now, it's not like you have a huge codebase already and finding stuff would take much time.
You should probably also keep a clean folder structure and don't give variables weird names. I think I remember some variables like K, K1 and K_Psomething.
You can write your own destructor - as you even have. So you can still save stuff on the harddrive.
And stuff is allocated via new, it must either be explicitly deleted by you - it will not be deleted by anyone else - or most OSs will clean up after the program terminates, in which case you couldn't do anything the the object anymore anyways.
Also a neat way to handle pointers in C++ is smart pointers. If I want to handle pointers by myself I usually make sure that noone else can by returning references and only using the pointer in the internals of the class taking care of it.
[QUOTE=Dj-J3;25514975]Try File.ReadAllLines(Directory.GetCurrentDirectory() + "\\Content\\Names\\Last.FILEEXTENSION").Length;
What i do when i read files, is use a streamreader, let me show you.
[cpp]using System.IO;
try
{
TextReader textReader = new StreamReader(PathToFile);
}
catch(Exception e)
{
Console.WriteLine(e.Message);
}
textReader.ReadToEnd();
textReader.ReadLine(); // Either of these two, depending on what you want.
textReader.Write();
textReader.WriteLine(); // Same applies as above.[/cpp]
Not sure if this is "the right way", but it works perfectly fine for me.[/QUOTE]
That didn't do anything...
[editline]19th October 2010[/editline]
[QUOTE=Darwin226;25514877]Trace this [url]http://msdn.microsoft.com/en-us/library/07wt70x2.aspx[/url]
see what file names it gives you.[/QUOTE]
This says that they exist...
[QUOTE=Icedshot;25514970]If by s you mean f, then yes (with some more args). my example is actually slightly wrong :3 its more hassle for file input, not output (string, char, load into char make string equal to.)
I think the point for me is, that i dont entirely need to use a string[/QUOTE]
char input[100];
fgets(input, sizeof(input), stream);
std::string something(input);
Also, std::istream.
[editline]19th October 2010[/editline]
mah automerge :arghfist:
[QUOTE=BlkDucky;25515049]I still see no reason to ever use a char array over a string...
I'm using PDCurses atm and the functions only accept char arrays and I still use strings and just .c_str() when needed.
Sometimes it's a stringstream.str().c_str(), actually.[/QUOTE]
if i want to read information from a file using the normal methods i use, ill have to switch between strings and arrays.
[QUOTE=Overv;25513634]Todo Freely is awesome too.
[img_thumb]http://gyazo.com/1169ae8d93dd7843a5bdf72823c870a7.png[/img_thumb][/QUOTE]
[img_thumb]http://www.tinyimg.org/images/781tasklist.png[/img_thumb]
Visual Studio already has a TODO list implemented, another thing is that it also scans your comments for "//TODO: " or "//HACK: ", etc
[QUOTE=Loli;25515098]That didn't do anything...[/QUOTE]
:O
It should work perfectly fine afaik.
Willing to post the code?
Found a suitable MP3 encoding library and got it to work!
Now to add a usable UI to it! :D
[QUOTE=ZeekyHBomb;25515078]Why use c-strings at all?
Also, fprintf(something.c_str(), number, stream);
Finding stuff when it is structured inside header and implementation files might just be something that takes a little time. So just start now, it's not like you have a huge codebase already and finding stuff would take much time.
You should probably also keep a clean folder structure and don't give variables weird names. I think I remember some variables like K, K1 and K_Psomething.
You can write your own destructor - as you even have. So you can still save stuff on the harddrive.
And stuff is allocated via new, it must either be explicitly deleted by you - it will not be deleted by anyone else - or most OSs will clean up after the program terminates, in which case you couldn't do anything the the object anymore anyways.
Also a neat way to handle pointers in C++ is smart pointers. If I want to handle pointers by myself I usually make sure that noone else can by returning references and only using the pointer in the internals of the class taking care of it.[/QUOTE]
Yeah, i realised that in the other guys quote. Its for file input i have to change things around
True, but i find my current method easy to manage?
Folder structure and headers and everything is something im working, my older code is even more awful :3 And K_ was a prefix i was using so i could remember what everything was. And also because i have a huge lump of functions to do with drawing, so i named them all K_ so it wouldnt conflict with other things. For variables, i am (extremely inconsistantly :3) using KG_ for globals, KT_ for things that only temporarily store info, KTE_ for things that really really temporarily store information (ill admit, it isnt the best system, though it helps), and KF for Files etc. I havent even slightly used it consistently though
The essential point of my thing is though - im handling user information with accounts. If someone does something invalid, i can delete the structure, and it wont do anything (no saving or anything). If someone does something valid, itll player::Delete it, which will save player information, then delete player memory. This gives me a different way to handle errors in player info, and proper exits. (though this might not be precisely what it does currently).
Oh, and despite doing all of the C++ tuts, i never really found out what std::istream and ostream do better, so i stuck with "normal" file pointers, because im pretty familiar with them already. Apart from perhaps being easier to use, what do streams actually have over simply reading a line from a file?
[QUOTE=Hexxeh;25515332]Found a suitable MP3 encoding library and got it to work!
Now to add a usable UI to it! :D[/QUOTE]
I was going to suggest LAME but never-mind =D
[editline]19th October 2010[/editline]
[QUOTE=Icedshot;25515348]Oh, and despite doing all of the C++ tuts, i never really found out what std::istream and ostream do, so i stuck with "normal" file pointers, because im pretty familiar with them already. Apart from perhaps being easier to use, what do streams actually have over simply reading a line from a file?[/QUOTE]
They're a little more convenient.
This probably isn't the best example but I'm just reading all the lines
of this file into a vector of strings.
[CODE]
std::fstream file("test.asm");
std::vector<std::string> lines;
if(!file.is_open())
return 0;
char line[256];
while(!file.eof())
{
file.getline(line,256);
lines.push_back(line);
}
file.close();
[/CODE]
std::fstream will automatically deallocate when it goes out of scope, saves you a line of code.
I'm writing a spec out for what (I hope) a bitfile will look like. Criticisms and suggestions are welcome :)
[code]
#!/usr/bin/env bit
# Using a Python context manager allows for easier scoping in my opinion.
# It's not enforced, but it's encourage for sure.
with Project('ledger', 'release', 'debug', 'install') as ledger:
ledger.type('static')
# Files
ledger.files.add('source/shared')
if bit.windows: ledger.files.add('source/win32')
else: ledger.files.add('source/posix')
# Debug Configuration Options
ledger.debug.include('include')
ledger.debug.warning('max')
# Release Configuration Options
ledger.release.include('include')
if bit.darwin: ledger.release.arch('i386', 'x86_64', 'ppc')
ledger.release.optimize('max')
# Install Configuration Options
ledger.install.add('include')
ledger.install.add(ledger.output)
[/code]
While I haven't always been a fan of magic behind the scenes, the idea for the backend is that given a specific setting the "targets" (which are basically the compiler instance themselves), will be able to apply settings accordingly. Which means you'll no longer do this:
[code]
if bit.windows: ledger.release.flags('/Qlong-double')
if bit.macosx: ledger.release.flags('-Wall')
[/code]
(Which is something that I was starting to do)
and instead you'll do this:
[code]
ledger.release.flags('long-double') # Ignored on non-msvc compilers
ledger.release.flags('pedantic') # Ignored by MSVC, but sets -pedantic for clang and gcc
[/code]
The way this is going to be implemented is with a dict of a <string, def>, (although technically anything that can be called as a function or method could be placed as the value).
The underlying "basic" methods would be sort of like:
[code]
def optimize(self, level):
optimize_dict.get(level, do_nothing)()
[/code]
So if the given key is not in the dict, nothing will happen (though I may have bit emit a warning. We'll see).
This is going to result in some pretty large classes, as each specific method is going to require some form of its own dict, otherwise it won't know how to handle anything. The hard part I think will be the generic unknown flags. I may not do with them what optimize and warning will, but rather depend on the user to use their best judgment, but at least you won't have to add a - or a / in front of each.
Also, I think I've said it already, but I am shooting for IronPython support, which allows for the compiling of a .NET assembly (DLL). This means you'll be able to use bit without having python installed on windows. Though to [i]build[/i] said assembly you will need IronPython (but I'll be distributing those myself).
Yesh, it evolved into a new timewaster app!
Download here: [url]http://braxnet.org/unifrog/[/url]
[QUOTE=Giraffen93;25516831]Yesh, it evolved into a new timewaster app!
Download here: [url]http://braxnet.org/unifrog/[/url][/QUOTE]
Does it do anything? :v:
It adds to the counter on the homepage, and finally shows how pathethic some people are :v:
[img]http://gyazo.com/d3e74407d55a379f727d9e7c340efd1f.png[/img]
Echoey rooms now... echo when you shout in them.
[b]TextCraft Beta[/b]
Time for another beta test :buddy:
Included some items this time so you don't have to add some yourself if you don't want too. (although i haven't made all craft recipes for them)
Download at
- [url=http://filesmelt.com/dl/TextCraft1.rar]Filesmelt[/url]
[release]
[b]Updates:[/b]
- Core engine stability is improved(hopefully, and most likely).
- Added requested features. (all of them afaik, if i haven't forgotten about any)[/release]
Yet again i fail to create a proper shortcut. :sigh: You know what to do. :v:
[QUOTE=bladerunner627;25515223][img_thumb]http://www.tinyimg.org/images/781tasklist.png[/img_thumb]
Visual Studio already has a TODO list implemented, another thing is that it also scans your comments for "//TODO: " or "//HACK: ", etc[/QUOTE]
Visual Studio is just awesome.
[QUOTE=BlkDucky;25517210][img_thumb]http://gyazo.com/d3e74407d55a379f727d9e7c340efd1f.png[/img_thumb]
Echoey rooms now... echo when you shout in them.[/QUOTE]
Is there any way to change the color of the words? If so, it would be cool if the echo's faded to black.
[QUOTE=luck_or_loss;25517965]Is there any way to change the color of the words? If so, it would be cool if the echo's faded to black.[/QUOTE]
Yeah. I'm not sure why the colour isn't working... And even then I'm limited to 16 (?) colours so it'd most likely be 3 shades absolute maximum.
[QUOTE=Dj-J3;25517281][b]TextCraft Beta[/b]
Time for another beta test :buddy:
Included some items this time so you don't have to add some yourself if you don't want too. (although i haven't made all craft recipes for them)
Download at
- [url=http://filesmelt.com/dl/TextCraft1.rar]Filesmelt[/url]
[release]
[b]Updates:[/b]
- Core engine stability is improved(hopefully, and most likely).
- Added requested features. (all of them afaik, if i haven't forgotten about any)[/release]
Yet again i fail to create a proper shortcut. :sigh: You know what to do. :v:[/QUOTE]
:love:
[QUOTE=Giraffen93;25516952]It adds to the counter on the homepage, and finally shows how pathethic some people are :v:[/QUOTE]
Are those achievements I spot on the homepage?
Yes. Not scripted yet, too tired right now, gonna do it tomorrow.
First demo of Dumpify, my Spotify track dumper:
[url]http://screencast.com/t/vlXhBYOE[/url]
Apologies for the audio quality on the video, Jing will only record from microphone, so it's just picking up the playback from my speakers. Dumps at 128K right now by default, going to add the option for 320K soon. Adding Spotify URL and playlist support tomorrow (this is trivial, really). Right now you can just type in a search term and I'll dump the first track.
[QUOTE=Dlaor-guy;25517680]Visual Studio is just awesome.[/QUOTE]
While I do agree, lots of IDEs have this.
[editline]19th October 2010[/editline]
[QUOTE=Chandler;25513035]Maybe I should write a todo-list script or something. Command line supremacy :v:[/QUOTE]
[img]http://dl.dropbox.com/u/313489/SS-20.37.59-0001.png[/img]
[QUOTE=Hexxeh;25519576]First demo of Dumpify, my Spotify track dumper:
[url]http://screencast.com/t/vlXhBYOE[/url]
Apologies for the audio quality on the video, Jing will only record from microphone, so it's just picking up the playback from my speakers. Dumps at 128K right now by default, going to add the option for 320K soon. Adding Spotify URL and playlist support tomorrow (this is trivial, really). Right now you can just type in a search term and I'll dump the first track.[/QUOTE]
How legal is this?
[QUOTE=layla;25519702]How legal is this?[/QUOTE]
It breaks the Spotify EULA, in terms of legality, I have no idea.
Will be including huge disclaimers when releasing the source, and enforcing the requirement of a premium account.
[QUOTE=Hexxeh;25519576]First demo of Dumpify, my Spotify track dumper:
[url]http://screencast.com/t/vlXhBYOE[/url]
Apologies for the audio quality on the video, Jing will only record from microphone, so it's just picking up the playback from my speakers. Dumps at 128K right now by default, going to add the option for 320K soon. Adding Spotify URL and playlist support tomorrow (this is trivial, really). Right now you can just type in a search term and I'll dump the first track.[/QUOTE]
You, sir, are awesome.
Sorry, you need to Log In to post a reply to this thread.