|
Rob Philpott wrote: Values *do* change
Only if you use FORTRAN...
All those who believe in psycho kinesis, raise my hand.
|
|
|
|
|
int x = 2;
x = 3;
There you are! x change from 2 to 3. And although one could argue that x is a value type and hence has been replaced, that fact is under the covers they'll be a register pointing to a bit of memory with x in it, and when x changes, that pointer won't, the content will. Your stack would get destroyed otherwise.
Regards,
Rob Philpott.
|
|
|
|
|
Yeah but I've used versions of FORTRAN in the past where the following works:
PROGRAM ARRGH
WRITE(*,*) "Seventeen = ", 17
OMG(17)
WRITE(*,*) "Seventeen = ", 17
CONTAINS
SUBROUTINE OMG(INT I)
I = I + 7
RETURN
END SUBROUTINE OMG
END PROGRAM ARRGH
Output:
Seventeen = 17
Seventeen = 24
:bugger to find:
All those who believe in psycho kinesis, raise my hand.
|
|
|
|
|
I'm glad I don't know FORTRAN. Very glad.
Regards,
Rob Philpott.
|
|
|
|
|
Just think VB with compulsary GOTOs.
Second language they taught us at Uni when I started. Straight after COBOL.
They saved "structured" languages like ALGOL for the second year.
Me? I learned Pascal and assembler in my summer industrial training and never looked back.
In practice, they tried hard to update and improve FORTRAN, but the best thing you could do with it was put the poor old girl down. Any language where you could declare a float and use it as a four dimensional array of characters to modify the OS can't be all bad! (And all without pointers or references)
All those who believe in psycho kinesis, raise my hand.
|
|
|
|
|
Variables change, constants do not and values are contants.
x = 1 + 2
1 and 2 are constant - 1 is always 1 and 2 is always 2, x is variable and so can change if different constants are used to calculate it.
It's value, 3, is constant. If we made it
x = 2 + 3
then x has changed, but 3 hasn't... 3 is still 3! x is now mutated to equal a different constant, 5.
Value types (structs) are meant (apparently) to be treated as values and are therefore constant. Variables using our value type can be made to have a different value but not change the actual value.
Dave
BTW, in software, hope and pray is not a viable strategy. (Luc Pattyn) Why are you using VB6? Do you hate yourself? (Christian Graus)
|
|
|
|
|
I've just discussed this with the world's authoritative figure on everything (my Mrs) and she says a Tringle should definately be a struct and immutable so Spin(...) should return a new Triangle .
Discussion closed (well in my house at least as Pride and Prejudice has just come on TV).
Dave
BTW, in software, hope and pray is not a viable strategy. (Luc Pattyn) Why are you using VB6? Do you hate yourself? (Christian Graus)
|
|
|
|
|
Do you not use underscores on member variables? I find it makes life so much easier.
Regards,
Rob Philpott.
|
|
|
|
|
I used to, but I found them unnecessary and an annoyance!
If it starts with a lowercase character then its a field (or parameter), if it's uppercase then it's a property (or method). The use of the this keyword allows me to use the field where there is a parameter of the same name which to me is far more distinctive than _ .
Many people also use m_ to indicate it's a member variable.
It's a matter of personal preference really, or the coding styles used in the company you're coding at/for. I've found the style I use the easiest and most logical, but many would disagree!
Dave
BTW, in software, hope and pray is not a viable strategy. (Luc Pattyn) Why are you using VB6? Do you hate yourself? (Christian Graus)
|
|
|
|
|
Fair dos. That's the 'coding standard' I have to use at work. But for me, looking at a variable and not knowing at a glance whether its local or member frustrates me a bit. As you say, personal preference.
Regards,
Rob Philpott.
|
|
|
|
|
I wonder if Roger is any less baffled now?
|
|
|
|
|
Nope. But the discussion is interesting.
"A Journey of a Thousand Rest Stops Begins with a Single Movement"
|
|
|
|
|
Thanks, Dave. That's much clearer!
I've since done a bit more experimenting, and come up with something very similar, though I've left the implementation as a class rather than a struct. I posted only a portion of the code, and some items need to be modifiable at run time. My thinking is that it makes no sense to build a single purpose triangle for use in a single control if, with a bit more effort, I can make one that I can make dance around the screen and do barrel rolls if a later app needs it. For the moment I need only a triangle that points up, one that points down, and a diamond shape that slides along the line between them to show progress. But who knows what loony ideas I'll have for it later?
The debate about whether to create a new Triangle for each change or modify a single instance was interesting. I'm still thinking about that. My thought was to make it self-contained, with its own OnPaint handler and to include some sort of notification mechanism to make it respond to changes in the containing control. I'm still thinking about that, and doing more research and experimentation, since I don't yet know how to do either.
"A Journey of a Thousand Rest Stops Begins with a Single Movement"
|
|
|
|
|
I've been thinking about this too - a possible solution to the dilemma would be to have a Draw method something like this
public void Draw(PointF offset, float rotationAngle)
{ This would allow a rectangle of the given parameters to be immutable, but allow the drawing to be controlled as you wish - in otherwords, the Triangle representation in memory could be identical for two triangles but the drawing could differ as required. You could even include a drawScale parameter etc. So long as they are part of the drawing process and not an integral part of the Triangle then I don't see a problem.
More food for thought!
Dave
BTW, in software, hope and pray is not a viable strategy. (Luc Pattyn) Why are you using VB6? Do you hate yourself? (Christian Graus)
|
|
|
|
|
I like the way you're thinking!
I do need to spend more time thinking about this; I just thought it would be a good way to get started in using the GDI+ functions to make a few basic shapes. Things grew from there.
"A Journey of a Thousand Rest Stops Begins with a Single Movement"
|
|
|
|
|
Hi,
I am trying to upload an image and resize it. the image being uploaded will be saved in photos and thumbs directory. I have given network service and iusr_machinename write access to both folders. the upload works fine in local machine its just when i try to upload via a remote server i get error "A generic error occurred in GDI+."
below are my codes for upload click event. please help
try
{
String file = "";
String thumb = "";
if (flUpload.PostedFile.ContentLength > 0)
{
file = flUpload.FileName;
thumb = "";
String[] strNew = file.Split('.');
strNew[0] = DateTime.Now.Ticks.ToString();
file = strNew[0] + "." + strNew[1];
thumb = strNew[0] + "_t." + strNew[1];
ImageName = file;
ImagePath = Server.MapPath("~/photos") +"\\"+ ImageName;
Response.Write(ImagePath);
ImageThumbName = thumb;
ImageThumbPath = Server.MapPath("~/thumbs") + "\\" + ImageThumbName;
Response.Write(ImageThumbPath);
using (System.Drawing.Image Img = new Bitmap(flUpload.FileContent))
{
Size ThumbNailSize = NewImageSize(Img.Height, Img.Width, 100);
Size ImageSize = NewImageSize(Img.Height, Img.Width, 500);
using (System.Drawing.Image ImgThnail = new Bitmap(Img, ThumbNailSize.Width, ThumbNailSize.Height))
{
ImgThnail.Save(ImageThumbPath, Img.RawFormat);
ImgThnail.Dispose();
}
using (System.Drawing.Image Img1 = new Bitmap(Img, ImageSize.Width, ImageSize.Height))
{
Img1.Save(ImagePath, Img.RawFormat);
Img1.Dispose();
}
Img.Dispose();
}
}
public Size NewImageSize(int OriginalHeight, int OriginalWidth, double FormatSize)
{
Size NewSize; double tempval;
if (OriginalHeight > FormatSize && OriginalWidth > FormatSize)
{
if (OriginalHeight > OriginalWidth)
tempval = FormatSize / Convert.ToDouble(OriginalHeight);
else
tempval = FormatSize / Convert.ToDouble(OriginalWidth);
NewSize = new Size(Convert.ToInt32(tempval * OriginalWidth), Convert.ToInt32(tempval * OriginalHeight));
}
else
NewSize = new Size(OriginalWidth, OriginalHeight); return NewSize;
}
|
|
|
|
|
Check if you have access rights to save to the shared / network folder.
There are only 10 types of people in this world — those who understand binary, and those who don't. |
|
|
|
|
|
what do you mean. not sure how i do that as the website is hosted remotely and its with the hosting provider.
|
|
|
|
|
|
Happy new year...
I have a list of objects I would like to use to populate a datagridview. I would somehow like to have each row bound to a specific object.
I can see how that object class can be added as a datasource, but I'm not sure how to get the objects from my list added as a row.
Anyone care to help? Also, is this the right direction?
Thanks for your time.
|
|
|
|
|
Message Closed
modified 23-Nov-14 7:14am.
|
|
|
|
|
Before the grid is populated, there are no rows to enumerate in the grid.
If the class is used as a datasource, adding rows 'dgView.Rows.Add()' creates an exception stating 'Rows cannot be programmatically added to the DataGridView's row collection'
I'm using the class as the view bindng source. If this is correct, how do I get the list of obects into the grid?
If there is a different approach that would be better than what I'm attempting, please comment.
Thank you for your time.
modified on Sunday, January 3, 2010 12:04 PM
|
|
|
|
|
You can retrieve the object via DataBoundItem property.
|
|
|
|
|
Hi frnds ... I was trying to connect a database which has an extension of .mdf .... but in the crystal report this extension is not filtered ... I want to know how to connect this .mdf file ... Please help
Thank you
|
|
|
|
|
i need some guidance regarding c# winsock programming, im a beginner in programming and network applications. i understand the client/server idea.
server -> socket() bind() listen() accept() {send() recv()} close()
client -> socket() connect() {send() recv()} close()
--
i also know Socket.Connected Property to test if connected.
--
where i am having difficulty is in both server and client how to implement send() and recv() [events]. i know how to send and receive but to do it while keeping the connection seems to very vague in google links.
most examples on google just creat the connection and may send some data or receive some data and the connection is closed.
the while(true) on server runs in a loop and accepts new connections.
i need to know how to implement send and recv (events) so the connected clients and server can keep on exchanging data using the same connection.
lots of the web examples have the server running in a loop and the client makes a new connection whenever data needs to be sent, it doesn't seem efficient to me.
i have also seen server loop running on its own thread to avoid gui lockups but there also the actual communication seems vague.
so. i would like info on how to handle send and recv in a structured manner.
thanks for reading and a very happy new year to you.
---------------------
my current approach is wrong, it concerns blocking.. i should be using .NET asynchronous socket programming.
thanks.
modified on Saturday, January 2, 2010 1:36 PM
|
|
|
|