I am having trouble getting a regular expression to match a dollar value. The string I'm using is: \b\$35,000\b If I remove the \$ then it matches the 35,000 string, so I am guessing I must be doing something wrong.
tansey4
Posts
-
C# Regular expression -
Drawing Frameworks for C#?I'm working on a research project that closely resembles a UML class diagram creation program. I started out using Java and JHotDraw to create my own figures, tools, etc, but I really would prefer to use C# as I am much more confident in the language and there are a lot of different aspects to this project which would make C# my preferred language. Are there any drawing frameworks for C# which allow the programmer to create their own models and creation tools?
-
DLL crashingHi Steve, I just spent a long while debugging, and it seems that the app is crashing when I call clear() on an stl map which is a member variable of an object which is a member variable of StatsDB. Not sure at all why that it's happening here. The message I get while debugging is: Unhandled exception at 0x1007619d (BotAI.dll) in Simulator.exe: 0xC0000005: Access violation reading location 0xcdcdce06. The actual line it dies is:
void _Erase(_Nodeptr _Rootnode) { // free entire subtree, recursively for (_Nodeptr _Pnode = _Rootnode; !_Isnil(_Pnode); _Rootnode = _Pnode) { // free subtrees, then node _Erase(_Right(_Pnode)); _Pnode = _Left(_Pnode); this->_Alnod.destroy(_Rootnode); // destroy, free erased node this->_Alnod.deallocate(_Rootnode, 1); } } Line 3 of the above pasted segment.
-
DLL crashingI recently wrote a simulator for a card game, and I wanted people to have the ability to extend the default AI by writing their own. I set it up so that people could write a DLL and the simulator would look for it. However, when I run the simulator using the DLL, it crashes at the start of the 2nd hand. The wierd part is that if I copy/paste the code from the DLL to the actual simulator, it runs fine. The problem occurs when I try to access (not dereference) a pointer which is passed to the DLL's function. This is the code I'm using to access the dll:
string dllName = "BotAI.dll"; const char* functionName = "?getBotDecision@@YA?AVAction@@AAVHandHistory@@PAVStatsDB@@_N@Z"; HMODULE module = LoadLibrary(dllName.c_str()); // our function pointer for the function we defined in the dll Action (*theDllFunc)( HandHistory&,StatsDB*,bool) = 0; if (!module) { cout << dllName << " not found or load failed.\n" << endl; Sleep( 10000 ); exit(1); } // retrieve our function from the .dll by name theDllFunc = (Action (*)(HandHistory&,StatsDB*,bool))GetProcAddress(module, functionName); Action result(ACTION_Fold);//fold is the default action if (!theDllFunc) { cout << functionName << " not found inside " << dllName << " or load failed.\n" << endl; Sleep(10000); } else { // load was sucessful // we can now use the function pointer to call the function result = theDllFunc(hand, stats, verbose ); } // important, free the dll if (!FreeLibrary(module)) cout << "error releasing the module loaded from " << dllName << endl; return result;
The strange part as I said is that it runs fine for 1 hand using the DLL for all 10 players, then hand #2 starts and it crashes while accessing a function call to StatsDB. However if I put all the code into the actual simulator and comment out all the above code, it works fine. Note that I'm compiling the DLL with the same compiler as the simulator, and am using the same static library for the DLL as for the simulator. Also, it accesses the DLL fine for the first hand, and only crashes on the 2nd hand. Each player accesses the DLL only once per hand, so I am inclined to think it is something to do with accessing the DLL twice from the same player...or something along those lines. As I've said, it works for the entire simulation if I just copy/paste the code from the dll to the simulator, and I've done a lot of simulator testing, so that's not what's wrong. Any ideas? -
Is C# right for me?Thanks for the advice all, I think I'm going to go ahead and write it in C#. :)
-
Is C# right for me?I want to create a multiplayer boardgame which allows players to either connect to a central server and join a game, or to host their own game and have their computer act as a private server. Security is also a high priorty for me, since I plan on creating a points system which leads to prizes, etc, so I don't want anyone to be able to cheat. So my question is: is C# the right language for this? I've done most of my programming in C++ and Java in the past. Most of my applications have been computational or console apps, so I've never really gotten into GUI design (though I've done some basic swing and a little mfc). Likewise, I've never done anything at all with regards to network programming and setting up client/server applications. I'm new to C# (all I know right now is from the FAQ on this forum), and it seems like what I want to use, but I'm not sure. Would you recommend it over say C++ and/or Java?
-
char to store < 255 or use intoversight-[project-zero] wrote:
chars are mainly used for strings.
Not exactly true. Char's are used for lots of things, including pure data manipulation. It's simply 2 bytes which can be interpreted as an ANSII character. That said, if you're only going to be holding very small numbers like 5 and you're EXTREMELY worried about space/efficiency, you should use BYTE for values which you know will be less than 16. I'm not sure how much time this will all save you to be honest, these types of issues are normally only a passing thought in designing your application because there are so many more design issues that would likely speed up your program much more.
-
char to store < 255 or use intTry it out yourself by using sizeof and passing each of those items. example:
cout << "Size of an integer: " << sizeof(int) << endl;
-
Sending text to chat via EditThanks for the link Vikram, however it seems that there is a bug with that engine (and the user comments seem to confirm) that creates problems with XP. From what I saw in the source of that project, I thought that this would work:
void say( const char* toSay ) { if( !SetForegroundWindow( chatBox ) ){ cout << "COULD NOT SET CHATBOX TO ACTIVE" << endl; } Sleep(500); UINT scan = MapVirtualKey( VK_RETURN, 0 ); Sleep(500); SendMessage( chatBox, WM_SETTEXT, (WPARAM)0, (LPARAM)toSay ); Sleep(2000); keybd_event(VK_RETURN, scan, KEYEVENTF_EXTENDEDKEY | 0, 0 ); Sleep(2000); keybd_event(VK_RETURN, scan, KEYEVENTF_EXTENDEDKEY | KEYEVENTF_KEYUP, 0); }
However, that doesn't seem to work. As in my previously posted function, the chatBox is set with the text and when VK_RETURN is sent it does clear, but it does not show up in the chat, it just gets cleared. I'm not sure why this is. -- modified at 3:43 Saturday 17th December, 2005 -
Sending text to chat via EditI have a 3rd party program which contains a chat area. I am trying to create a function which sends a message to that chat. I have the handle to the parent window and the handle to the Edit window where you type. I am not having any trouble setting the text in the Edit window, my issue is sending the text. All I want to do is be able to send the box a simulated Return key press, but I'm having a lot of issues with it and can't seem to get it to work. I spied the window and when a real Return is pressed, it generates two messages:
P WM_KEYDOWN nVirtKey:VK_RETURN cRepeat:1 ScanCode:1C fExtended: 0 fAltDown: 0 fRepeat: 0 fUp: 0 P WM_KEYUP nVirtKey:VK_RETURN cRepeat:1 ScanCode:1C fExtended: 0 fAltDown: 0 fRepeat:1 fUp:1
For KEYDOWN, the parameters are: wParam: 0000000D lParam: 001C0001 For KEYUP, the parameters are: wParam: 0000000D lParam: C01C0001 Given all this information, my current function looks like:void say( const char* toSay ) { HWND tempa = SetActiveWindow( hwnd ); HWND tempw = SetFocus( chatBox ); Sleep(500); SendMessage( chatBox, WM_SETTEXT, (WPARAM)0, (LPARAM)toSay ); Sleep(1000); PostMessage( chatBox, WM_KEYDOWN, VK_RETURN, 0x001C0001 ); Sleep(2000); PostMessage( chatBox, WM_KEYUP, VK_RETURN, 0xC01C0001 ); Sleep(2000); SetFocus( tempw ); SetActiveWindow( tempa ); }
I have had very little success with this method. It will sometimes send the first message it gets but then will no longer send anything. It seems like this should be much simpler, as I'm sure it's a common need. Any help is greatly appreciated.