|
thanks for all the info
I have not really found a need for regex and in the past - i usually resort to manual manipulation for more control. but this time i just thought i should look into 'out the box' functions and start getting used to them.
I find every time i post a theory of how to do something manually i get knocked for being wrong for not using ready made class and functions, so maybe i need to start. but at the end of the day i will do what i think is best for the task at hand. which may involve changing manually handling the file as you suggested. The only issue is my OP example wasnt the complete regex expression, my requirement is more complex, but i can hand code if it comes to that.
Thanks
If only MySelf.Visible was more than just a getter...
A person can produce over 5 times there own body weight in excrement each year... please re-read your questions before posting
|
|
|
|
|
musefan wrote: i get knocked for being wrong for not using ready made class and functions
Yes, there are lots of classes and methods that offer a compact solution for small problems, but in the end they typically aren't the best solution because they may take long to execute, consume much memory, and provide no feedback.
Regex is a powerful tool, but it still is a tool; you have to know it exists and use it when you feel it is the right approach for you. If the regex expression is so complex you can hardly understand it, then IMO you are better of coding something yourself, so you know what it does, how it does it, and you can debug and watch it.
Luc Pattyn [Forum Guidelines] [My Articles]
- before you ask a question here, search CodeProject, then Google
- the quality and detail of your question reflects on the effectiveness of the help you are likely to get
- use the code block button (PRE tags) to preserve formatting when showing multi-line code snippets
modified on Sunday, June 12, 2011 8:44 AM
|
|
|
|
|
If only MySelf.Visible was more than just a getter...
A person can produce over 5 times there own body weight in excrement each year... please re-read your questions before posting
|
|
|
|
|
Try using a binary reader instead of a text reader?
|
|
|
|
|
Hi,
I've created a webservice and made that as a HTTPS one, but for some period of time i want to skip HTTPS certification validation, how can i do this? When i call using https:// it says connection couldn't be established. Is there any way to explicitly tell to skip this validation in C#
Thanks
|
|
|
|
|
Hi,
I have this function in a DLL.
long MatchPage (long hImage, long hTemplateList, long *hMatch, char *szTemplate, long iMinMark, long bRegister, long *iConfidence);
Purpose
Match a filled form image to a Template from a Template List.
Parameters
hImage: Image handle of filled form
hTemplateList:Handle of the Template List.
hMatch:Handle of a Match which can be used later by JIRegionsRecognize. The handle should be free later by JIMatchFree.
szTemplate:Template file name is returned here. File name is returned without path and without file name extension.
iMinMark:Minimal confidence for a match. Legal values are 0-100. Recommended value is 15.
bRegister:If 1, the registered image is returned in hImage if matching achieved.
iConfidence:Confidence of the Match.
Import in this way:
[DllImport("image.dll")]
public static extern long MatchPage(IntPtr hImage, IntPtr hTemplateList, out IntPtr hMatch, [MarshalAs(UnmanagedType.LPStr)] StringBuilder szTemplate, long iMinMark, long bRegister, out IntPtr iConfidence);
...and call in this way:
rc = (int) MatchPage(hImage, hTemplateList, out hMatch, matchingTemplate, 25, 1, out iConfidence);
but the compiler says:"Access Violation" .
Someone can help me please?
TY
|
|
|
|
|
It's not polite to double post your question. Nine posts down...[^]
"we must lose precision to make significant statements about complex systems."
-deKorvin on uncertainty
|
|
|
|
|
You are right, sorry.......
|
|
|
|
|
I've created a program that does all the parsing that I want and need in c#. the parsed information is bassically a bunch of xy coordanates and some other information. What i need to do next is take that information and create an animation for a robot simulator. Now someone mentioned to me flash would be the easiest and have the smoothiest animations, much smoother then c# can offer for sure. I tend to agree. Now Im not sure how I would integrate the two programs, c# parsing, flash animating. Now that same person who suggested flash also suggested i abandon c# and start using a program called autoit as it has a very simple function that allows autoit and flash to communicate. Ive taken a look at autoit and so far just cant seem to get much out it. Very frustrating as I have a working program already and keep looking back at c#.
Now what Im asking is any opinions on my situation? Is there any easy way to pass information from c# to flash or is autoit worth the time learning?
|
|
|
|
|
You may use Windows Presentation Foundation (WPF) instead of Flash, and you can use your C# code in WPF application.
Calin
|
|
|
|
|
where would you put the skill level required to get a WPF app up and running?
|
|
|
|
|
It's not all that bad if you have something like ASP.NET programming in your background where you have some XML that dictates the look-and-feel of your application and some code in a "code-behind" class that controls the app.
You can find information at this site: WindowsClient.net[^].
Of course, if you have access to a Sam's Teach Yourself WPF in 24 Hours kind of book, that might make more sense in bringing you up to speed on the philosophy behind the design of WPF.
"we must lose precision to make significant statements about complex systems."
-deKorvin on uncertainty
|
|
|
|
|
Hi
as u know, in Visual Studio DataSet Designer, each column of table is a DataColumn object and DataColumn object has a property named Caption. when i change this property of columns in dataSet designer and bind my datagridview.DataSource to that DataTable object, it does not display Caption text in DataGridView.Column.HeaderText (it display Name property from DataColumn object), wheras i want to display it's Caption.
my problem is that, is there any way to map DataGridView.Column.HeaderText to DataColumn.Caption property automatically ?
Thanks
|
|
|
|
|
Hello All,
I have a particular problem that I am hoping someone can give me a better way of acheiving something.
I have a web page with some predefined search options. I want to give the user a way to create an adHoc search that could have up to 5 elements for the criteria.
So I thought of associating a numeric or alpha character to each element and then do check for a pattern on the postback. This option is becoming cumbersome and I know there has got to be a better way of doing this.
Any suggestions would be greatly appreciated. For those who don't answer, have a great day.
Fred
|
|
|
|
|
|
I did create 5 fields but what if the user doesn't want to utilize all the fields. For example they might want to use "Create Date" and "User". Another user might want to search by "Status", "User" and "Create Date".
|
|
|
|
|
Then what is the problem. Pass the parameters to your stored procedure if they are provided, null if not, and then use the appropriate where clause to restrict the results. If you aren't using a database, LINQ will do the same thing in its where clause.
|
|
|
|
|
Sorry to have been a bother. I just wasn't thinking for some reason. Thanks!
|
|
|
|
|
This may sound dumb but I will try anyway. I am trying to pass a delegate with variable parameters (params object[] {"1", "2"}) as a parameter to another delegate. What I am trying is below but it won't compile:
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
TestManager tManager = new TestManager();
int iRet = tManager.TestMethod1(tManager.TestMethod5 (new List<string> {"2", "1"} ));
Console.WriteLine("Result: " + iRet.ToString());
Console.ReadLine();
}
}
}
namespace ConsoleApplication1
{
delegate object TestDelegate (params object[] list);
delegate object ContaineOne (TestDelegate test);
class TestManager
{
public int TestMethod1(ContaineOne TestMethod3)
{
TestDelegate td = new TestDelegate();
td = TestMethod3.Method;
int iRet = (1 + td(list));
return iRet;
}
public int TestMethod5(params object[] list)
{
return Convert.ToInt32(list["zero"]);
}
}
}
</string>
Anyway, if you think I am an dumb and this can't be done please let me know.
Thanks,
Steve
|
|
|
|
|
Note: I know the code is incorrect, wrong type of parameters, etc. but you get the main Idea. I hope.
|
|
|
|
|
This is how it is done:
using System;
namespace ConsoleApplication1
{
public class Program
{
public delegate int OuterDelegate(object[] o);
public delegate int InnerDelegate(object[] o);
public int MyMethod(object[] o)
{
int t = 0;
foreach (object io in o)
{
t += (int)io;
}
return t;
}
static void Main(string[] args)
{
Program p = new Program();
InnerDelegate oInnerDelegate = new InnerDelegate(p.MyMethod);
OuterDelegate oOuterDelegate = new OuterDelegate(oInnerDelegate);
int i = oOuterDelegate(new object[] { 1, 2, 3, 4 });
Console.WriteLine(i.ToString());
Console.WriteLine("done");
Console.Read();
}
}
}
Now, the question I still have is how could I change the OuterDelegate to execute some code on what was returned from the InnerDelegate?
Thanks,
Steve
modified on Thursday, February 26, 2009 2:34 PM
|
|
|
|
|
Hi,
Steve Holdorf wrote: Now, the question I still have is how could I change the OuterDelegate to execute some code on what was returned from the InnerDelegate?
You could restructure slightly and write a method that invokes two delegates sequentially. I can't see any way out of passing all the arguments required for the first delegate as arguments to the invoker.
Also the invoker would need code to format or translate the first delegate's output into something the second can accept.
delegate int D1(params int[] list);
delegate void D2(int p);
class DeliDelegate {
internal void Run(){
InvokeBoth(ShowInt, Sum, 1, 2, 3, 4, 5);
InvokeBothAndSome(ShowInt, Sum, 1, 2, 3, 4, 5);
}
void InvokeBoth(D2 outer, D1 inner, params int[] p) {
outer(inner(p));
}
void InvokeBothAndSome(D2 outer, D1 inner, params int[] p) {
int res = inner(p);
res = res * 6;
outer(res);
}
int Sum(params int[] i) {
int result = 0;
foreach (int j in i) {
result += j;
}
return result;
}
void ShowInt(int i) {
Console.WriteLine("Value is {0}", i);
}
}
|
|
|
|
|
Thanks Man! You made my day a lot better.
Steve
|
|
|
|
|
 Finished code:
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
TestManager tManager = new TestManager();
Console.WriteLine("ProcessRequest1");
tManager.Run1();
Console.WriteLine("ProcessRequest2, returned value is: " + tManager.Run2());
Console.ReadLine();
}
}
}
namespace ConsoleApplication1
{
delegate object OuterDelegate (int p);
delegate object InnerDelegate (params string[] list);
class TestManager
{
public int ProcessRequest1(OuterDelegate DoSomethingWithResults, InnerDelegate GetData, params string[] sParams)
{
int iRet = Convert.ToInt32(GetData(sParams));
iRet += 1;
return Convert.ToInt32(DoSomethingWithResults(iRet));
}
public string DoSomethingWithResults(int i)
{
i += 4;
return i.ToString();
}
public string DoNothingWithResults(int i)
{
return i.ToString();
}
public object GetData(params string[] list)
{
int iReturn;
iReturn = (Convert.ToInt32(list.GetValue(0))) + (Convert.ToInt32(list.GetValue(1)));
return iReturn;
}
public int ProcessRequest2(OuterDelegate DoNothingWithResults, InnerDelegate GetData, params string[] sParams)
{
int iRet = Convert.ToInt32(GetData(sParams));
return iRet;
}
internal void Run1()
{
string [] sArray = { "1", "2" };
Console.WriteLine("Not returning anything, results: " + ProcessRequest1(DoSomethingWithResults, GetData, sArray));
}
internal string Run2()
{
string[] sArray = { "4", "5" };
return Convert.ToString(ProcessRequest2(DoNothingWithResults, GetData, sArray));
}
}
}
|
|
|
|
|
Delegates are not used to pass parameters. You are trying to pass parameters to the delegate, ie the result of the method, and the delegate at the same time which would not be correct.
I don't think you are dumb but I think your approach is flawed.
|
|
|
|
|