|
Hello... I have a function which takes my data from "Contload.xml"...and put it in the variable "Wc", how can I use this variable in the main program ...so that it be able to see it in the console.....
void readfromfile(String^ strFName,int Wc)
{
strFName = gcnew String("e:\\Contload.xml");
DataSet^ dataset = gcnew DataSet();
dataset->ReadXml(strFName);
DataRowCollection^ rows;
int Wc,Hc, Dc,idi,ix;
int id[100];
int w[100];
rows = dataset->Tables[0]->Rows;
for each (DataRow^ row in rows)
{
Wc = Convert::ToInt32(row["ContainerWidth"], System::Globalization::CultureInfo::CurrentCulture);
}
how can I cal this "Wc" in the main ...?
int main(int argc, char *argv[])
{
String^ filename = gcnew String("e:\\Contload.xml");
readfromfile(filename);
Console::WriteLine("Width: {0}",Wc);b>
lavy
|
|
|
|
|
Maybe
Console::WriteLine("Width: {0}", Wc.ToString());
Mark
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
|
|
|
|
|
If you want both readfromfile and Main to know about the variable Wc, then one option is to use what is called 'file scope'. If you define 'Wc' in file scope, then the variable becomes global for this ONE file. You simply define 'int Wc;', or perhaps 'static int Wc;' at the top of your file. Now you can use Wc anywhere in this file.
The current code will only print out the last result of Wc. Is that what you want? If you want to print Wc for each loop, you will need the WriteLine inside the for loop.
|
|
|
|
|
|
Hi,
I declared a managed struct
public ref struct FconvertRecord
{
};
This i am using in unmanaged class like this
Convert(FconverRecord *);
But this is giving error missing ; before *.
Thanks in advance.
Regards, Eswari
|
|
|
|
|
Shouldn't you be using ^ instead of *?
Mark
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
|
|
|
|
|
Hello gurus,
I have a compilation and linking problem with the __loctotime_t .
Is there an equivalent of this function in Win32?
To wich library belongs this function?
How can I solve my problem?
Best regards.
Fred.
There is no spoon.
|
|
|
|
|
I have a little bit of interop in C# which calls StgOpenStorageEx and returns an IStorage COM object:
[DllImport("ole32.dll")]
//AJ: http://www.pinvoke.net/default.aspx/ole32/StgOpenStorageEx.html
//AJ: http://msdn2.microsoft.com/en-us/library/aa380342.aspx
private static extern int StgOpenStorageEx([MarshalAs(UnmanagedType.LPWStr)]string pwcsName,
uint grfMode,
uint stgfmt,
uint grfAttrs,
ref STGOPTIONS pStgOptions,
IntPtr reserved2,
[In] ref Guid riid,
[MarshalAs(UnmanagedType.IUnknown)] out object ppObjectOpen);
IStorage structuredStorageFile = (IStorage )ppObjectOpen;
The IStorage interface isn't defined in the BCL's so we're making it ourselves:
[ComImport]
[Guid("0000000b-0000-0000-C000-000000000046")]
[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
//AJ: http://www.pinvoke.net/default.aspx/Interfaces/IStorage.html
public interface IStorage
{ ... }
This object is used in various places inside our C# code with perfectly good results and all is well. Now though we're wanting to pull that object into C++/CLI, which is no problem. Then we want to pass it to 'BindIFilterFromStorage' to retrive the appropriate IFilter, which is a problem. We've had a bit of a poke around and tried getting 'BindIFilterFromStorage' to take the object but we just get '8000ffff' Catastrophic failure all the time.
If any one could shead any light on how we can achive this or indeed even if its just not possible that would be great!
Andy
|
|
|
|
|
I created the Xml file, I want to put the data from xml in a table....I have my function like this...
void readfromfile()
{
String^ strFName = gcnew String("d:\\Contload.xml");
DataSet^ ds = gcnew DataSet();
DataTable^ table;
DataRow^ row;
int i;
try
{
ds->ReadXml(strFName);
DataRowCollection^ dr = ds->Tables[0]->Rows;
}
finally
{
delete strFName;
}
}
but I don't know how to do next....to put the data from the Xml in Tables[]
I created an for like...
for (i=0; iTables->Count; i++)
{
table = ds->Tables->Item[i];...................
.......}
but it give me an error :
Error 6 error C2039: 'Item' : is not a member of 'System::Data::DataTableCollection' ...
can you tell me at least why it give me this error...please
|
|
|
|
|
With C++/CLI you can use 'for each':
for each(Table table in ds.Tables)
{}
|
|
|
|
|
Hello, I have an Xml and I want to put data from it in tables how can I do this ...please if you have an idea of example or something like this..help me...thanks
lavi
|
|
|
|
|
See this[^] is helpfuls for you?
|
|
|
|
|
|
|
|
If Christian Graus were around he would let you know that this is the C++/CLI forum, as the first message in the forum states, and your question does not seem to pertain to that subject therefore it is in the wrong forum.
To find the answer to your question read the documentation on the _T() macro.
led mike
|
|
|
|
|
Hi,
I have a function DataPeak(const void* el1, const void* el2) in class oconvew.h
Now i have to pass this as an argument to other function
qsort(void*, size_t, size_t,pointer to DataPeak)
I did like this
qsort(x,num,sizeof(m),&oconvew::DataPeak)..
It is giving qsort cannot convert all required two arguments.
Any help is appreciated.
Thanks, Eswari
|
|
|
|
|
If Christian Graus were around he would let you know that this is the C++/CLI forum, as the first message in the forum states, and your question does not seem to pertain to that subject therefore it is in the wrong forum.
To learn more about function pointers in C++ search Google for: cplusplus "function pointers"
led mike
|
|
|
|
|
sorry for posting in the wrong forum and at the same time thanks for your answer
|
|
|
|
|
|
Hello,
first off, bear with me as i posted this question on another newsgroup a couple of hours ago (but my thread does not look like getting answered during the next week).
So here's the problem. I tried to translate this c# example to c++/cli:
CustomVertex.PositionNormalTextured[] verts =<br />
(CustomVertex.PositionNormalTextured[])_mesh.VertexBuffer.Lock( 0,<br />
typeof( CustomVertex.PositionNormalTextured ),<br />
LockFlags.None,<br />
_mesh.NumberVertices );<br />
Looks simple and should be simple to translate. But...
array<Direct3D::CustomVertex::PositionNormalTextured, 1>^ myVertices = gcnew<br />
array<Direct3D::CustomVertex::PositionNormalTextured, 1><br />
(myMesh->NumberVertices);<br />
myVertices = safe_cast<array<Direct3D::CustomVertex::PositionNormalTextured,<br />
1>^> (myMesh->VertexBuffer->Lock(0,<br />
Direct3D::CustomVertex::PositionNormalTextured::typeid,<br />
Direct3D::LockFlags::None));<br />
gives me an IndexOutOfRangeException.
So i think i have to use gcnew in the second line. But how?
I just can't figure out the right syntax to solve this problem.
Or is there just something else wrong?
I hope, someone is able to help me on this.
|
|
|
|
|
VertexBuffer.Lock returns an Array pointer but you are casting it to an array pointer.
Maybe something like this...
Array ^myVertices = myMesh->VertexBuffer->Lock(0,
Direct3D::CustomVertex::PositionNormalTextured::typeid,
Direct3D::LockFlags::None);
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
|
|
|
|
|
You are right, but the cast seems to be needed as i'm going from system::array to array<...> and as system::array is an abstract class (ok one can create an instance of such an array, but that's another story), i had to go through a cast.
But the problem was solved (not by me btw )
Here's the right way to do it:
array<Direct3D::CustomVertex::PositionNormalTextured>^ myVertices = safe_cast<array<Direct3D::CustomVertex::PositionNormalTextured>^> (myMesh->VertexBuffer->Lock(0, Direct3D::CustomVertex::PositionNormalTextured::typeid, Direct3D::LockFlags::None, myMesh->NumberVertices));
The last parameter made it.
Thanks for trying to help me, Mark.
|
|
|
|
|
Cool thanks for the update! I didn't know you could cast between those
Mark
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
|
|
|
|
|
I am doing like this in my .h file
String^ strpath="dff";
CString strDataPath(strpath);
GetXcaliburDataPath(&strDataPath);
In the last line the compiler is issuing a error like this
cannot convert from CString* to CString&.
Thanks in advance.
|
|
|
|