|
Yes - have a look at this article[^] which shows how to make an owner drawn version of the spin control.
Graham
Librarians rule, Ook!
|
|
|
|
|
Hey guys, im quite new to c++. i am doing a project in which i would have to extract certain information of a database which i have saved in a text file. the database looks something like this :
Database<br />
John32451^23.21 >tyyhg>tdsrte^>1.24<br />
Mark55342^ 335.11 >tsthh
What i am trying to do is search each row based on a specific id and then extract the information next to it. For example, if i were to select John in the menu, the output will be like this.
OUTPUT<br />
John 23.21 1.24
I am not very sure how could i do this and the method to use. Could i get some guidance? To get the correct line will be easy as we just have to search for the name to get the line. But , how about the other two information? I was thinking of using the characters before it which is "32451^" and then reading the info. but how do i get it to stop at the information i want and not continue displaying the information after that which is ";gt;t"
|
|
|
|
|
I suggest you put the data in a real database table. That way you can search the information you want using SQL instead of writing all the code to find the values you want from a text string.
|
|
|
|
|
i cant do that cos the information is coming from a html file. so i have to read it as a text file then use unique id attibutes to make sure i am on the right string , and which line to get the info from.
For example :
<br />
Nasdaq</a></td><td><span class="streaming-datum" id="yfs_l10_^ixic">2,287.99<<td colspan="4"><div style="height: 0px;<br />
the information which i have to retrieve will be "2,287.99". i studied the code and i realize that , the id before it is unique,(id="yfs_l10_^ixic">) , so i can search for it. the problem i am having is how to i tell the prog to save the information which i want and not save the other lines of text?
|
|
|
|
|
You need to write a Scanner.
The simpelest way would be (but this may not suffice):
You open the html file, and read it line by line.
You then search for the string id="yfs_110...>"
Your number follows this string, and the number ends before the deinmiter'<'. So, scan your string until you find the '<' and set it to 0.
Voila, your required Number string, Copy it, and do with it as you please.
Regards,
Bram van Kampen
|
|
|
|
|
Hey thanks for the tip. Is there any example programs or tutorial which u know that can help me with the problem i am having?
|
|
|
|
|
gregarion wrote:
What i am trying to do is search each row based on a specific id and then extract the information next to it
Have a look at regular expressions (RE). There are various libraries for C++, see Boost or CodeProject articles. Alternatively, you could pre-process the data with a Python or Perl script, they are ideal for this kind of work and have regular expressions built-in. You could scan line by line trough your HTML-input and with a regular expression test/extract the wanted information.
Hope this helps,
M
|
|
|
|
|
Yep, you read correcly, my app is spontaneously forking itself - in windows!
I've written a command-line native C++ app with VS2008 to measure temperature data using a Dallas Semiconductors 1-wire hardware and storing the data in a MySQL server. No MFC or .NET stuff. For this I use the Dallas Semiconductors TMEX SDK (link below) and the MySQL C++ connector.
My app is strictly command-line, is run with scheduler once every minute, and exits normally after a second or so. Most of the time, 98% of runs, everything is fine - no error messages, data stored correcly and all that. But sometimes, about once every hour (though not consistently) the app splits in two (or is possibly run twice). I have included some simple logging of key events in the app, storing them in a textfile along with the process IDs, which are indeed different. It LOOKS like the app is simply started twice, almost simultaneously, each process doing it's work correcly and then exiting. The temperature hardware cannot be shared, so one of the processes pauses to let the other one finish, and then carries on itself. Still no error messages, and nothing in windows logs. The temperature data is simply measured and stored twice. I use the simpliest of C++ language, no threading, no registering of windows classes, nothing. I DO use LoadLibrary to import a DLL for hardware access, and GetCurrentProcessID for logging, but no other WINAPI functions I can think of. Other than the ones used by the MySQL C++ Connector, of course.
What about the scheduler then? Well, I've tried both windows scheduler and an old one I made myself back in the days when the built in windows scheduler couldn't do work once every minute. Same result, except that my own scheduler seems to give the error slightly more often, and more erradic. I've tried to run the app using "CMD.EXE /C [myapp.exe] [my_args]" or "myapp.exe [my_args]" directly with the same result.
The behaviour is identical on two servers, a Windows 2008 R2 x64 on dual-core CPU, and a Windows 2003 original x86 on single core x64 CPU. The former runs a 64 bit version of the app (with a 64-bit DLL), and the latter of course a 32-bit version.
Has anyone dealt with anything similar? Where do I need to look? Anyone seriously interested in helping out please mail me for source code.
Best regards
Måns
TMEX SDK: http://files.dalsemi.com/auto_id/softdev/owdocs_400beta2/Docs/1-Wire_SDK_Help.html
|
|
|
|
|
I think no fork happens. Why don't you make your application permanently running, doing measurement once a minute (this way dropping off the coupling with any scheduler)?
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]
|
|
|
|
|
Hi
Well, a continously running app doing the work once every minute is also a valid way of doing it, preferably as a system process. One of the main reasons for doing it command-line with scheduler though was that if there was a hardware error, the app might lock up. With the current way of doing it, even if the app crashes, the sheduler would just restart it the next minute.
But the main question remains - how can the app be duplicated in this strange way? With two separate PID's?
I now added a Mutex, so the second process immediately exits upon detecting the first process, but hey - that's really insane!
/Måns
|
|
|
|
|
I suppose it is a problem related to the scheduler (no forking happens), suppose the scheduler has to defer it's action, then may happen that it has to launch two instances of your application at practically the same time (it is just a guess, however).
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]
|
|
|
|
|
Yes, the scheduler seems a likely cause. The strange thing though, two different schedulers do the same thing. Also, no runs are missed, there are only extra runs. I'll try to implement some simple logging of the scheduler to see what it's up to.
/Måns
|
|
|
|
|
Well,
I've had similar problems with the scheduler in the past, and made up my mind a long time ago to never use it again.
I would definitely use a continuously running Dlg based Win App. (there are ways to run these as if they were a Service) Normally, the Dialog would not show, but is would be available to provide an error message on hardware failure. You could do your measurements by using events, and WaitForSingleObject. If that times out, you know you had a hardware failure, and you can react accordingly.
Hope this is helpfull.
Regards,
Bram van Kampen
|
|
|
|
|
Hi Måns! You could also make it a service, which starts the functionality every minute and logs/reacts on possible problems. Otherwise using a mutex, like you wrote in another post, prevents an application running twice at the same time. The service has the advantage that it could detect error cases like one temperature measure cycle hasn't finished when the next one should start. What's better depends on your requirements and the time you want to spend.
Hope it helps!
/M
|
|
|
|
|
hi every one
What is the equivalent of atoi and itoa functions in Windows SDK platform?
with special thanks
|
|
|
|
|
The SDK contains the same functions as described here[^].
MVP 2010 - are they mad?
|
|
|
|
|
I am grateful to help you
I am using these functions, but have not the correct answer.
I've created a library in visual c++ and for use it in Delphi, convert it to OMF format.
But when I add lib to Delphi ,get an error message where the atoi function is called.
Please help me
Thanks and respect
|
|
|
|
|
Please help us to help you.
What on earth does "get an error message where atoi function is called" actually mean?
Does the program crash, provide an unexpected conversion result, display an error message (if so, WHAT?), etc, etc.
My initial thought is that you could have unicode issues.
Perhaps this page will help: Using Functions That Have No Unicode Equivalents[^]
|
|
|
|
|
I am grateful to help you.
I test this method, but It is not my problem.
When using library, this error message is displayed:
Build
[Error] Unit1.pas(130): Unsatisfied forward or external declaration: 'atoi'
[Error] Unit1.pas(130): Unsatisfied forward or external declaration: 'itoa'
[Fatal Error] Project1.dpr(5): Could not compile used unit 'Unit1.pas'
but when calling the "atoi" function be deleted from the lib error does not occur.
This problem when using "strcpy" function also occurred. But replacing it with the "lstrcpy" function This problem was solved
I'm hoping to find a function equivalent to the "atoi" function to this problem be solved.
Thanks!
modified on Monday, January 18, 2010 6:29 AM
|
|
|
|
|
itoa and atoi are functions in the C runtime library. What your question should really be is: what are the equivalents of itoa and atoi in the Delphi runtime library... Here's a hint - look at StrToInt and IntToStr ...
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
MVP for 2010 - who'd'a thunk it!
|
|
|
|
|
|
Hello all,
In my project I have created one class in which I am storing some data. Now I want to send the data stored in that class to other computer on serial port using our normal Win32 APIs like "CreateFile","WriteFile" and "ReadFile". Means in short I will create an object of that class and I will write that object on serial port and send it to other computer. On other computer also, I will open communication port and I will read that class object, which I will store locally and then I can get the data stored in that class. I am trying to do it but not getting success.
So first of all I want to ask, is it possible to do? Is there any other method to do what I want to achieve? How can I send data stored in a class to other computer using serial port communication? How can I write a class object on serial port of one computer and also how can I read that class object from serial port of other computer?
Does anyone know the solution? plz plz help me out, it is really very very urgent.
Thanks and Regards,
Anay
|
|
|
|
|
AnayKulkarni wrote: I am trying to do it but not getting success.
Perhaps you could explain what you mean by this. How are you sending the data, and what happens at each end of the communications channel when you do?
MVP 2010 - are they mad?
|
|
|
|
|
Usually, the best way to do that is to have your object support some kind of serialization: you can add a function to load a function to save your object into a "file" (here, through the handle of the serial port, but this is the same). These methods read and write all data members of your object that needs to be sent to the other side.
|
|
|
|
|
You should serialize (see Serialization) your objects, send serialized data over the serial line and then deserialize them on the other side (in order to re-create the original objects).
MFC supports serialization for CObject -derived classes. Another option maybe Boost Serialization , you may even write your own serialization mechanism (the task is simple just for basic data structures, though).
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]
|
|
|
|
|