DdoubleD 315 Posting Shark

In the last example I gave, I used your DemoReport() object without knowing exactly how you defined it. Post or attach your DemoReport.cs file so I can see how you are defining your ReportDocument object.

DdoubleD 315 Posting Shark

Yes, thanks. I knew where the options where, but figured wrong about the same capabilities between the editors. However, I found the Ctrl-F (suggested by narue) on selected blocks seems to do the trick. I used to use VS < 2003 to code in CPP years ago, but after using VS 2008 and C# editor recently and then going back to CPP, it's really annoying there is not the same editor functionality. Anyway, thanks for the information guys!

DdoubleD 315 Posting Shark

how about a pure virtual destructor.

Also gotW

See: http://www.codeguru.com/cpp/tic/tic0163.shtml

No, I mean what was with the quote to my response?

I thought you had asked how this subject pertained to pure virtual destructors, so I provided that link which explained that aspect. I only now noticed you provided a link in the first quote above--sorry.

I'm pulling an excerpt from the article I prescribed for the benefit of people trying to read this thread:

"For a time, pure virtual destructors were legal and worked if you combined them with a function body, but in the final C++ standard function bodies combined with pure virtual functions were outlawed. This means that a virtual destructor cannot be pure, and must have a function body because (unlike ordinary functions) all destructors in a class hierarchy are always called."

Cheers!

DdoubleD 315 Posting Shark

@Gribouillis, @DdoubleD:
From load into memory can I assume you mean two giant multidimensional arrays? Thinking about it....I wouldn't have to keep reloading the data and only commit when I've worked it out. Thanks!

Wish I knew Python because I'd love to help you out with this. I definitely think that working with the record sets in memory is the way to go though if you can pull it off; then do your final update(s) to DB. Best of luck!

DdoubleD 315 Posting Shark

But to answer your question you can use RegEx:

private void button15_Click(object sender, EventArgs e)
    {
      const string sentence = @"This is Daniweb Forums.Good Luck";
      string[] regex = System.Text.RegularExpressions.Regex.Split(sentence, @"\W");
      System.Diagnostics.Debugger.Break();
    }

You lost me.... I tested it and the "\\W" works fine, but what is it?

DdoubleD 315 Posting Shark

please help me to have a program that will compute for n! (n factorial) which is the product of all numbers from 1 to n.

OK, but this is a secret between you and me: factorial cpp

DdoubleD 315 Posting Shark

You could also consider loading all the schools and children in memory and modify the database only when you know in which school each child goes (this can be done if you're able to compute the distance between a child and a school without the ST_DISTANCE function).
Also, try to use the cProfile module to tell you where time is spent.

In my opinion, the only correct way to do this is to load the records in memory and process them rather than this UPDATE and SELECT through each iteration of your two loops!

DdoubleD 315 Posting Shark

Look, you make a function virtual anticipating it will, or in fact needs to, be overridden. Therefore, the derived class can, or even should or must (1), implement an override of the function to alter characteristics/behavior and can also call the inherited function if need be. I assume that a "pure" virtual function (1) still requires the derived class to implement this functionality.

DdoubleD 315 Posting Shark

Hi,

1) Over riding should come into picture when i am using pointer to object, but here i am using the object directly. Do you think that overriding comes in picture?
2) Sorry, but i don't agree much, since in that case i will have a usual virtual function, not a pure virtual function. Anyways, let's leave this point, since you also happen to know this recently
like me:) Thanks.

Regards,
Vivek

You are not making sense to me:
1) overriding a function has nothing to do with "using a pointer to an object", or "using object directly".
2) OK--we will leave that point out--LOL.

What are you asking now?

DdoubleD 315 Posting Shark

2 cont.) Yes. I have overridden many virtual functions, but until today, I did not know that you could define a body in a "pure" virtual function as defined in CPP. So, I've learned something new today--hoorah!

I am still perplexed by this new identification of the definition of "pure", which was always treated as wholly abstract by myself in the past. This new definition (to me anyway) of a "pure" virtual function sort of depletes reason of the meaning of the word "pure".

Anyway, best of luck!

DdoubleD 315 Posting Shark

Hi DdoubleD,

Thanks.
I agree with your code snippet, but i have below questions:

1) Why does SayHello2() invoke speak() of dog instead of animal.
Although SayHello2() is a member function of animal. Is this due to the object being used of dog? In general, when i call a function from a member function, it calls from its own class, if the function is not available, it checks for base class. But in this case, it's checking for derived class, I am little confused. Can you share more details?
*
2) My original question is more about design, what would be a real time use-case where i need to write pure-virtual function with body?
In general, i make pure-virtual functions for abstract classes, and i want every derived class must override the function. Have you ever defined body for a pure virtual function, where you actually needed it?

Regards,
Vivek

Firstly, that was not my code snippit.

1) because dog speak overrode animal...
2) yes. With respect to item 1, suppose you want to now define a particular dog with a particular barking sound. For each particular dog, you could do something like attach a sound unique to that breed of dog. Otherwise, the default sound for a common dog would be utilized. Does that make sense?
2 cont.) Yes. I have overridden many virtual functions, but until today, I did not know that you could define a body in a …

DdoubleD 315 Posting Shark

whats that supposed to mean?

Are you asking me to explain the article to you?

DdoubleD 315 Posting Shark

I noticed this link posted by adatapost, which seems to use the dashed outline on the drag you are looking to replicate, but cannot be sure because I did not get to see your IMG tag. Anyway, it's a TreeView drag/drop I believe, but the owner drawn stuff is probably the same with some minor tweaks: http://www.codeproject.com/KB/tree/mwcontrols.aspx?msg=904987

Cheers!

serkan sendur commented: chic +7
DdoubleD 315 Posting Shark

Cool--didn't know that. Thanks for the info.

DdoubleD 315 Posting Shark

how about a pure virtual destructor.

See: http://www.codeguru.com/cpp/tic/tic0163.shtml

DdoubleD 315 Posting Shark
DdoubleD 315 Posting Shark

Hello Friends,


Generally, we have pure virtual function without body, but C++ does allow to write pure virtual function with body. Can anyone suggest any use-case where we need to write pure-virtual function with body?

Regards,
Vivek

This is news to me, but it has been a while since I used CPP and maybe it has evolved. My understanding is that any class that implements a "pure" virtual function is an abstract class that forces you to define the function or it also becomes an abstract class. I am not aware that you can define a body for the function in your class and still have a "pure" virtual function.

DdoubleD 315 Posting Shark

:P LOL. That's a lot of PP, so if that was supposed to be a joke you got me.

DdoubleD 315 Posting Shark

I have the following code and it wont compile, it says no matching function for call to `autop::autop(autop)' at this part

autop j = f();

I got no compiler error with that code.

Another Thing:

when used inside the function parameter list (i.e autop(autop & s) , whats the effect of the &, does it creates a ref, or is it passing an address, is it the same( I dont see how) , how should I understand it.

I also wonder why using & to get the address of anything adds a '*' i.e if I have

int * p 
int x;
p = x //wont work AND compiler says: invalid conversion from int to int* 
//same applies to 
int ** pp;
int * p
pp = p;

so question why adding an & makes the '*' match to the compiler
Does taking the address of anything gives me a pointer or what
:confused:

Because Pointers point to References, you need to resolve a variable to its reference when assigning to a pointer. Therefore, to say that int *p = &x is to say "p" points to reference "x". When you try int *p = x , you are attempting to say an address pointer points to an integer value, which is why you get an error because this code is suspect of being in error.

Part 2: Your **pp is a pointer to a pointer, so when you dereference "**pp" as *pp, it must be a …

DdoubleD 315 Posting Shark
if ((count % 2) == 1)

oops! I posted this before realizing it was Java...Sorry in advance if the syntax is wrong.

DdoubleD 315 Posting Shark

Can anyone tell me how to get my blocks of code to automatically indent when I place the final closing brace--"}". This works fine when I am coding in C# and I know there must be a way to enable this feature for CPP source documents.

DdoubleD 315 Posting Shark

You are losing the precision in your division. You need to cast:

div = (float)num1 / (float)num2;

Your printf requires "%%" to represent a literal % symbol:

printf("> %d %% %d = %d.\n", num1, num2, mod);

Can't help you with the search parameter for "C", but I'll be watching to see what others say.

Cheers!

DdoubleD 315 Posting Shark

Also, you could modify your print loops to accomplish the logical pattern. What is the requirement?

DdoubleD 315 Posting Shark

Please use code tags.

In your matrix function, you are assigning -1 to all elements. If you want to assign the pattern of numbers you specified you would like to output, then you need to assign them as such.

Having said that, do you want to put them into your matrix completely hard coded? Probably not, but I don't know. If not, you need to modify your loops to contain logic that will assign your matrix according to the pattern. If so, then it's an easier thing to achieve because you don't need any logic.

Syntax for hard-coded array:

int table[r][c] = {{-1,-1,-1,-1,-1, 0},
					{-1,-1,-1,-1,0,1},
					{-1,-1,-1,0,1,1},
					{-1,-1,0,1,1,1},
					{-1,0,1,1,1,1},
					{0,1,1,1,1,1}};
DdoubleD 315 Posting Shark

No problem. If that answered you questions, please mark as solved.

Cheers!

DdoubleD 315 Posting Shark

If you specify a default contsructor for you Item struct definition, this error will go away:

Item(void) :name(""), iid(0), value(0.0) {}
DdoubleD 315 Posting Shark

If you know your string contains only words separated by spaces you could use:

string Mystr = "This is a sentence.";
string[] split = Mystr.Split(new Char[] {' '});

Now split[1] would contain the word "is".

Ah, yes! then just iterate through the array and count only those have Length > 0 --nice!

DdoubleD 315 Posting Shark

Well, you probably want to remove any leading or trailing spaces so you don't count extra words--see string.Trim() . Then, you could loop through the string looking for " " (space) and count each one you find using string.IndexOf() or IndexOfAny() , but you probably want another loop inside of that to skip extra spaces so you only count one word for mulitple contiguous spaces e.g. " " (two spaces together).

DdoubleD 315 Posting Shark

Did this work?

DemoReport rpt = new DemoReport(); // your embedded document
            ReportDocument crDoc = (ReportDocument)rpt; // upcast
            ReportSourceSetup(crDoc, crConnectionInfo); // table logon info setup

        public void ReportSourceSetup(ReportDocument crDoc, ConnectionInfo crConnectionInfo)
        {
            // Each table in report needs to have logoninfo setup:
            Tables crTables = crDoc.Database.Tables;
            foreach (CrystalDecisions.CrystalReports.Engine.Table crTable in crTables)
            {
                TableLogOnInfo crTableLogonInfo = crTable.LogOnInfo;
                crTableLogonInfo.ConnectionInfo = crConnectionInfo;
                crTable.ApplyLogOnInfo(crTableLogonInfo);
            }
        }
DdoubleD 315 Posting Shark

The .NET compact framework does not natively provide support for bluetooth, so you will need to device specific support I believe. Try google'n "Codeproject bluetooth c#" to see some examples. If supporting a particular PDA, you might include that in your search as well.

DdoubleD 315 Posting Shark

And, if you pass in your listView1 object in the constructor:

ListView.ListViewItemCollection lvic = new ListView.ListViewItemCollection(listView1);

it appears to return a reference to the listView1's item collection.

Again, I recommend looking into ddanbe's suggestion using the SelectedListViewItemsCollection .

DdoubleD 315 Posting Shark

Have you a SelectedListViewItemsCollection class, or is it missing in a compact framework?

I think what ddanbe has led you to is what you want/need. However, I was a little confused when you said there is no constructor and you couldn't create an instance, so I had to check this myself and I found I could do it, though I cannot imagine wanting to:

ListView.ListViewItemCollection lvic = new ListView.ListViewItemCollection(new ListView());

Cheers!

DdoubleD 315 Posting Shark

actually i tried to make the program in the link you showed me to run but i couldn't but i tried to pass parameters to the crystal report and export it to word using export in it's options in the report viewer not using my code it exported the report with the parameters in it so it makes me don't need to append in the word document thanks double d you helped me alot and it's so appreciated

but there is another problem when the crystal report is exported to the word document the it exports the arabic daynamic data in it reversed do you know how to handle that

You are most welcome!

I don't know why you are getting the data reversed. May I suggest you close this thread and start a new one about the reversal of the data?

Cheers!

DdoubleD 315 Posting Shark

Hi Friends
i have a datagird and it has 2 columns and have calculate with the content of them but when i typed them in runtime my result was wrong i followed it by BreakPoint and underestood that the content of last column didn't use in my calculate(although it has some content) what's its reason? why it happened? how i can solve it?

Thank you

You are using long integers to accumulate and calculate your remaining result--was that intended? Seems to me you would want to use the decimal type since this pertains to monetary verbiage (credit/debt).

Not sure how new you are to C#, but I will assume you know that cells[2] is actually column 3 viewable in your grid, etc.

DdoubleD 315 Posting Shark

Let's think that the problem is Open Connection.
what should I do?
I Closed my connection on Form_Load.Is it true?

Is this a multi-user system, or are you the only user? You don't want to shut down any connections that might be needed.

Also, are you logged in as an administrator? Make sure you are.

If you are the only user and you are certain it is ok to shutdown the DB server, shutting it down and restarting it will ensure there are no hanging connections.

If your restore code still doesn't work after the above, try doing it manually WITHOUT the C# and see if it works.

DdoubleD 315 Posting Shark

More elaboration...

if (comparevalue.Days < 3)
                {

                    foreach (string s in files)
                    {
                        fileName = System.IO.Path.GetFileName(s);
                        destFile = System.IO.Path.Combine(targetdir, fileName);
                        System.IO.File.Copy(s, destFile, true);
                        sw.WriteLine("Log " + s + " has been copied..");
                    }
                }

This inner loop is copying all of the files regardless of whether they met your date check as long as only one them does meet the date check because your inner and outer loops are looping through the same list--right?

DdoubleD 315 Posting Shark

Maybe I have read this code wrong, but it looks to me like you are looping and copying all of the files if one of them matches (> 3 days), and that you are doing it each time one of them matches, essentially redundant. Did you mean for both of these to build from the same folder?

// get files from expandedsystemroot
            string[] files = System.IO.Directory.GetFiles(ExpandedSystemRoot, "*.flog");
            DirectoryInfo dirinfo = new DirectoryInfo(ExpandedSystemRoot);
            // get files from expandedsystemroot
            System.IO.FileInfo[] fileinfo = dirinfo.GetFiles("*.flog");
DdoubleD 315 Posting Shark

what do u suggest?what should I do?
plz.It's very important.

You probably need to move this to the Database forum. Check your database error log to see more details of why the process failed. Could be a number of things, including insufficient privileges--like not being adminsitrator. Could be an open connection preventing the task, etc...

DdoubleD 315 Posting Shark

Are you using subreports in the report?

DdoubleD 315 Posting Shark

Although your code is C#, your error might be strictly DB. Have you checked the server's error log for more details?

DdoubleD 315 Posting Shark

Is it possible you have subreports in your report that have missing parameter links?

Try adding the following code statement and see if it shows any unforeseen parameters:

foreach (ParameterFieldDefinition parafld in wordReport.DataDefinition.ParameterFields)
            {
            }// set breakpoint and examine parafld
DdoubleD 315 Posting Shark

Not sure if you noticed a thread in here created 2008/01 that was posted to today. It contained an interesting link about automating word in c# and I wanted to pass it on to you: How to automate Microsoft Word to create a new document by using Visual C#

DdoubleD 315 Posting Shark

Not sure whether this is a good idea, but I believe it will do what you asked:

while (true)
            {
                // get all instances of notepad running...
                System.Diagnostics.Process[] procs = 
                    System.Diagnostics.Process.GetProcessesByName("notepad");

                if (procs.Count() == 0) // process by that name no longer running--we're done
                    break;

                System.Threading.Thread.Sleep(30000); // pause this app for 30 seconds
            }
            MessageBox.Show("Done");
DdoubleD 315 Posting Shark

Thanks for the code!! This works. I have been trying the exact same thing. The only difference was that instead of ReportDocument, i was using an object of the report itself.

...

Can this be done using the report object and not the path so that i dont have to copy the rpt files manually in each machine the application is installed?

Hi, I think you only need to upcast your report object to a ReportDocument. So in the example I gave, you could just substitute the FileInfo with a ReportDocument by using a cast instead of calling ReportDocument.Load method:

crDoc = (ReportDocument) MyReportObject;

Here is a link to MSDN topic on: Binding to an Embedded Report

DdoubleD 315 Posting Shark

Hello ajijcobm, I am bored so I decided to look up this subject (cause I have never personally done it before). Anyway, here are some links I thought might get you started:

XML and Database Mapping in .NET
An XML Database Schema And Data Editor
Create Data Classes

Hope that gets you started.

Cheers!

DdoubleD 315 Posting Shark

I'm a little perturbed about how this happened--can someone explain it to me?

OK, I guess I am going crazy because now I cannot find the more detailed thread this person posted in the ASP.NET forum per my suggestion, though it was there a while ago.... whatever.

DdoubleD 315 Posting Shark

OK, I guess I am going crazy because now I cannot find the more detailed thread this person posted in the ASP.NET forum per my suggestion, though it was there a while ago.... whatever.

Scott, I gave suggestion to move this to ASP.NET. Personally, I've never moved a thread to a different forum and I didn't provide exact instructions. Please help this person in the other thread (ASP.NET) and I will ask that this one be closed--thanks.

DdoubleD 315 Posting Shark

Anytime. Please mark the thread as solved.

DdoubleD 315 Posting Shark

Upload your project in a zip file. FYI it is against the forum rules to ask the same question in two different forums. Please do not do that in the future.

Scott, I gave suggestion to move this to ASP.NET. Personally, I've never moved a thread to a different forum and I didn't provide exact instructions. Please help this person in the other thread (ASP.NET) and I will ask that this one be closed--thanks.

DdoubleD 315 Posting Shark

Hi, Thx for your reply
I'll have a look to your links and report back tomorrow
however just some more explanation, The running application that i'm trying to access is an externally installed app.
In short, i'm in QA, and i'm writing an automation framework, but i want to make it easier to access the custom built components by having my framework directly read and manipulate these objects (eg. Grids)

You might take a look at this link for some hints: Automated Test System Project