|
Paulraj G wrote: the above code is not working.
That is not a very helpful piece of information; exactly what is not working; does the program crash, do you see the wrong results, etc.?
You have defined a DLL function as
extern "C" __declspec(dllexport) char* __stdcall ISim::BaseClassFunction()
and I suspect the ISim:: prefix may be affecting your exported name; you can check with Dependency Walker[^]. Also I am not sure whether a char* returned from C++ will be accepted as a String in C#, you should check the PInvoke rules for marshalling, and also this article[^], and this one[^], by Luc Pattyn[^].
Unrequited desire is character building. OriginalGriff
I'm sitting here giving you a standing ovation - Len Goodman
|
|
|
|
|
Hi - Think it's easier just look at the following code fragment than me attempting to explain this. But basically, Regex.Split isn't splitting the source string way I've expected.
Following example try to split the string at "Timestamp" locations - example "hh:mmPM EST"
<br />
static void TestRegularExpressionSplit()<br />
{<br />
string Src = "467.00 9:32PM EST 467.32 9:33PM EST 468.18 9:34PM EST ";<br />
string SplitExpr = @"([0-9]{1,2}[:]{1}[0-9]{1,2}(PM\sEST){1})";<br />
Regex Expr = new Regex(SplitExpr);<br />
string[] Tokens = Expr.Split(Src);<br />
return;<br />
}<br />
Expected:
467.00
9:32PM EST
467.32
9:33PM EST
468.18
9:34PM EST
Actual:
467.00
9:32PM EST
PM EST
467.32
9:33PM EST
PM EST
468.18
9:34PM EST
PM EST
REF: http://msdn.microsoft.com/en-us/library/ze12yx1d.aspx
dev
|
|
|
|
|
Your MSDN reference says: If capturing parentheses are used in a Regex.Split expression, any captured text is included in the resulting string array.
So, strip those extra capturing parentheses from your regex - you don't need them. You can also simplify it a bit, to something like
string SplitExpr = @"([0-9]{1,2}:[0-9]{1,2}PM\sEST)"; Note I haven't checked this, but it should get you headed in the right direction. You may need to play with the odd \s somewhere to get exactly what you want.
Cheers,
Peter
Software rusts. Simon Stephenson, ca 1994.
|
|
|
|
|
The bracket is causing the issue. This fixed it:
<br />
([0-9]{1,2}[:]{1}[0-9]{1,2}[A|P]{1}M\sEST{1})<br />
dev
|
|
|
|
|
Also, there is a Regex forum (which doesn't get enough traffic).
|
|
|
|
|
I'm not proposing this as a "solution," but more to illustrate a corollary question that this thread brings up, for me.
private string Src = "467.00 9:32PM EST 467.32 9:33PM EST 468.18 9:34PM EST ";
string[] splitOnAry = new string[] { "EST" };
var ListOfValuesAndTimes = Src.Trim().Split(splitOnAry, StringSplitOptions.RemoveEmptyEntries).Select(s => s + "EST").ToList(); Which do you think would be easier to maintain, and, for new programmers (perhaps not deeply versed in RegEx), to understand ? The above code or RegEx ? And, yes, I am ignoring the question of which would be more "performant" under "high load" (given you can compile RegEx in C#).
I admit that doing a Linq iteration just to add "EST" back into the results is ugly, and there is an assumption here, on my part, that CS graduates these days are not coming out of whatever schools with the kind of mastery of RegEx you could expect even ten years ago (a very questionable assumption). And, I'd be curious about to what extent "self-made" programmers ... not coming out of academic CS ... are also as well-versed in RegEx as in days of yore.
Just curious.
thanks, Bill
"Anyone who shows me my 'blind spots' gives me the gift of sight." ... a thought from the shallows of the deeply shallow mind of ... Bill
|
|
|
|
|
Thanks Bill. - I already solved it please see prev post
I posted the reg expr which resolves this issue, seems like RegEx.Split has special handling for "(" and ")" so need be very carefully with that (i.e. with RegEx.Match you wont have the same problem, only with "Split")
Reg expression is such powerfull language (but ... quite hard to master and you can't really expose this via UI to end user as a result of language/expression complexity...)
dev
|
|
|
|
|
devvvy wrote: you can't really expose this via UI to end user Hi,
I just want to make sure you understand that what I am asking in my response to you refers to other developers as being "end-users." And I am speaking to the issue of code maintenance in the context of projects involving complexity and teamwork (not speaking about virtuoso code written by geniuses who will support it to their graves, and perhaps beyond).
I have personally seen cases where complex RegEx's were not fully documented, and then the person who wrote them moved on, or was a temporary consultant, or whatever, and, later, bugs developed requiring modification of the RegEx, and the effort it took on the part of the then available developers to grok the original, and make effective change was a true waste of time.
Perhaps in the ideal world, to get a beginning degree in CS, you'd have to pass a core competency test in RegEx ? I think not. And new tools, like Linq, offer alternatives that are much easier to document, and, imho, maintain. And the times now with amazing desktop CPU horsepower, and relatively vast amounts of memory, allow, I think, for a choice, at times, of high-clarity, highly maintainable, over possibly obscure, but higher-performant, code.
Which is not to say that someone could not document a complex RegEx so well that it would be easy to maintain: I've just, personally, never seen that in the "real-world."
Now if my hypothesis ... that RegEx skills are diminishing among programmers in general over the last ten, twenty, years ... is off-base: well, then 'fugedda about it'
But, I have no bias against RegEx per se, and admire its almost cryptic syntax which is so powerful, just as I once admired certain LISP small functions that, via multiple recursion, did amazing things (the problem being that in order to understand how they did what they did required you to have mental abilities equal to their, often brilliant, creators).
best, Bill
"Anyone who shows me my 'blind spots' gives me the gift of sight." ... a thought from the shallows of the deeply shallow mind of ... Bill
|
|
|
|
|
Hi,
I have a datagridview with 3 columns. In column1 I have a datagridviewcombobox which consists of country. In column2 we have datagridviewcombobox which consists of states. In column I have a datagridviewlinkbutton column when I click on the this link column it will add a new row to the datagrid. This datagridview is on placed on a tabpage of a tab control with the name tab2. When I move to tab1 and come back to tab2 then the datagridviewlinkbutton column is added again i.e., the total number of columns is now 4. But i dont want this to happen i.e., it should only have 3 columns even if i move from tab1 to tab2.
Thanks,
Ajay Chauhan
|
|
|
|
|
I have a product for which I build an MSI with VS setup solution.
Every time I want to deploy my changes the the customer I have to remote desktop to 4 machines, upload my new installer, uninstall the previous version and install the new version (run the MSI).
It's a bit tedious (particularly on 4 machines).
Is there a way I could automate the process (remote login / upload / uninstall / install) ins ome way (with PowerShell for example)?
A train station is where the train stops. A bus station is where the bus stops. On my desk, I have a work station....
_________________________________________________________
My programs never have bugs, they just develop random features.
|
|
|
|
|
You don't have to remote desktop into the machines at all. You do, have to copy the installers out to the machines, then you can either run the install command lines in quiet mode with PSEXEC or open up a CMD prompt with PSEXEC and run the same command line. The usual command line for a quiet unattended install starts with
msiexec /i myinstaller.msi /q
Since you can't see any MSI user interface, you'd have to monitor the msiexec processes using the TaskList command line tool. Something like:
tasklist /FI "imagename eq msiexec.exe"
You'll usually have 3 instances running while an install is in progress. When it's done, it'll drop down to 1 instance.
|
|
|
|
|
Thanks David, all very good tip!
I'm going to look at it!
A train station is where the train stops. A bus station is where the bus stops. On my desk, I have a work station....
_________________________________________________________
My programs never have bugs, they just develop random features.
|
|
|
|
|
i have 2 datatables (each have 158740 rows or even more)
How can i get these three things :
1) items in both datatbales on ColumnA-----> in arrayList
2) items in A not B on ColumnA
3) items in B not A on ColumnA
I mean get diffrence on ColumnA
|
|
|
|
|
select distinct ColumnA from Table1 union select ColumnA from Table2
select Table1.ColumnA from Table1 where Table1.ColumnA not in (select ColumnA from Table2)
select Table2.ColumnA from Table2 where Table2.ColumnA not in (select ColumnA from Table1)
Or something like that. SQL is getting rusty due to abhorrent Oracle exposure.
Use SqlConnection, SqlCommand, SqlDataReader to get that into .NET.
Regards,
Rob Philpott.
|
|
|
|
|
Records in Table A not in Table B
Select A.ColumnA from
A left join B
on A.ColumnA=B.ColumnA
where B.ColumnA is null
Records in Table B not in Table A
Select B.ColumnA from
B left join A
on B.ColumnA=A.ColumnA
where A.ColumnA is null
Records in both table A and B
Select A.ColumnA from
A join B
on A.ColumnA=B.ColumnA
modified 28-Nov-11 14:40pm.
|
|
|
|
|
If you mean that you have two System.Data.DataTables, then may I humbly suggest a MasterFileUpdater[^]?
|
|
|
|
|
yes it is System.Data.DataTables.
Please help!
the link i didnt get any thing usefull
|
|
|
|
|
Well, that's all I've got. You'll have to fill in the details.
|
|
|
|
|
We have a website we are showing a embedded media player. With out Media player being installed this media player object will not be shown in the website page.
For enabling media player in Windows server 2008 Destop experience feature should be installed. But When we enable this feature we are getting trouble with Windows media encoder component.
1) Is there any way to enable Windows media player without enabling the Desktop Experience feature?
2) Is there any known issues with Encoder when Desktop experience is enabled. Please suggest.
Thanks in Advance.
Chandu
|
|
|
|
|
Hi everyone, I am using Graphics.DrawString function to draw text on a Panel control modeled as a sheet of paper. The function is called more than once when there is more than one record of text to be drawn.
My problem now is how to find the location where the previous call to DrawString ended so that I can set the location of the next text to the subsequent call to Graphics.DrawString.
Another problem is how to find out whether the initial sheet is full so that the rest of the text
can be drawn on another sheet that will be created after the first one is full. Thanks.
|
|
|
|
|
Graphics.DrawString isn't going to tell you that. However, there is a similar Graphics.MeasureString which, when given a maximum width, will return the rectangular hull of the text Graphics.DrawString would paint. Make sure you give DrawString the same string and font, and a rectangle with the same width and sufficient height.
Mind you, there are some anomalies, MeasureString and DrawString don't always match up to the last pixel. Google may be able to provide more details on this.
|
|
|
|
|
Thanks Luc! I have not done it yet, if MeasureString can return the Rectangle for the text, then I believe it will really help. Just about to continue.
modified 28-Nov-11 7:12am.
|
|
|
|
|
You are going to have to keep a record of how many characters have been entered and in what fonts, then you can use the Graphics.MeasureString [^] method to find whereabouts you are on the panel.
My plan would be to use the width and height of the panel to create a Rectangle , which I would use with the DrawString method (has an overload which takes a rectangle to draw in), and just keep adding the user input to the end of the string, calculating beforehand how many characters the rectangle could hold, so that I could just use the number of characters entered to tell if I need to create a new page.
Hope this makes sense.
When I was a coder, we worked on algorithms. Today, we memorize APIs for countless libraries — those libraries have the algorithms - Eric Allman
|
|
|
|
|
Wayne Gaylard wrote: Hope this makes sense.
Hmm. Counting characters doesn't make sense when using proportional fonts (where iiiiiiiiii and wwwwwwwwww have different width).
|
|
|
|
|
I din't really mean actually counting the characters, just meant to use MeasureString with the font used to calculate the space used. My bad, I guess my English is not up to scratch today
When I was a coder, we worked on algorithms. Today, we memorize APIs for countless libraries — those libraries have the algorithms - Eric Allman
|
|
|
|
|