|
thanks
I know many thing about statement and stack and some thing about priorities
and about prefix and postfix ..etc
just I need some helps like idea and some codes
|
|
|
|
|
the exile wrote: [...]and some codes
Boy are you in the wrong place for that.
|
|
|
|
|
the exile wrote: how can i do that??
Do you know we've a wonderful article repository? [^].
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
...but....but....but....those articles do not do this statement A+B(f*g-r)/A+B
Yusuf
Oh didn't you notice, analogous to square roots, they recently introduced rectangular, circular, and diamond roots to determine the size of the corresponding shapes when given the area. Luc Pattyn[^]
|
|
|
|
|
The articles were just to fool him, why parsing when you may use javascript?
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
Why parse at all? Just hard-code the expressions
|
|
|
|
|
I'm not much of a programmer, but I'd start by modelling the data items as structs - one element for the real, the other for the imaginary part - then overload the operators to define complex functions.
For instance,
struct Complex
{
public double Re, Im;
public Complex(double Re, double Im)
{
this.Re = Re;
this.Im = Im;
}
public Complex(Complex X)
{
Re = B.Re;
Im = B.Im;
}
public static Complex operator + (Complex A, Complex B)
{
Complex result = new Complex(A);
result.Re += B.Re;
result.Im += B.Im;
}
}
This defines a struct with two parts called Complex, with real and imaginary parts called Re and Im, respectively. Re and Im are declared as type double. Two constructors are declared, one being initialized with separate values, the other by a type Complex value. The last bit overloads the '+' operator to return a Complex sum of two Complex variables. You can add other operators to the mix by writing the code to implement them. Although structs do not have methods, operator overloads (which look just like methods) work on structs as well as classes. In your calculator application I'd define buttons to click for each overloaded operator, something like what Microsoft has done with the built in Windows Calculator utility.
By the way, I didn't write or test the above - I modified an example in a book I'm studying to fit your situation. You might want to pick up a copy and read it; "Professional C# 2005 with .Net 3.0" by Wrox Press. It's quite thorough and very readable.
"A Journey of a Thousand Rest Stops Begins with a Single Movement"
|
|
|
|
|
Here's how I would do this:
1. Make a binary tree. Leaf nodes stand for your variables (A, B, f, g...). Interior nodes stand for an operation on the values of the interior node's two sons.
2. Go through your statement and put all tokens into a list of leaf nodes. (The operations will eventually be transferred to interior nodes.)
3. Find the range of nodes where the parentheses are most deeply nested.
4. If you have the pattern [left parenthesis] [variable] [right parenthesis], delete the two parentheses nodes. (The variable could also be an interior node.)
5. In this deeply-nested region, replace the pattern [variable] [high-precedence-operation] [variable] with an interior node for the operation, with the two variables as sons. (The variables could also be other interior nodes.)
6. Repeat Step 5 for the low-precedence operations. You should now be able to apply Step 4 on the remaining interior node left in the parentheses.
7. To evaluate the expression, do a post-order traversal on the binary tree, getting the variable values for leaf nodes, and applying the operation to the two values for interior nodes. The result of the evaluation will be left in your root node.
I find this approach simpler than the recursive algorithms.
modified on Friday, March 27, 2009 10:10 AM
|
|
|
|
|
How do you use a poplated <list> array to feed into a listbox.
I tried using the datasource property, but it doesn't return what I would've expected. Of course I could manualy do this with lots of code. But is there a quick method.
I tried using the 'items' property, but it says its readonly and blows up.
this.lbNames.DataSource = cn.Patient.Names; // I get the appropriate number of records but... not the actual records I get like the name of what kind it is...lol
-Robert
|
|
|
|
|
Please show some code. What is cn.Patient.Names ?
All you need to do is:
ListBox.DataSource = yourList;
जय हिंद
|
|
|
|
|
cn.Patient.Names is a <list>
and I explained that it did not work, but rather it returned like a the full namespace twice. Indicating that there were 2 records.
private void Patient_Load(object sender, EventArgs e)
{
this.lbNames.DataSource = cn.Patient.Names;
}
there is obviously a lot of code to copy... and some of it I would not want to reveal, but here is the last where Names is declared... Also there are two records by the time it gets to the above place.
Names = new List<theName>();
|
|
|
|
|
What is theName? Object of some other class?
जय हिंद
|
|
|
|
|
I'm not sure I see how this applies to this question.
public class theName
{
public string use;
public string prefix;
public string pqualifier;
public string FirstName;
public string fqualifier;
public string Middle;
public string mqualifier;
public string LastName;
public string lqualifier;
public string Suffix;
public string squalifier;
}
It could be 'dog'. The point is I have a array list of them.
|
|
|
|
|
Use properties not fields... bad code..!!!! And the question does apply.
|
|
|
|
|
Oh...so you want that when you set datasource, all these properties should be displayed in columns. This way:
use prefix.....and so on
जय हिंद
|
|
|
|
|
Set the DataTextFiled property of lbNames to the name of the property you want to display.
Example:
public class Customer
{
public string Name
{
...
}
public long Id
{
...
}
}
Customer[] customers;
this.lbNames.DataSource = customers;
this.lbNames.DataTextField = "Name";
this.lbNames.DataValueField = "Id";
|
|
|
|
|
lol... those properties don't exist. So we are not speaking the same language.
I'm using Visual Studio 2005 2.0 Framework C#
I'm speaking of DataTextField, DataValueField on a ListBox.
However I tried DisplayMember, and ValueMember
But that didn't work either. I still get the namespace showing up in two records, instead of columned names.
Remember guys I'm not using a dataset... I'm using a <list> array.
|
|
|
|
|
The DataSource accepts more than just a DataSet or DataTable. The DataSource property accepts anything that implements IListSource, IEnumerable....
Below is what I tried and it worked for me. Try again.
public class Customer
{
public Customer(string name, int id)
{
this.name = name;
this.id = id;
}
private string name;
public string Name
{
get { return name; }
set { name = value; }
}
private int id;
public int Id
{
get { return id; }
set { id = value; }
}
}
protected void Page_Load(object sender, EventArgs e)
{
List<Customer> customer = new List<Customer>();
customer.Add(new Customer("John", 1));
customer.Add(new Customer("Mike", 2));
customer.Add(new Customer("Freddy", 3));
this.ListBox1.DataSource = customer;
this.ListBox1.DataTextField = "Name";
this.ListBox1.DataValueField = "Id";
this.DataBind();
}
|
|
|
|
|
for one this I want a multi-column listbox... with
the fields to show up in columns...
This is capability only in later versions of .NET probably not what you are using. Thanx for your help though...
That's just not going to populate columns.
|
|
|
|
|
Are you doing a WinForms App?
If so, then you are either using a third-party listbox control that has columns, and in that event you should ask on their website, or you are using a ListView and should have said so.
Is it a web App?
If so, search for 'Display Multiple Columns in a List Box Sample' and follow the links available from there.
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
|
|
|
|
|
Hi,
Does anyone know of a way to embed a progress bar into a node of a treeview?
Thanks.
-Jamie
|
|
|
|
|
I don't think you can do this directly. Although, you can add a ProgressBar to a TreeView using treeView1.Controls.Add(new ProgressBar()) or by drag drop in design view. Then, you will have to manage to position over a node.
Real dirty way IMO.
जय हिंद
|
|
|
|
|
Hello
i'm using Visual Studio C# 2008 Express
i'm working on a large school assignment along with other two people; there's a computer for each one of us obviously.
we installed the same VS version and we have been working nicely until yesterday, when a weird error ocurred only at two of us.
it happened when we updated our files with everyone's information and tried to test it. this is the code which shows the error...
private void UnlockBitmap()
{
_bitmap.UnlockBits(_bitmapData);
_bitmapData = null;
pBase = null;
}
and this is what it says
No se controló System.ArgumentException
Message="Parameter is not valid."
Source="System.Drawing"
StackTrace:
at System.Drawing.Bitmap.UnlockBits(BitmapData bitmapdata)
at Vision.SeLUT.UnlockBitmap()
at Vision.SeLUT.Finalize()
InnerException:
where Vision is out proyect and SeLut is a class we made to handle bitmaps
this message always appear while testing the application, but just to two of us:
sometimes the execution crashes, sometimes it doesn't, but the actual last-one-to-modify-the-files does not has this problem
since we all now have the very same files...
does anyone has any idea of what is happening and how to solve it?
thanks in advance
|
|
|
|
|
Hi,
I suggest you don't share binary files such as .obj and .exe and .dll while developing; just share source files, and built on every machine. Also use a debug build, so an Exception shows line numbers, and tell Visual Studio to show line numbers in all its editor windows. Finally try a "rebuild all" since you most likely have an inconsistent set of files on at least one machine.
Obviously, when things settle down, you can switch to release build, and distribute .exe/.dll files rather than source files. Or create an installer app.
Luc Pattyn [Forum Guidelines] [My Articles]
- before you ask a question here, search CodeProject, then Google
- the quality and detail of your question reflects on the effectiveness of the help you are likely to get
- use the code block button (PRE tags) to preserve formatting when showing multi-line code snippets
|
|
|
|
|
Hello guys.
I'm going to send data to USB with C#.
I've already searched Google for it ! But I couldn't find what I want.
Could you guide me ?
Thanks in advance.
|
|
|
|