|
We need to validate an expression which contains all the arithematic operators, conditional operators, logical operators, grouping such as '()' and '{}'
For example:
A+B = 10 AND (B*C)/d = 56
Thanks in advance
|
|
|
|
|
This sounds very much like homework to me, but I might be wrong...
Internet - the worlds biggest dictionary
|
|
|
|
|
hi, can anyone help me how to set up DirectSound buffer notification points? im trying to use a streaming buffer and i wanted to set notification points to know if the buffer is almost full..
mumwei
|
|
|
|
|
Hello Friends,
I want to implement socket client project.
I want only one server and any number of clients.
Please suggest me something which will work faster.
Is it possible to communicate on same port.
Please help me fast.
Thanks in Advance.
Rahul Kulkarni
|
|
|
|
|
RahulRKulkarni wrote: Please suggest me something which will work faster.
Faster than sockets? Everything will go through a Socket eventually so you are already at the lowest level of abstraction for an application. If you want to get really down and dirty you could write an NDIS driver and manipulate the packets directly as they pass through your network card.
I would like to suggest that sockets are probably not your problem. Perhaps they way you are interacting with sockets is the problem. Perhaps the protocol you invented to sit on top of TCP/IP is inefficient.
RahulRKulkarni wrote: Is it possible to communicate on same port.
The client and server will have their own ports. The server will listen on the same port for all clients. What port the client receives data on can be the same or different. If one client machine can open several connections then the client will have to use several ports.
|
|
|
|
|
Hi,
I want to know how to display the files on the web page that is uploaded for downloading later one by one.Each of this file should be password protected.Can I use data grid?Can you please give the coding.The coding is to be in C#.And the db is MS-Access.Very Urgent.........
-- modified at 1:53 Friday 16th February, 2007
Regards,
Sharon.A.
|
|
|
|
|
i am currently trying to create a program that takes screen coordinates on a panel and on click stores that information in memory then continues the line from the last click. Basically creating a polyline.
I have been looking thru the forums and got these snippets of code:
mark1.MouseUp += new System.Windows.Forms.MouseEventHandler(this.Mark_MouseUp);
mark1.MouseDown += new System.Windows.Forms.MouseEventHandler(this.Mark_MouseDown);
mark1.MouseMove += new System.Windows.Forms.MouseEventHandler(this.Mark_MouseMove);
I ran the entire source that contained the above snippets and they produced effects similar to what i want.
So can anyone give advice on what to do or where i can go for source code similar to what i want?
oh btw the above snippet came from Drawing and Editing Lines with GDI+
By Butch.er. somewhere on this site.
ghost_uwi
|
|
|
|
|
I did this yesterday, apologies if i missed any snippets
Instance variables:
LinkedList<LinkedList<Point>> _lineDrawings = new LinkedList<LinkedList<Point>>();
LinkedList<Point> _currentDrawing;
Mousedown:
_currentDrawing = new LinkedList<Point>();
_lineDrawings.AddLast(_currentDrawing);
MouseMove:
if ((e.Button & MouseButtons.Left) > 0)
{
_currentDrawing.AddLast(new Point(e.X, e.Y));
}
Paint Method:
foreach (LinkedList<Point> pointList in _lineDrawings)
{
if (pointList.Count != 0)
{
Point LastPoint = pointList.First.Value;
foreach (Point point in pointList)
{
e.Graphics.DrawLine(new Pen(new SolidBrush(Color.Red)), LastPoint, point);
LastPoint = point;
}
}
}
Undo Method:
_lineDrawings.RemoveLast();
pctMainView.Invalidate();
Hope there's something in there to help you
Russell
PS sorry about the formatting, i don't seem to be able to get generics working without ticking the ignore HTML tags tickbox
-- modified at 3:39 Friday 16th February, 2007
|
|
|
|
|
I've just realised that when i read your post the first time I missed the bit about poly line. Unfortunately i don't have any code to do that but i'll take a stab at some ideas.
Create a line struct with a start and end point as properties.
Create an instance variable: LinkedList<Line> _lineCollection where Line is your struct.
Create another instance variable: Line _currentLine
Create another: bool _drawing
On the first click create a line with start and end at the samepoint and assign it to _currentLine, add this object to _lineCollection, also set _drawing to true.
On move:
Check if _drawing == true
set _lineCollection.Last to the current mouse position
Invalidate the drawing surface
SecondClick set endpoint of _lineCollection.Last to the Mouseposition and create a new line as before assign to _currentline etc.
In the Paint method of the form:
use a foreach loop to go through all the lines in _lineCollection
e.Graphics.drawLine(Line.Start,Line.End)
HTH
Russ
|
|
|
|
|
Ok thx for the help but the help was a bit out of my league.
I got some source code and mainpulated it a bit.
...
this.MouseDown += new System.Windows.Forms.MouseEventHandler(this.Painter_MouseDown);
this.MouseUp += new System.Windows.Forms.MouseEventHandler(this.Painter_MouseUp);
this.MouseMove += new System.Windows.Forms.MouseEventHandler(this.Painter_MouseMove);
...
Point ps = new Point();
Point pe = new Point();
private void Painter_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e)
{
if (flag_mouseclick == 0)
{
ps.X = e.X;
ps.Y = e.Y;
flag_mouseclick = 1;
}
pe = ps;
}
private void Painter_MouseUp(object sender, System.Windows.Forms.MouseEventArgs e)
{
Form thisform = (Form)sender;
Graphics g = thisform.CreateGraphics();
Pen p = new Pen(Color.Blue, 2);
g.DrawLine(p, ps, pe);
ps = new Point(e.X, e.Y);
g.Dispose();
}
protected void Painter_MouseMove(object sender, System.Windows.Forms.MouseEventArgs e)
{
Form thisform = (Form)sender;
pe = new Point(e.X, e.Y);
}
the above works around where i wanted it to.
But thx for the help none the less.
-- modified at 11:53 Friday 16th February, 2007
|
|
|
|
|
Can the Microsoft chart control take row values as double? If so how?(Any code example). And i want to plot the row values against the coloumn values.(as the coloumns contain a pointer on the chart for the specified coloumn value).
|
|
|
|
|
I am trying to search for a text in a file from my desktop whose extension i gave as .surya (Purposely) and i am not getting the results while searching as expected. But suppose i want my windows desktop search to start recognising this file extension What am i supposed to do please. I would like to have the details please to surya.raghava@gmail.com.
Surya Raghava.S
|
|
|
|
|
From within a C# application, I would like to invoke the Visual Studio command-line C++ compiler (cl.exe) to compile a simple console program (e.g., helloworld.cpp). The compiler messages should be redirected or captured to a text file.
I know the environment variables have to be set (using vcvars32.bat), but I have not had any luck in hitting on the correct sequencing and parameters for System.Diagnostics.Process methods, or the Process.StartInfo property settings. I think I'm in generally the right ball park--but maybe not.
Can anyone help?
Thanks so much,
Tom
|
|
|
|
|
I tried the following and got it working without any problems (using VS2005). I also tried it in a graphical application, storing the output in a multiline-textbox instead, without any problems. Good luck!
static void Main()
{
ProcessStartInfo psi = new ProcessStartInfo("cl.exe", " -GX c:\\hello.cpp");
psi.CreateNoWindow = true;
psi.RedirectStandardError = true;
psi.RedirectStandardOutput = true;
psi.UseShellExecute = false;
Process p = new Process();
p.StartInfo = psi;
p.ErrorDataReceived += new DataReceivedEventHandler(p_ErrorDataReceived);
p.Start();
p.BeginErrorReadLine();
string sout = p.StandardOutput.ReadToEnd();
p.WaitForExit();
StringBuilder builder = new StringBuilder();
builder.AppendLine("Error:");
foreach (String s in errData)
{
builder.AppendLine(s);
}
builder.AppendLine("Output:");
builder.AppendLine(sout);
Console.WriteLine(builder.ToString());
Console.WriteLine("Press ENTER to continue");
Console.ReadKey(true);
}
private static List<string> errData = new List<string>();
static void p_ErrorDataReceived(object sender, DataReceivedEventArgs e)
{
errData.Add(e.Data);
}
Internet - the worlds biggest dictionary
|
|
|
|
|
Thanks so much for your response! Wow, I'm impressed!
Unfortunately it didn't work for me. It appears that the appropriate environment variables have to be set.
When running from within VS2005 I had to provide the whole path to cl.exe. Even then, nothing appeared after your Error: and Output: lines.
When running outside the IDE, the program complained about not being able to find mspdb80.dll.
Do you know which environmental variables should be set up [programmatically], if that is indeed the problem?
Thanks again,
Tom
|
|
|
|
|
Sorry, no. That is a question you should ask in the C++ forum instead, since it is compiling C++ you have problems with, right?
Internet - the worlds biggest dictionary
|
|
|
|
|
Well, yes and no, but certainly thanks for setting me on the right path. With some experimentation I came up with a successful C# handler (based on your code, but with necessary environment variables set--and with directories hard coded for my computer) for a "compile and run" button as follows:
////////////////////////////
protected void CompileAndRun_Click(object sender, EventArgs e)
{
// Set up environment
Environment.SetEnvironmentVariable("INCLUDE", @"C:\Program Files\Microsoft Visual Studio 8\VC\ATLMFC\INCLUDE;C:\Program Files\Microsoft Visual Studio 8\VC\INCLUDE;C:\Program Files\Microsoft Visual Studio 8\VC\PlatformSDK\include;C:\Program Files\Microsoft Visual Studio 8\SDK\v2.0\include;");
Environment.SetEnvironmentVariable("LIB", @"C:\Program Files\Microsoft Visual Studio 8\VC\ATLMFC\LIB;C:\Program Files\Microsoft Visual Studio 8\VC\LIB;C:\Program Files\Microsoft Visual Studio 8\VC\PlatformSDK\lib;C:\Program Files\Microsoft Visual Studio 8\SDK\v2.0\lib");
Environment.SetEnvironmentVariable("LIBPATH", @"C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727;C:\Program Files\Microsoft Visual Studio 8\VC\ATLMFC\LIB");
Environment.SetEnvironmentVariable("Path", @"%Path%;C:\Program Files\Microsoft Visual Studio 8\Common7\IDE;C:\Program Files\Microsoft Visual Studio 8\VC\BIN");
// Compile program
ProcessStartInfo psi = new ProcessStartInfo("cl.exe", @" -Fec:\testCompile\hello.exe -EHsc c:\testCompile\hello.cpp");
psi.CreateNoWindow = true;
psi.RedirectStandardError = true;
psi.RedirectStandardOutput = true;
psi.UseShellExecute = false;
Process p = new Process();
p.StartInfo = psi;
p.Start();
p.WaitForExit();
compilerMessages.Text = p.StandardOutput.ReadToEnd(); ;
//Execute program
ProcessStartInfo psi2 = new ProcessStartInfo(@"c:\testCompile\hello.exe");
psi2.CreateNoWindow = true;
psi2.RedirectStandardError = true;
psi2.RedirectStandardOutput = true;
psi2.UseShellExecute = false;
Process p2 = new Process();
p2.StartInfo = psi2;
p2.Start();
p2.WaitForExit();
programOutput.Text = p2.StandardOutput.ReadToEnd();
}
/////////////
Again, thanks!
Tom
|
|
|
|
|
Glad I could help!
Internet - the worlds biggest dictionary
|
|
|
|
|
Using VS2005 (not patched), writing a ASP.Net web app, using C# for the code-behind...
I have the following function:
public bool LoadFromDataSet(DataSet ds)
{
bool bSuccess = false;
if (ds != null)
{
foreach (DataTable table in ds.Tables)
{
foreach (DataRow row in table.Rows)
{
CEmployee employee = new CEmployee();
employee.LoadFromDataRow(row);
this.Add(employee);
}
}
bSuccess = true;
}
return bSuccess;
}
the intent is to read any records that might be contained within the dataset. It is assumed that if the dataset doesn't contain any records (ds.Extendedproperties.Count == 0 ), the inner-most foreach code would not be processed. What is actually happening is that it IS processing the dataset as if there were records in it. In fact, it never exits from the inner-most loop.
To coerce the function into perform as desired, I changed the function accordingly:
public bool LoadFromDataSet(DataSet ds)
{
bool bSuccess = false;
if (ds != null)
{
if (ds.ExtendedProperties.Count > 0)
{
foreach (DataTable table in ds.Tables)
{
foreach (DataRow row in table.Rows)
{
CEmployee employee = new CEmployee();
employee.LoadFromDataRow(row);
this.Add(employee);
}
}
}
bSuccess = true;
}
return bSuccess;
}
Is there some super-secret reason that this would happen?
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
I've used almost exactly the same code in previous projects and never had that problem, however I will look into when I get the time, if only to prove you wrong
|
|
|
|
|
Prove me wrong? I'm just describing what I'm seeing and I want to know why it's happening. I agree that it *shouldn't* be happening.
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
John Simmons / outlaw programmer wrote: I'm just describing what I'm seeing and I want to know why it's happening
Forgive me, I was just saying that I've used almost identical code (albeit strongly typed) and have never seen the problem you experienced.
|
|
|
|
|
I know it is kind of over-kill, but if I am not sure what the state of the dataset will be I might write some code like this: (Note I am assuming that only one table will be returned in this situation)
if (ds != null && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
{}
Anyway, I guess it is just another way to skin a cat.
Ben
|
|
|
|
|
I've knocked up a quick test with a dataset containing 2 table with one column: AColumn.
It doesn't appear to have the problem you observer.
Is there perhaps a recursion problem within your employee code?
Just a thought.
I also have used similar code elsewhere with no problems.
private void button1_Click(object sender, EventArgs e)
{
textBox1.Text += "1: Running with no entries\r\n";
DataSet1 ds = new DataSet1();
LoadFromDataSet(ds);
textBox1.Text += "Finished 1\r\n";
textBox1.Text += "2: Running with entries\r\n";
DataSet1.DataTable1DataTable dtbl =
new DataSet1.DataTable1DataTable();
ds.DataTable1.AddDataTable1Row("A record 1");
ds.DataTable1.AddDataTable1Row("A record 2");
LoadFromDataSet(ds);
textBox1.Text += "Finished 2\r\n";
}
public bool LoadFromDataSet(DataSet ds)
{
bool bSuccess = false;
if (ds != null)
{
foreach (DataTable table in ds.Tables)
{
foreach (DataRow row in table.Rows)
{
textBox1.Text += "In Rows: data: " +
((DataSet1.DataTable1Row)row).AColumn + "\r\n";
}
}
bSuccess = true;
}
return bSuccess;
}
The above code works fine.
Regards
ChrisB.
|
|
|
|
|
No recursion at all. It goes into that function and starts an endless loop in the innermost foreach. According to everything I know about foreach loops, it certainly shouldn't do what I'm seeing it do. If I change it to a plain for loop, it works fine.
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|