|
If a 2 dimension array works for you then all you need is
<br />
<code>array < String ^, 2 > ^ tab=gcnew array < String ^, 2 > (20, 200);<br />
<br /> That's 4000 Strings.
You can add a String something like:
<code>tab[0,0] = gcnew String("String at (0,0)");<br />
<br /> What are you trying to do with the other array?
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
I would store subItems in any structure {because i have many subItems who are generate with a Timer} , then recover the contents of this structure after a few moments,
array < String ^ > ^ subItems = gcnew array < String ^ >(16);
Thank you verry mutch
|
|
|
|
|
So it's working now?
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Unfortunately, it doesn't work yet
I would store subItems in any structure {because i have many subItems who are generate with a Timer} , then recover the contents of this structure after a few moments,
array < String ^ > ^ subItems = gcnew array < String ^ >(16);
and i would set : Structure [i]= subItems ; i++;
Thank you verry mutch
|
|
|
|
|
array < String ^ > ^ subItems = gcnew array < String ^ >(16);
// Structure is an array of string arrays
array < array < String ^ > ^ > ^Structure = gcnew array < array < String ^ > ^ >(numberofstringarrays);
Structure [i]= subItems ;
i++;
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
These simple problems are begining to bug me. I'm using Visual Studio 2005 C++/CLI. My app does some stuff that takes long enough that I wanted to have a small dialog box appear with status information. In Visual Studio I select 'project'->Add New Item->UI->Windows Form and give it the name of "Status Dialog". This creates the "Status Dialog.h" header and the name of the class is 'ref class StatusDialog' (note no space between Status and Dialog). The "Status Dialog.h[Design] page appears with a new form. I add a label (that I plan to change progromatically) and that's it. I open the myClass.h file of the class I want to use it in and include the "Status Dialog.h" file. This all compiles fine. I add the declaration in the myClass.h file as StatusDialog^ aDlg;. This does not compile. It gives the general error of C2143: syntax error : missing ';' before '^'. The "Status Dialog.h" file is created by Visual Studio so it should be okay. Does anyone see anything wrong here. This should be simple.
#include "Status Dialog.h" // Created by Visual Studio
using namespace System;
ref class myClass
{
public:
myClass(void);
StatusDialog^ aDlg; // Remark this out, compiles OK. Leave in and I get the syntax error.
};
}
Buck
|
|
|
|
|
Is the StatusDialog class in the same namespace as the myClass class?
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
I believe so. The first line before "ref class StatusDialog" is "namespace projectname{". I looked at "Form1.h" and "Status Dialog.h" and they both have this namespace declaration but the myClass.h file does not. I added a "namespace projectname" to the myClass.h file but that did not help. I am going to try to remove the two namespace declarations in the Visual Studio generated files to see if that helps.
|
|
|
|
|
All the class declarations don't have to be in the same namespace, but if they aren't,
then you'll need to qualify any references to classes in other namespaces.
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
I take that back. As I was trying the approach I just mentioned I noticed that there was a declaration that should have been remarked out (which was causing my secondary error). I deleted this un-needed line and tried to recompile but got the same errors. Then I added the "namespace projectname" to the begining of the myClass.h file and everything compiled fine. Here's the moral of this story...All of the files in my project have been created with Visual Studio. When you use Visual Studio to create files, sometimes Visual Studio will define the file as part of the namespace and sometimes it does not, in which case you have to go and add it into the namespace explicitly. Personally, I think this is stupid. I think Visual Studio should always create a file in the projects' namespace unless you explicitly exclude it from the namespace. Bottom line, now that I know about this I can keep an eye out for it as I use Visual Studio to create files.
Thanks
Buck
|
|
|
|
|
Can anyone shed some light. I have rebuilt my application after installing Vista Premuim and downloading the latest VC++ Express edition (version 8.0.50727.867 ( vista.050727-8600) .Net Framework version 2.0.50727) using the following code sample and I am getting some weird results to the port list which I don't see when running the same code that was compiled in windows XP with VC++Express (Don't know what version I had since my drive crashed - Was downloaded in 2006)
This is the code
try {
// Get a list of serial port names.
TRK_PORTNAME_cbox->Items->Clear();
TRK_PORTNAME_cbox->Items->AddRange(TRK_Port->GetPortNames());
}
catch (Win32Exception^ ex) {
MessageBox::Show(ex->Message);
}
At this point TRK_PORTNAME_cbox->Items[0-2] contains:
"COM3"
"COM5鮤"
"COM4"
I don't know why it's finding Com3 and 5 since I only have a USB to serial adapter at COM4. THat weird character after COM5 doesn't appear when I run my old build in Vista.
Help!!
LarryD
|
|
|
|
|
You can check that list in other places:
- a terminal emulator (such as HyperTerminal) should present it to you
- the Device Manager (right click "My Computer" if that is still around, then follow the
word "Hardware"...) should enumerate all your hardware, so you could find serial ports
under a whole range of entries, such as: Ports, USB, and some vendor-specific groups if any.
If none of the above show COM3 and COM5, you can safely conclude they dont exist,
and your app+VS+.NET is wrong; if they do show up, you are in for a Vista drivers
adventure I guess.
|
|
|
|
|
Hi, I am using Visual Studio 2005 C++/CLI. I have a class that includes a structure or nested class that has an array within it. I am having problems getting the definition right. A simple example is...
ref class CWafer
{
public:
CWafer(void);
value class CCoordinate
{
public:
int nXcoord;
int nYcoord;
int nBin;
int nType;
array<int>^ nIndex;
array<int>^ nByte;
};
I need to create a two dimensional array so further down in the class definition I have declared...
array<ccoordinate, 2="">^ OriginalData;
And in the constructor of the wafer class I have the line...
OriginalData = gcnew array<ccoordinate, 2="">(1000, 1000);
I can then access the integers in the nested class, but I cant figure out the correct way to define the arrays named nIndex and nByte. When I try to access these the debugger shows them as being undefined. Can someone provide me with a link to some decent documentation on how to use multidimensional CLI arrays and arrays of classes. I could change this from a nested class to a struct but I think I will have the same problem.
Thanks
Buck
|
|
|
|
|
Missing information in previous post.
In the CWafer class I defined...
"array<ccoordinate, 2="">^ OriginalData;" // This two dimensional array
and then in the constructor used...
"OriginalData = gcnew array<ccoordinate, 2="">(1000, 1000);"
It seems there is a problem with the "<>" brackets.
Buck
|
|
|
|
|
Since there is a problem with the brackets I will use [] for this illustration.
In the CWafer class I have declared a two dimensional array as...
array[CCoordinate, 2]^ OriginalData;
Then in the constructor I have defined it as...
OriginalData = gcnew array[CCoordinate, 2](1000, 1000);
Thanks
|
|
|
|
|
Hi,
when posting some code you could:
1. use the <pre> and </pre> tags to get background coloring, and preserve indentation
2. check the "ignore HTML tags" below the textbox to preserve the < and > that get
eaten by the HTML interpreter
but you cant expect both to work at the same time.
If you republish your code with this in mind (that's 2. I guess), more people may react
to the actual question...
|
|
|
|
|
Not having ever heard of these "tags", how do you use them?
Buck
|
|
|
|
|
These are HTML tags, they apply to whatever is in between the opening tag and the closing
tag, that is:
<pre>
for (i=0; i<10; i++) {
print (a[i]);
}
</pre>
will show as (there are four spaces to the left of print, a tab would do too):
for (i=0; i<10; i++) {
print (a[i]);
}
which is quite a difference for larger blocks of code, isnt it ?
|
|
|
|
|
Luc,
Is there a secret way to copy code FROM a post that's wrapped in "pre" tags and still retain
carriage returns when pasting to, say, Visual Studio?
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Hi Mark,
I had a discussion only yesterday about PRE and CODE tags,
and it is confusing and not satisfying.
the PRE tag seems to give non-prop font, correct spacing (except drops empty lines), background;
the CODE tag seems to give non-prop font, dark red forground color
copying while preserving newlines is completely unclear;
sometimes it works for both PRE, CODE and PRE+CODE
sometimes it does not; I do not understand
And I dont know a magic trick that solves it all.
Regards
|
|
|
|
|
I don't think pre drops blank lines:
Let me see...
Oh that's right - I had to ask about that one a while back - add at least 1 space to the line
and the line will stay - so yes, I guess it drops empty lines.
Anyway, I like the way code looks in the pre tags, I just wish I could copy the code right over
to VS. I spend enough time here so it grinds my gears when I have to go through and reformat it.
I guess I could actually research this. Nah.
Thanks!
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Hi Mark,
I fully agree.
One should be able to copy source code from VS into whatever tag is required in a message
to get it shown at its best; and to copy code from a message back to VS, without any
hassle.
AFAIK that is not the case:
1.
empty lines (without a single char) get thrown out of PRE
2.
and copying from message to elsewhere may or may not succeed (i.e. keep newlines)
3.
and then there is the problem with the < sign which triggers HTML interpretation;
if you're lucky it does not start a valid HTML tag and it will show as intended;
if unlucky it will be eaten together with some more characters
(most striking example are the summary,returns,remarks tags from structured comments in C#,
the ones that can be collected into an XML file.
Of course, there must be technical reasons for the current behavior: the message is shown
as HTML text, so we copy what we see (more or less), but we dont see what we type or paste;
nevertheless we want to be able to paste, then copy with no change whatsoever !
I'll try to do some more research on this, resulting hopefully in:
- either some guidelines as to how best to use what is available
- or a new request towards the webmaster(s)
Regards
|
|
|
|
|
Luc,
Here is an odd twist. If I am using the CPSyntax, and take the
and paste into VS, I get...
1.
2.
3.
4.
5.
This happens in Notepad, as well. Disabling CPSyntax, all is good
"The clue train passed his station without stopping." - John Simmons / outlaw programmer
|
|
|
|
|
Paul Conrad wrote: Disabling CPSyntax, all is good
On my laptop, I had an older version of CPSyntax. Updated CPSyntax and all is better now...
"The clue train passed his station without stopping." - John Simmons / outlaw programmer
|
|
|
|
|
I've had some time to play with CPhog on FF. Fixed all my editor gripes
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|