Jump to content

Longest Running Thread EVER


Recommended Posts

Re: Longest Running Thread EVER

 

The rate at which birds are emptying our backyard feeder these last few days is impressive. I think a lot of them had begin their northward migration and had got as far as Puget Sound when this clutch of storms hit, and now all of the migrators are tiding over here where it's more moderate weather-wise than inland or further north. So we have a temporary overpopulation consuming food at remarkable rates.

Link to comment
Share on other sites

Re: Longest Running Thread EVER

 

I need some help. I am (imo) reasonably good at programming C++, but I have effectively no knowledge of how to 'interface' that knowledge with Visual C++. I'm using Microsoft Visual C++ 2010 Express (a free download).

 

I need to write a program where I can store unsigned integer values into a two dimensional array of 1024 x 4 cells. I want to load the cells by clicking buttons instead of typing in a numeric value. My research so far has led me to the following statements in main, which compiles and runs:

 

array ^ uiPieces = gcnew array(1024, 4);  // Create the 1024 x 4 array of unsigned integers.
for(I=0;I<1024;I++) {uiPieces[i,0]=0;uiPieces[i,1]=0;uiPieces[i,2]=0;uiPieces[i,3]=0;} // Initialize the array.  'I' is declared elsewhere.

 

But I can't find a way to access the uiPieces array from the form1.h 'piece' of the program that contains all the function calls that are tied to the gui interface. If I try to declare the array extern(al), I get an error. If I try to move the first statement out above main, I get an error. If I put it into form1.h (where I can happily declare other unsigned int variables), I get an error.

 

All the 'tutorials' I've found so far haven't dealt with arrays in a *Visual* environment. :mad:

Link to comment
Share on other sites

Re: Longest Running Thread EVER

 

It's been too long since I did Visual C++, and even that was with the 2000 version of the compiler/etc. Have you included in the object which includes that 2-d array an explicit accessor member function that is externally callable?

Link to comment
Share on other sites

Re: Longest Running Thread EVER

 

You don't mention using any scope declarations, so I'll start there. Have you tried declaring a Class scope like:

class ClassName
{
   int x;
   int y;
};

 

You would declare your array within the brackets where I've placed the sample variables. Then to access the variables you use the ClassName.ArrayName.

Link to comment
Share on other sites

Re: Longest Running Thread EVER

 

It's been too long since I did Visual C++' date=' and even that was with the 2000 version of the compiler/etc. Have you included in the object which includes that 2-d array an explicit accessor member function that is externally callable?[/quote']

 

I was hoping to avoid using Objects, as this is meant to be a "quick-n-dirty" personal project.

 

You don't mention using any scope declarations, so I'll start there. Have you tried declaring a Class scope like:

class ClassName
{
   int x;
   int y;
};

 

You would declare your array within the brackets where I've placed the sample variables. Then to access the variables you use the ClassName.ArrayName.

 

I tried as you suggested, RPMiller, and I get pretty much the same thing. I admit to being extremely rusty in this language, and having a preference for Procedural vs Objects coding. This is meant to be a (so far) "quick-n-dirty" project, emphasis on quick. :-\

 

I've been trying just to get main and the form to share a simple unsigned int variable, and event that is proving not yet possible for me. :mad: I figure, once I solve this problem, I can possibly add the level of complication that arrays have become. Whatever happened to simply doing*: unsigned int uiPieces[1024][4];?

 

*In Borland Turbo C++.

Link to comment
Share on other sites

Re: Longest Running Thread EVER

 

The problem is that you have to declare your variables with the proper scope, which in OOP requires a class to be instantiated at the global level. The array needs to stay in existence until the project or procedure ends.

Link to comment
Share on other sites

Re: Longest Running Thread EVER

 

The problem is that you have to declare your variables with the proper scope' date=' which in OOP requires a class to be instantiated at the global level. The array needs to stay in existence until the project or procedure ends.[/quote']

 

I tried that (or I think I did). I put class with the array outside of main to make it global, and the form still couldn't access it. I put a regular unsigned int outside of main to make it global, and I can't even access it from the form. I never got into using header files -- Is there something simple I am missing about them that would cause this inability?

 

Normally I learn reasonably well on my own, given condensed, concise information. the online PHP manual has been a great source for me in learning PHP -- why can't I find somethign similar for Visual C++? Grrr.

Link to comment
Share on other sites

Re: Longest Running Thread EVER

 

Yay! Now that I got that hurdle cleared, it seems simple.

 

I had to declare (and *only* declare) the array in the form with:

 

array ^ uiPieces;

 

And then assign it the array and initialize it in the Form1_Load 'function' that executes once when the form first starts up/loads with:

 

uiPieces = gcnew array(1024, 4);

for(I=0;I<1024;I++) {uiPieces[i,0]=0;uiPieces[i,1]=0;uiPieces[i,2]=0;uiPieces[i,3]=0;}

 

Now all the other button event functions (in the form, which is mainly what I care about) can see and modify the uiPieces array!

Link to comment
Share on other sites

Re: Longest Running Thread EVER

 

Normally I learn reasonably well on my own' date=' given condensed, concise information. the online PHP manual has been a great source for me in learning PHP -- why can't I find somethign similar for Visual C++? Grrr.

 

Because Visual C++ is proprietary, and they intend to make money off the sale of documentation and training. Duh.

Link to comment
Share on other sites

Re: Longest Running Thread EVER

 

Back when I worked for the insurance company and they were being pushed into upgrading their Exchange server installation, I had to figure out what that would do to our custom email stuff. It was nearly impossible to find out, because the new list of "properties" (in Exchange, ***everything*** is an IUnknown object with a large collection of properties) was something you had to pay money to get. I managed to find such a list once hanging unprotected and with no special annotation off a .mil site, so I happily copied it and started poring over it and finally noticed the "Confidential" notation in the page footers of the document.

 

Reported this to the boss, deleted my copy, and went on flailing ineffectively at what I was supposed to do without a budget.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...