|
thanks for your reply,
i haven't made much of a start because i dont know the first thing about programing i have seen the ocr information on cp thats how i found it (google searched ocr) the first thing i wanted to know was it possible, which you say it is. i have downloaded a few types of ocr and played with them, so i have taken some screen grabs and turned them in to editable text. i think the hardest part for me is to get the text from the ocr to count and log, and automating the ocr to take a screen grab at the right time ( maybe on a timer every 2 seconds)
-- modified at 16:52 Wednesday 14th November, 2007
|
|
|
|
|
Hey all,
I want to use pseudo random functions in C++, such that they take input parameters, and based on this input give output. i.e. function(param1, param2).
My problem is that what I find on the internet are just simple random number generators based on seeds, which is not what I want. Does anyone know, if there is any class that I could use for above-stated purposes. ?
Thanks
|
|
|
|
|
boost::random[^]
Let's think the unthinkable, let's do the undoable, let's prepare to grapple with the ineffable itself, and see if we may not eff it after all. Douglas Adams, "Dirk Gently's Holistic Detective Agency"
|
|
|
|
|
What exactly are you trying to do here? There isn't any reason to think that two or more seed parameters will be any better than a single well chosen seed.
Since any random number generator basically produces a repeating (but repeating with a HUGE period) sequence that looks random, and since seeding the generator just tells the RNG where to begin iterating through that sequence, passing in multiple values won't get you anything better than passing in a single numerical value.
Without knowing more about what your goal is, I would say to just use one parameter, or combine them into a single seed value, or something like that.
|
|
|
|
|
I see what you mean Nathan. Yes, I could combine the values into one as well. What I need it for example following. I have a pseudorandom function F. And say F(x) = y. So that everytime I call the function with parameter x, it outputs y.
|
|
|
|
|
Then use a manually mathematic formulem as you want. You will always have the same output for the same input. I.E
y = ABS( (((((3 - (x+1)) * (x-1) / 1.5) + ((2 - (x/5) + (x - 2/3))) / ((1 - x/7) + 2 * (x+1)))
And if you want the result to be between 0 and 1, normalize the output or just divide y /= y+1;
Greetings.
--------
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
“The First Rule of Program Optimization: Don't do it. The Second Rule of Program Optimization (for experts only!): Don't do it yet.” - Michael A. Jackson
|
|
|
|
|
Your terminology is confusing, random is a property of a sequence not a function, so pseudo-random generators produce a pseudo-random stream of values, you can initialise this from a seed. It sounds that you are looking for a one-way or trapdoor function, where given x, the value f(x) appears random and difficult to invert to produce x. You could look at the standard hash functions (e.g. MD5), or alternatively something simple like exponentiation modulo some prime e.g.
f(x) = r^x (mod p) where r is a primitive root mod p.
Peter
"Until the invention of the computer, the machine gun was the device that enabled humans to make the most mistakes in the smallest amount of time."
|
|
|
|
|
Hi
I'm facing some problem in standard MFC application. In my application, I'm able to run only 3 instances of my application simultaneously.That is, I'm able to open only three login screens at the same time, but I dont want this limitaton. I'm currently working in Windows XP. However, when I ran my application in Windows NT, only 4 instances can be run at a time.
When I tried to open it fourth time in Windows XP, it is failing at the following line of code.
//winfrm.cpp
BOOL CFrameWnd::Create(LPCTSTR lpszClassName,
LPCTSTR lpszWindowName,
DWORD dwStyle,
const RECT& rect,
CWnd* pParentWnd,
LPCTSTR lpszMenuName,
DWORD dwExStyle,
CCreateContext* pContext)
{
HMENU hMenu = NULL;
if (lpszMenuName != NULL)
{
// load in a menu that will get destroyed when window gets destroyed
HINSTANCE hInst = AfxFindResourceHandle(lpszMenuName, RT_MENU);
if ((hMenu = ::LoadMenu(hInst, lpszMenuName)) == NULL)
{
TRACE(traceAppMsg, 0, "Warning: failed to load menu for CFrameWnd.\n");
PostNcDestroy(); // perhaps delete the C++ object
return FALSE;
}}
m_strTitle = lpszWindowName; // save title for later
if (!CreateEx(dwExStyle, lpszClassName, lpszWindowName, dwStyle,
rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top,
pParentWnd->GetSafeHwnd(), hMenu, (LPVOID)pContext))
{
TRACE(traceAppMsg, 0, "Warning: failed to create CFrameWnd.\n");
if (hMenu != NULL)
DestroyMenu(hMenu);
return FALSE;
}
return TRUE;
}
Also, I have the following thing in my code:
//Inside ::InitInstance
if (pDocTemplate = new CMultiDocTemplate(IDR_mdiflsTYPE,
RUNTIME_CLASS(CmdiflsDoc),
RUNTIME_CLASS(CChildFrame), // custom MDI child frame
RUNTIME_CLASS(CmdiflsView) ) != NULL)
cout<<"Successful"
else
cout<<"Failure"
I am creating such 140 CMULTIDOCTEMPLATE (using new) objects for different menus.
Somebody suggested me why above function is failed might be due to the following reason:-
If you call the constructor(above Doctemplate) so many times, without freeing, then you probably reach a maximum space of Windows handles, if the constructor loads menu and other resources. That’s why next resource-allocation functions fails. Can you confirm that you really create and keep so many objects?
So to check resource allocation/storage limitation problem, I applied logs as shown above and I got 140 "Successful" messages when I ran 4th instance.
One more thing is that when I lessen the number of these doc templates to around 50, I am able to start 6-7 instances of my application.
So could anybody suggest me how to ensure if this much objects are successfully created?
Is there any better way to ensure if it is a resource allocation/ storage limitation problem? If yes. how can I overcome this?
Thanks in advance!
Chirag Kalra
|
|
|
|
|
Sounds to me like classic running out of resources. I've never seen a serious app which needed 50 MultidocTemplates, never mind 150, but there you go, there's always a first for everything. Then on top of that you try and run multiple instances of this. (More than 3 anyways). Sounds more like a test of how much abuse you can give the system before it breaks. BTW how many documents of each of the 150 types did you plan to have open at the same time in the multiple instances, and what would the average size of each document be.
It sounds to me like a case of 'Back to the Drawing Board'
Hope this is Helpful
Bram van Kampen
|
|
|
|
|
First... this is the 3rd or 4th time I see the question, if you are the same user repeating question, you could tae a look to the answers of your previous posts. If not... take a look on them, maybe you find the solution.
Second... Why do you want to make different instances of application? Can't you just make, different pairs Doc-View in just one instance of your application?
Greetings.
--------
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
“The First Rule of Program Optimization: Don't do it. The Second Rule of Program Optimization (for experts only!): Don't do it yet.” - Michael A. Jackson
|
|
|
|
|
Hi Chirag,
Did you found a solution, I am running into the same issue.
Thanks,
Priyank
|
|
|
|
|
Hello,
I have read an excel sheet through IDispatch interface in VC++.
But still I have not understood the fundamentals of IDispatch.
What is this interface ?
Is IDispatch a class ?
Why the same IDispatch pointer can be used for the classes Application,Workbook,Range etc?
Is there any link to understand these concepts?
Prithaa
|
|
|
|
|
prithaa wrote: Is there any link to understand these concepts?
No. And if there were you certainly could not find them by using Google to search for them.
|
|
|
|
|
You're so bad!
¡El diablo está en mis pantalones! ¡Mire, mire!
Real Mentats use only 100% pure, unfooled around with Sapho Juice(tm)!
SELECT * FROM User WHERE Clue > 0
0 rows returned
Save an Orange - Use the VCF!
VCF Blog
|
|
|
|
|
IDispatch and IUnknown are fundamental COM interfaces. Read up on COM, Interfaces, and dual interfaces (IDispatch is used for dual interfaces), as well as the specific IDispatch and IUnknown interface documentation.
Very generally speaking, IDispatch is used for scripting like/interpreted languages (like VB) that will not have the methods statically bound at compile time. Instead, the methods are "bound" (or looked up) at run time and IDispatch provides the interface methods that describe how this is supposed to happen. The actual implementation of IDispatch is up to the application or library author.
¡El diablo está en mis pantalones! ¡Mire, mire!
Real Mentats use only 100% pure, unfooled around with Sapho Juice(tm)!
SELECT * FROM User WHERE Clue > 0
0 rows returned
Save an Orange - Use the VCF!
VCF Blog
|
|
|
|
|
Thanks everybody for your answers.
Prithaa
|
|
|
|
|
For C++ developers to understand COM I highly recommend the book Inside Com - Dale Rogerson[^]
This is one of the best books I ever read, period.
|
|
|
|
|
led mike wrote: This is one of the best books I ever read
I never thought I'd ever hear anyone ever say that about a COM book.;P
Anyone who can chew up COM (in C++) and still laugh... I'm speechless.
|
|
|
|
|
Hey all,
I have implemented a simple TCP server/client class from the following web-site
(http://www.codeproject.com/internet/winsockintro02.asp). Which shows us how
to send raw char* data over the TCP connection.
My problem is that I want to be able to send a whole instance of a class, for example
ClassFoo objectFoo; i.e. I want to be able to send the object:
<br />
objectFoo , instead of just text, i.e. "hello".
Can anyone help me, by hinting how to achieve this ?
Thanks
|
|
|
|
|
You need to do what is frequently referred to as "Marshalling", in other words, you need to convert an instance of your class into a byte stream, and then, when you recv this byte stream from a source, you need to be able to "reconstitute" it. Look up marshalling for ideas on how to do this. COM supports this and performs it automatically (as well as allowing you to customize the process if you're crazy enough). I think .Net supports this as well. There are C++ frameworks that also support this, you can look for them.
¡El diablo está en mis pantalones! ¡Mire, mire!
Real Mentats use only 100% pure, unfooled around with Sapho Juice(tm)!
SELECT * FROM User WHERE Clue > 0
0 rows returned
Save an Orange - Use the VCF!
VCF Blog
|
|
|
|
|
Jim Crafton wrote: You need to do what is frequently referred to as "Marshalling"
Isn't marshalling used in terms of memory where reconstituting objects is referred to as serialization?
|
|
|
|
|
Actually I was going to ask you the same question! I was going to say "serialization" but then I *thought* (always a dangerous idea) that serialization was just a way to store object data, not necessarily create a new object from scratch. Whereas marshalling was actually the ability to send the object across the wire with all the info needed to completely recreate it from scratch on the other side.
Now that I think about it, I suspect I'm getting my "definition" from how COM does things, which may or may not be the way most other OO frameworks/libraries do things.
¡El diablo está en mis pantalones! ¡Mire, mire!
Real Mentats use only 100% pure, unfooled around with Sapho Juice(tm)!
SELECT * FROM User WHERE Clue > 0
0 rows returned
Save an Orange - Use the VCF!
VCF Blog
|
|
|
|
|
Jim Crafton wrote: Now that I think about it, I suspect I'm getting my "definition" from how COM does things, which may or may not be the way most other OO frameworks/libraries do things.
Well I just checked an according to the Wikipedia they are interchangeable. From my experience I learned about marshalling way back in Remote Procedure Calls and Serialization came later in terms of Objects so I made the connection that way. Learn something new everyday.
|
|
|
|
|
bigdenny200 wrote: Can anyone help me, by hinting how to achieve this ?
It's called "Serialization". You might want to use it as a keyword in Google and read some material to gain a basic understanding of it.
|
|
|
|
|
Dear led,
thanks for reply. I found a tutorial, which should have done a serialization, as you suggested.
Below is the code (with my object, instead the one from tutorial):
std::vector<std::string> word_list;
word_list.push_back(_T("HI"));
ofstream ofs("c:\\fifthgrade.ros", ios::binary);
ofs.write((char *)&word_list, sizeof(word_list));
std::vector<std::string> word_list2;
ifstream ifs("c:\\fifthgrade.ros", ios::binary);
ifs.read((char *)&word_list2, sizeof(word_list));
The problem is that this code (the last line) doesnt work. And I think this is
because I am using not simple Class instances, but a vector object.
Do you have any idea, what could be other reason for it not to work ?
thanks
|
|
|
|
|