[QUOTE=raccoon12;21102710]just realized, my file will never close
edit:
my function ends before closing it
Says file isn't open[/QUOTE]
What are you passing in as a filename? There is no need to use the mode "in" here, and ofstream's constructor provides "out" as the default mode argument.
[cpp]
std::ofstream file(name.c_str())
[/cpp]
still doesn't work
what the hell is going on
-snip-
[QUOTE=Hypershadsy;21102523][code]TextWriter tw = new StreamWriter("text.txt");[/code]
Wassap y'all.[/QUOTE]
That won't work, you need a cast
try it out yourself
[QUOTE=turb_;21104134]That won't work, you need a cast[/QUOTE]
StreamWriter inherits from TextWriter.
[QUOTE=jA_cOp;21105234]StreamWriter inherits from TextWriter.[/QUOTE]
Oh does it? I thought it was the other way round.
[QUOTE=turb_;21105814]Oh does it? I thought it was the other way round.[/QUOTE]
I checked with the MSDN before posting :)
Smarty :p
I was posting from my iPod touch so I just assumed TextWriter : StreamWriter, as StreamWrite sounded more generic
Fixed my own problem, I changed
[cpp]double camX = sqrt( ( sin( pitch ) / tan( pitch ) ) * ( sin( pitch ) / tan( pitch ) ) - sin( yaw ) * sin( yaw ) );
Vector( camX, sin( yaw ), sin( pitch ) ) * distance + center[/cpp]
to
[cpp]Vector camPos = Vector( cos( window.pitch ), 0.0f, sin( window.pitch ) ) * window.distance;
camPos = Vector( cos( window.yaw ) * camPos.x, sin( window.yaw ) * camPos.x, camPos.z ) + center;[/cpp]
I was making the whole thing much more complicated than it actually is.
[QUOTE=turb_;21106073]Smarty :p
I was posting from my iPod touch so I just assumed TextWriter : StreamWriter, as StreamWrite sounded more generic[/QUOTE]
Stream supremacy.
Any reason why this still doesn't work?
[cpp]#include <string>
#include <fstream>
#include <iostream>
class FileHandle
{
public:
void WriteToFile(std::string name, std::string fileData);
};
void FileHandle::WriteToFile(std::string name, std::string fileData)
{
std::ofstream file(name.c_str());
file.open(name.c_str());
if(file.is_open())
{
file << fileData;
std::cout << "File is open..";
}
else
{
std::cout << "File isn't open...";
}
file.close();
}
[/cpp]
[cpp]
#include "file.h"
int main()
{
FileHandle file;
file.WriteToFile("R:\\test.txt", "weiners");
std::cin.get();
}
[/cpp]
tells me the file isn't open
Don't call open on the std::ofstream after creating it with that constructor, it already opens the file for you.
so I wanted to try something that I tried in visual basic a while ago and failed..
im trying to make a form with a richtextbox and a button. when I put Lua into the textbox and press the button, it runs it and the output it printed into a label underneath it. I have got LuaInterface working, and Luanet as well as lua51.dll all in there respective places. What should I do to achieve my goal?
[QUOTE=jA_cOp;21121863]Don't call open on the std::ofstream after creating it with that constructor, it already opens the file for you.[/QUOTE]
thank you, although it still doesn't work
[QUOTE=Chad Mobile;21121929]so I wanted to try something that I tried in visual basic a while ago and failed..
im trying to make a form with a richtextbox and a button. when I put Lua into the textbox and press the button, it runs it and the output it printed into a label underneath it. I have got LuaInterface working, and Luanet as well as lua51.dll all in there respective places. What should I do to achieve my goal?[/QUOTE]
I'm not too sure what you're having trouble with, what exactly isn't working/are you stuck on?
I'm not sure how to actually run the Lua and have it output to the label or another textbox. :frown:
[QUOTE=Chad Mobile;21122549]I'm not sure how to actually run the Lua and have it output to the label or another textbox. :frown:[/QUOTE]
[url]http://einfall.blogspot.com/2006/05/scripting-with-lua-in-c.html[/url]
That might help you, but basically, you want to create a new Lua object, use RegisterFunction to attach any functions you want the lua that you're inputting to use (such as a function that takes text and outputs it in the textbox/label), and then call DoString on the contents of the textbox.
[QUOTE=raccoon12;21121952]thank you, although it still doesn't work[/QUOTE]
Might be your OS blocking file access for security reasons. Try using a file in the same directory instead.
[QUOTE=Wishfallen;21122759][URL]http://einfall.blogspot.com/2006/05/scripting-with-lua-in-c.html[/URL]
That might help you, but basically, you want to create a new Lua object, use RegisterFunction to attach any functions you want the lua that you're inputting to use (such as a function that takes text and outputs it in the textbox/label), and then call DoString on the contents of the textbox.[/QUOTE]
Damn, now I have to learn what that means or how to do it. :frown:
[QUOTE=Chad Mobile;21122924]Damn, now I have to learn what that means or how to do it. :frown:[/QUOTE]
... isn't that the fun part?
Yeah, but it can get a little boring reading a long tutorial and then finding out the part you needed was way at the end. lol
The code?
What?
He's referring to the fact that most tutorials have copyable code at the end.
I don't haven't seen any that works or is not for a console app.
[QUOTE=noctune9;21122914]Might be your OS blocking file access for security reasons. Try using a file in the same directory instead.[/QUOTE]
yep, ran the program as administrator, it created the file
[QUOTE=Chad Mobile;21124544]I don't haven't seen any that works or is not for a console app.[/QUOTE]
The tutorial explains it pretty clearly, I have never even made something serious with either Lua or C# and that's very easy to understand.
[QUOTE=Chad Mobile;21124544]I don't haven't seen any that works or is not for a console app.[/QUOTE]
:wtc:
Yet again you have blown my mind, Mr Mobile.
Sorry, you need to Log In to post a reply to this thread.