|
ROTFL - you're usually the one who beats me :P
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
jblouir wrote: I just read an article on parsing in c# and they said that unlike older languages, parsing in c# in simple terms, for a beginner, can be a nightmare.
Anything for a beginner is a nightmare, until they learn it's really very easy! I have no idea where you read that, but stop.
jblouir wrote: Is it possible to pull this data out in chunks using StreamReader?
Sure. But, you don't have to use ReadToEnd. Just read a line of the file (StreamReader.ReadLine), split the line on your delimitter (String.Split) to get the string values in an array, then process the first item in the array. That will tell you how many more items there should b in the array and what to do with them. Read the next line in the file. Rinse and Repeat.
|
|
|
|
|
The other responses are correct, but have you considered using XML?
|
|
|
|
|
I am trying to start with basic stuff, instead of jumping into 2d/3d graphics and using databases, so im just making a text adventure (In console) with simple data files for storing data, I might use serialisation for saving the game state(save games).
After that then ill move up to the fancier code. )
|
|
|
|
|
jblouir wrote: so im just making a text adventure (In console)
Splendid! Splendid! Check out Collosal Cave Adventure[^] if you haven't already played it.
/ravi
|
|
|
|
|
Thanks for your help previously, been implementing it into my code.
Its changed a bit because I had problems with getting the .Count to work, doesnt appear to be in my namespaces.
but anyway heres what I have, the program doesnt get any syntax errors, but during the program running I get an error that...(scroll down)
#region dataload()
// Extracting the data from databin and dumping it in to an array.
static void dataload()
{
int intIndex = 0;
string strRoom = "anything";
string strDesc = "anything";
string strLook = "anything";
int intElement = 0;
int i = 0;
string[] lines = File.ReadAllLines("databin.txt");
foreach (string line in lines)
{
string[] elements = line.Split(new char[] { ',' });
intElement = elements.Length;
if (intElement > 0)
{
int n;
if (int.TryParse(elements[0], out n))
{
// the first element was a number, now stored in n
intIndex = n;
}
}
if (intElement > 1)
{
strRoom = elements[1];
}
if (intElement > 2)
{
strDesc = elements[2];
}
if (intElement > 3)
{
strLook = elements[3];
}
RoomData descriptor = new RoomData(intIndex, strRoom, strDesc, strLook);
GlobalVars.ArrRoomData.SetValue(descriptor,i);
i = i++;
// etc.
}
}
#endregion
the error points to GlobalVars.ArrRoomData.SetValue(descriptor,i); saying that the object reference not set to an instance of an object
ArrRoomData is declared in a class called GlobalVars (Global Variables), where...
private static object[] arrRoomData;
public object[] ArrRoomData
{
get { return arrRoomData; }
set { arrRoomData = value; }
}
I have a feeling that once it gets past this error im going to get another one on the fact that its going to try and declare another object named descriptor, which im guessing I can I can do an if check on a boolean to see if its already been declared once.
|
|
|
|
|
It's perhaps intElement.Length
jblouir wrote: string strRoom = "anything";
string strDesc = "anything";
string strLook = "anything";
This is outside your loop, so if a row fails, instead of a default, it will continue to contain the last value found.
jblouir wrote: saying that the object reference not set to an instance of an object
Odds are that a line doesn't have enough elements, and removing Count is making a check that is just invalid.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
At the bottom of the code where the particular code of line is highlighted.
descriptor is holding the correct values for index, room name, room desc, and room look.
The .Count I got around by using .Length which returns the number of elements in that line which logically to me does the same thing.
|
|
|
|
|
I Want to make the background and the tracker with images I've got.
There any dll that I can add my WinForm Controls ?
Thank alot.
|
|
|
|
|
I suspect you'd need to make the control owner drawn. I am certain there are examples of this here on code project.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
I have discovered the existence of IKVM.NET for the interoperability between java and .NET. I have tried to convert java libraries in DLL and to call them from C#... all ok. Is it possible, with IKVM, to call java libraries runtime without converting them in DLL?
|
|
|
|
|
No. Why do you think IKVM exists?
|
|
|
|
|
Askalo wrote: Is it possible, with IKVM, to call java libraries runtime without converting them in DLL?
AFAIK you have to convert them to a DLL file to use it in .net.
You can write a webservice in java to expose the methods and the .net application can communicate via the webservice to the application.
|
|
|
|
|
How i can use USB gates on C#.Net?
There are any ActiveX for this?
Thanks
P.S. I use Windows Vista
By Windows M
|
|
|
|
|
Windows M wrote: How i can use USB gates on C#.Net?
What's a "USB gate"?
|
|
|
|
|
Is a "Universal Serial Bus" device
Excuse me for error but i'm a italian boy.
By Windows M
|
|
|
|
|
Windows M wrote: Is a "Universal Serial Bus" device
I know what USB is. What's a USB "gate"???
|
|
|
|
|
Hi all.
What are the limitations of the Express Editions of C# etc?
And are other compilers just as good as microsoft's?
I've been tinkering around with C# (my first attempt at programming) for a
while now and i seem to be able to do everything with the Express edition(EE).
Would a buisness legally be able to use the EE to create custom software? Or
would i be able to create apps that i could sell with the EE?
Thanks.
|
|
|
|
|
Visual Studio .NET 2005 Feature comparison chart[^]
Ylno wrote: And are other compilers just as good as microsoft's?
There are others, but I haven't heard of anyone using them.
Ylno wrote: Would a buisness legally be able to use the EE to create custom software? Or would i be able to create apps that i could sell with the EE?
You could, but it's not recommended. You only get a single deployment solution, ClickOnce, which is not very flexible for commerical software.
You'd need an external installer editor to create application deployments that give you much greater flexibility over your installations.
If you really want to get into commercial software, use at least the Professional versions of Visual Studio.
|
|
|
|
|
The limitations tend to revolve around things like database connection tools. You can write any DB code you like, but you don't get the same tools to do it with.
Ylno wrote: And are other compilers just as good as microsoft's?
Microsoft's C++ compiler is very good, nowadays. The question makes no sense in any other context, I don't believe there's a bunch of viable contenders for C# and VB.NET compilers, although I believe one or two exist, when MS defines the language, they will always be the best, by definition.
Ylno wrote: Would a buisness legally be able to use the EE to create custom software? Or
would i be able to create apps that i could sell with the EE?
Surprisingly, I believe the answer is 'yes'.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
|
Thanks all.
I really should have looked at the FAQ !
|
|
|
|
|
hello,
I want to deselect a row in the datagridview, and I'm using the code:
<br />
if ( dgv[ hti.ColumnIndex, hti.RowIndex ].Selected )<br />
{<br />
dgv[ hti.ColumnIndex, hti.RowIndex ].Selected = false;<br />
}<br />
else<br />
{<br />
dgv[ hti.ColumnIndex, hti.RowIndex ].Selected = true;<br />
}<br />
this code is in the DatagridView_MouseClick.
the code does not work, anybody knows why?
thank you
|
|
|
|
|
First of all you could have written this like this:
<br />
dgv[ hti.ColumnIndex, hti.RowIndex ].Selected=!(dgv[ hti.ColumnIndex, hti.RowIndex ].Selected);<br />
Secondly, if the row is not selected it will become selected. Do you want this to happen?
|
|
|
|
|
You can use ClearSelection function of DataGridView
|
|
|
|