|
Well, after benchmarking many combinations using multiple .mdb files, this does not affect performance or memory usage in any significant way.
(For anyone who might stumble upon my question and wonder how this ended up)
|
|
|
|
|
Hi all,
I got a txt file filled with HTML code extract from www.finance.yahoo.com
this is the data from finance.yahoo.com
Dow 10,212.73 +27.20 +0.27%
Nasdaq 2,174.00 +2.80 +0.13%
10 Yr Bond(%) 3.6500% -0.0400
Oil 75.25 +0.82 +1.10%
Gold 1,113.60 +10.10 +0.91
the 3 values i wanna extract from each stock is all the values above. all the values need to be read from the HTML text file of finance.yahoo.com.
so, how should i create the method and what parameter should i pass in?
should i create individual method for each stock? example
double getDOW(param1, param2, param3, etc)
or a generic method that can search any stock quote
|
|
|
|
|
Use getline or CStdioFile to read the file line by line.
Then use strtok_s or CString::Tokenize to extract the values from each line.
|
|
|
|
|
You can have one method to read the "raw" data for each data line as long as they follow the same pattern, for example, in your case, it looks like:
<name> <data1> <data2> <data3>
after that, you have to interpret each data like depending on where it comes from, is it from Dow ? is it from "Oil"? and decide if it's a percentage, a absolute value, a "delta" and put those values in the appropriate fields in your application :
if ( <name> == Dow )
{
...
}
else (if <name> == Nasdaq )
{
...
}
...
Technically, there must be dozen different ways to do that, but I try to keep it as simple as possible.
Good luck with that.
This signature was proudly tested on animals.
|
|
|
|
|
benjamin yap wrote: all the values need to be read from the HTML text file of finance.yahoo.com.
Use the IHTMLDocument interface to navigate the HTML.
Did you read this article suggested to you three days ago?
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Man who follows car will be exhausted." - Confucius
|
|
|
|
|
how do i extract 2,190.06 from here?
<span class="streaming-datum" id="yfs_l10_^ixic">2,190.06</span>
The ihtmldocument quite complicated to understand
|
|
|
|
|
benjamin yap wrote: how do i extract 2,190.06 from here?
Look for a SPAN element named yfs_l10_^ixic. Then use one of the innerText , outerText , innerHTML , or outerHTML properties.
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Man who follows car will be exhausted." - Confucius
|
|
|
|
|
do i have to
#include anything to use the innertext, outertext etc etc?
|
|
|
|
|
They are methods of the IHTMLElement interface. You might need to include mshtml.h .
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Man who follows car will be exhausted." - Confucius
|
|
|
|
|
#include <iostream>
#include <fstream>
using namespace std;
int main() {
fstream file("c:\\test.txt",ios::in | ios::out | ios::binary);
if(file.is_open())
{
file<<"Hello";
file.close();
}
else
{
cout<<"Error";
}
return 0;
}
I wonder why this code is giving me the output "Error" unexpectedly...what went wrong in this code. I'm not able to write texts in file..please help
|
|
|
|
|
As you may check, opening the file with ios::in flag set, fails if the file doesn't exist.
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]
|
|
|
|
|
Member 6910300 wrote: I'm not able to write texts in file..please help
Does the file exist?
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Man who follows car will be exhausted." - Confucius
|
|
|
|
|
no the file is expected to be created.
in the following case also it outputs "Error"
fstream file("c:\\test.txt",ios::out | ios::in);
if(file.is_open())
{
file<<"Hello";
file.close();
}
else
{
cout<<"Error";
}
|
|
|
|
|
Then you should use:
ofstream file("c:\\test.txt", ios::binary);
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Man who follows car will be exhausted." - Confucius
|
|
|
|
|
thanks for the answer but i dont want to use ofstream and ifstream class instead i want to use fstream class only. Is it possible? and i also need the file to be created as using ofstream.
|
|
|
|
|
if the file does not exist, you have to use
fstream file("c:\\test.txt", ios::out | ios::binary);
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]
|
|
|
|
|
what's problem with this bit masking
ios::in | ios::out | ios::binary
since we have specified out in the mask, why the file is not being created.
thanks for replying.
|
|
|
|
|
The problem is you can't read from a not exitsting file, I suppose.
Your bit mask works if the file do exist. On the other hand, if the file does not exist you should use the
ios::out | ios::binary
mask.
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]
|
|
|
|
|
maybe your file doesn't exist.check your file. I check your code, is ok.
Calvin
|
|
|
|
|
Hi,
I am using ON_WM_KEYDOWN event for keyboard shortcuts in my application. And below is function to handle this keydown action.
void CRearPanel::OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags)
{
if(nChar == 112)
{
if(((CMainFrame*)AfxGetMainWnd())->GetRearPanel()->m_hWnd != NULL)
((CMainFrame*)AfxGetMainWnd())->GetRearPanel()->ShowWindow(SW_HIDE);
if(((CMainFrame*)AfxGetMainWnd())->GetHWSimulatorDlg()->m_hWnd != NULL)
((CMainFrame*)AfxGetMainWnd())->GetHWSimulatorDlg()->ShowWindow(SW_HIDE);
}
else if(nChar == 113)
{
((CMainFrame*)AfxGetMainWnd())->OnViewHWSimulator();
if(((CMainFrame*)AfxGetMainWnd())->GetRearPanel()->m_hWnd != NULL)
((CMainFrame*)AfxGetMainWnd())->GetRearPanel()->ShowWindow(SW_HIDE);
}
else if(nChar == 114)
{
((CMainFrame*)AfxGetMainWnd())->OnViewRearpanel();
::SetFocus(((CMainFrame*)AfxGetMainWnd())->GetRearPanel()->m_hWnd);
if(((CMainFrame*)AfxGetMainWnd())->GetHWSimulatorDlg()->m_hWnd != NULL)
((CMainFrame*)AfxGetMainWnd())->GetHWSimulatorDlg()->ShowWindow(SW_HIDE);
}
CDialog::OnKeyDown(nChar, nRepCnt, nFlags);
}
Now let me explain my problem,
Here I am having one main document window which is coming up initially. And I have another 2 dialog window which should be open on keydown event. From main document window I am able to get key down event and functionality working properly. In Those 2 dialog I put same events, and there start my problem. First time when it(dialog) comes up its not catching keydown event. If I close that dialog and then open it again then I am able to catch it. I found on net some where to put below code,
BOOL CRearPanel::PreTranslateMessage(MSG* pMsg)
{
if( pMsg->message == WM_KEYDOWN )
{
::TranslateMessage(pMsg);
::DispatchMessage(pMsg);
return (1);
}
return CDialog::PreTranslateMessage(pMsg);
}
But I dint find it helpful. Can any one help me for this issue.
|
|
|
|
|
Do you want the dialogs to execute anything when key down?
or..
Is the parent window the one that has to execute anything on the key down from dialog?
Regards.
--------
M.D.V.
If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about?
Help me to understand what I'm saying, and I'll explain it better to you
Rating helpfull answers is nice, but saying thanks can be even nicer.
|
|
|
|
|
well currently I have set same shortcut action in main window and 2 dialog. I mean for all window action for F1 F2 F3 should be same. I thought of passing action msg to main window back, but for that also those dialog should get event..
Is there any work around?
modified on Tuesday, February 2, 2010 10:33 PM
|
|
|
|
|
Hi i think i got the problem. But I dont know how to solve it. Here the dialog I am talking have internally different dialog attached into their body. So focus is not fixed sometimes its that in main dialog sometimes in child dialog. Is there any way that for 3 keys F1, F2, F3 took event in mainframe or main application class. I dont want to pass this 3 key down event to any further dialog,
|
|
|
|
|
|
You were not bothering, and sorry about the absence (I was pretty busy last days).
Glad that you found a solution
Regards.
--------
M.D.V.
If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about?
Help me to understand what I'm saying, and I'll explain it better to you
Rating helpfull answers is nice, but saying thanks can be even nicer.
|
|
|
|