|
Hi,
I know I'm really close but not just quite there yet.
I'm reading data from a text file with the following code and as a newbie I am advancing bit by bit and I've come unstuck...again.
What I want to do now is in place of int num = 4991 I want to use Close[0] (which is a double) to compare against tmp (an int) but have absolutely no idea how to go about it.
Here is my code.
private string path = Cbi.Core.UserDataDir.ToString() + "PIn.txt";
private int[] levels;
private int count = 0;
private string readText = "";
<big>int num = 4991;</big>
<big>private int tmp, res = 0;</big>
private int? diff = null;
#endregion
protected override void Initialize()
{
CalculateOnBarClose = true;
Overlay = true;
PriceTypeSupported = false;
levels = new int[1000];
}
protected override void OnBarUpdate()
{
readText = File.ReadAllText("C:\\PIn.txt");
string [] split = readText.Split(new Char [] {';'});
foreach (string s in split)
{
count++;
tmp = int.Parse(s);
levels[count] = tmp;
if (tmp > <big>num</big>)
{
if(diff == null)
diff = <big>num</big>;
if ((tmp - <big>num</big>) < diff)
{
res = tmp;
diff = tmp - <big>num</big>;
}
}
}
Print(res);
}
Really appreciate the help,
suprsnipes
|
|
|
|
|
Hi,
1.
you could round your double to an int once and store it in a variable; a simple cast would suffice.
Alternative (not recommended): you could do everything using doubles.
2.
your code is wrong; test it with 0001 as the first number in the file!
3.
no need for private int? diff = null; as a simple private int diff = int.MaxValue; would work equally well, need less code, and fix the bug (2)
4.
your code has an artificial limitation of 1000 numbers in the file; it will crash for longer files.
Solution 1: use a List<int> instead of an array; a List behaves like an array that grows as needed.
Solution 2: don't store the numbers at all (your code isn't using them at all)
|
|
|
|
|
How would I do the following?
1. you could round your double to an int once and store it in a variable; a simple cast would suffice.
|
|
|
|
|
int roundedValue = (int)myOriginalDoubleValue;
BTW: do yourself a favor, go buy a book on C# and study it. It is the fastest and the best way of learning a new language thoroughly.
|
|
|
|
|
Thanks for your help Luc Pattyn.
I have revised the code from your suggestions which are much appreciated and I will be purchasing a book on C#.
Regards,
suprsnipes
|
|
|
|
|
I want to write a winform program to implement following behaviour
when the program exits,I will write some log infomation in a log file
so I write some code in Form_Closing Function,It works fine when I click X on the window.But when I shutdown the computer before I close the program,It seems Form_Closing Event is not fired,so the log information is not saved into file.I checked many articles on MSDN And Google,It all says,this event will be triggered when shutting down the computer,I also tried to handle the WM_QUERYENDSESSION message,it did not work either.
Can Anyone give some suggestions and help? thanks
|
|
|
|
|
Hi,
AFAIK you should:
- have a "LogClosing" method that logs what needs to be logged;
- have that called by the SystemEvents.SessionEnding handler;
- have it also called by the Form.FormClosing handler;
- implement some protection so it only executes once (as FormClosing may or may not fire on session end)
|
|
|
|
|
hey experts,
i m sending multiple emails from my code in bulk, i just want to check which mail succeeded and which mail fails, i searched a lot but i m not getting any idea, can anybody help me with that. Or may be help in creating a email sending monitor
waiting for positive replyRegards
Narendra Singh
(Jindal Tech Ventures)
|
|
|
|
|
Hi !
In the section, where you set your mail values
(for example:
mail.From = new MailAddress(Mail_From);
mail.Subject = Mail_Subject;
mail.Body = Mail_Body;
you have to add two lines:
mail.DeliveryNotificationOptions = DeliveryNotificationOptions.OnSuccess;
mail.Headers.Add("Disposition-Notification-To", "<my.name@myfirm.de>");
Then normally (and if the recipient click 'yes'), you will receive a mail-answer.
Best regards,
Gerrit
|
|
|
|
|
hey gerrit,
thanks for reply
i want to ask u is it necessary to use headers.add part for notification, or it will work without header part too.
("Disposition-Notification-To", and i have to pass what there)
because with "" it is giving error
waiting for your replyRegards
Narendra Singh
(Jindal Tech Ventures)
modified on Wednesday, March 10, 2010 3:09 AM
|
|
|
|
|
Hi !
In any way, I have trouble with the editor.
I am shure to have written
> mail.Headers.Add("Disposition-Notification-To", "<mail.address@firm.us>");
If it comes out wrong again, the empty quotationmarks must contain
a valid email address in brackets.
Best regards,
Gerrit
|
|
|
|
|
Hi !
I did not work once again !
Another Trial :
mail.Headers.Add("Disposition-Notification-To", "<gerit.rait@neus-ag.de>");
Best Regards,
Gerritmodified on Wednesday, March 10, 2010 7:32 AM
|
|
|
|
|
now its not giving error and key is also added to the header part, but it is not getting any notification Regards
Narendra Singh
(Jindal Tech Ventures)
|
|
|
|
|
my code is
<system.net.mail.smtpclient smtp="new" system.net.mail.smtpclient(smtpserver,="" convert.toint32(portid));
mssg.from="new" mailaddress(emailid);
mssg.subject="txtSubject.Text;
mssg.Body" =="" htmleditorcontrol.bodyhtml;="" ;
mssg.isbodyhtml="true;
mssg.DeliveryNotificationOptions" deliverynotificationoptions.onsuccess;
="" mssg.headers.add("disposition-notification-to",="" "<mymailid.co.uk="">");>
like this
is it rightRegards
Narendra Singh
(Jindal Tech Ventures)
|
|
|
|
|
Hi !
I do not think so.
> mssg.Headers.Add("Disposition-Notification-To", "xxxxxx");
There is the email address missing between the empty quotation mark. (here xxxxxx)
You do NOT get back a notification from the programm. The recipient
of the email is asked, to push a commit button and then a email
is send to the address, you set in your mssg.Headers.Add.
The email-address at the place xxxxxx must set between brackets.
Best regards,
Gerrit
|
|
|
|
|
yes i have added mail address there but it is not showing anything
can we add Disposition-Notification-Options???Regards
Narendra Singh
(Jindal Tech Ventures)
|
|
|
|
|
Hi !
You have already set the options in
> mail.DeliveryNotificationOptions = DeliveryNotificationOptions.OnSuccess;
with the enum .OnSuccess
Once again:
You will not receive a notification or a message in Your programm.
With the two additional programm lines, a messagebox will show up at the
computer of the mail-receiver. If he commits this box, a notification-mail will
be send back to the mail-address you set.
Best regards,
Gerrit
|
|
|
|
|
yes gerrit i know i will not receive a notification or a message in my programm. but it is not showing messagebox at mail receiver, thats what i m trying to say
plz help me with thatRegards
Narendra Singh
(Jindal Tech Ventures)
|
|
|
|
|
it have some issues with different mail servers (like gmail, yahoo, hotmail)???????????? Regards
Narendra Singh
(Jindal Tech Ventures)
|
|
|
|
|
Hi !
I did try it with an Outlook (2003 and 2000) frontend and a MS Exchange server to
send the Mail. As a receiver, I tried Outlock 2003 directly linked to a
Web-provider and the Mail frontend of the Web-provider(1x1) itself and it
worked perfectly.
I suppose Your receiver will not answer for notifications at all (maybe
you have set an option) or Your mail-address for the notification is
in the receivers list for spam-mail.
As I do not know about your mail-receiver, I am afraid that I cannot help
here. Sorry.
Best regards,
Gerrit
|
|
|
|
|
no need to say sorry thanks for all your help Regards
Narendra Singh
(Jindal Tech Ventures)
|
|
|
|
|
If I have 2 or more tables in database ,I want to know how we can establish connection between them and if we have same field common in 2 tables ,how we can update all by updating one table i.e. particular fields that r common.
|
|
|
|
|
i am not understanding your question but whatever i got i am telling you..
for making connection you can use join query on table..
If You Get your answer then please Rating me...
Thanks..
"Are You Ready"
DX-ARMY
|
|
|
|
|
AFAIK, JOIN only works for select queries, not for updates - I could be wrong, but I've never seen an UPDATE with a JOIN in! You should never use standby on an elephant. It always crashes when you lift the ears. - Mark Wallace
C/C++ (I dont see a huge difference between them, and the 'benefits' of C++ are questionable, who needs inheritance when you have copy and paste) - fat_boy
|
|
|
|
|
yes you may be right but we can also match the comman field of the table in query..like
for example
update tablename set ('"+name+"',.....) where table1.id=table2.id and table1.customer_name=table2.customer_name
If You Get your answer then please Rating me...
Thanks..
"Are You Ready"
DX-ARMY
|
|
|
|