Jump to content

Welcome to eMastercam

Register now to participate in the forums, access the download area, buy Mastercam training materials, post processors and more. This message will be removed once you have signed in.

Use your display name or email address to sign in:

1 small question


Recommended Posts

After seeing what X+ and the new Active Reports can do I wanted to know what do I need to learn in order to do something similar to these programs but in my own way.

I like the output of .XML so I'm probably going to do something with that.

Link to comment
Share on other sites

I'd recommend starting with Visual Studio.

 

Active Reports using the VS interface to build your report. It looks like there might also be some VB.NET functionality that is available in the report designer. VB.NET now has some pretty cool tools for working with XML files like LINQ.

 

There are also a ton of resources available for learning Visual Studio.

 

When I started learning it (I'm still a noob) I got a lifetime subscription to

 

www.learnvisualstudio.net

 

It was cheap at the time and I've gotten more than my money's worth I think.

Link to comment
Share on other sites

I'm working with MFC and XML. My C-Hook call the XML to retrieve/save all the setup information.

 

It's not a big issue.

1. insert the line below DLL_PROCESS_ATTACH

in the DllMain(...) to initialize COM

code:

 CoInitialize(NULL) 

2. insert the line below DLL_PROCESS_DETACH in the DllMain(...) to release the COM.

code:

 CoUninitialize 

3. Read/Write/Manage the XML.

 

 

code:

 

//Read XML

CComPtr<IXMLDOMDocument> spDoc; //DOM

spDoc.CoCreateInstance(CLSID_DOMDocument);

VARIANT_BOOL vb;

spDoc->load(CComVariant(OLESTR("stocks.xml")),

&vb); //Load XML file

 

CComPtr<IXMLDOMElement> spRootEle;

spDoc->get_documentElement(&spRootEle); //Root Node

CComPtr<IXMLDOMNodeList> spNodeList;

spRootEle->get_childNodes(&spNodeList); //Child node list

 

long nLen;

spNodeList->get_length(&nLen); //number of child nodes

for (long i = 0; i != nLen; ++i) //go through child nodes

{

CComPtr<IXMLDOMNode> spNode;

spNodeList->get_item(i, &spNode);

ProcessNode(spNode); //Process the node - your own funcion

}

 

//Writing into XML

CComPtr<IXMLDOMNode> spNode;

spRootEle->selectSingleNode(OLESTR("/root/node1"),

 

&spNode);

spNode->put_text(OLESTR("newText"));

spRootEle->selectSingleNode(OLESTR

 

("/root/node2/childnode1/@attrib1"), &spNode);

spNode->put_nodeValue(CComVariant(OLESTR

 

("newValue"))); CComPtr<IXMLDOMNode> spNewNode;

spDoc->createNode(CComVariant(NODE_ELEMENT),

 

OLESTR("childnode3"), OLESTR(""), &spNewNode);

spRootEle->selectSingleNode(OLESTR("/root/node2"), &spNode);

spNode->appendChild(spNewNode, &spNewNode);

spNewNode->put_text(OLESTR("childtext2"));

 

CComQIPtr<IXMLDOMElement> spEle = spNewNode;

spEle->setAttribute(OLESTR("attrib1"), CComVariant(OLESTR("value1")));

spDoc->save(CComVariant(OLESTR("stocks.xml")));

 

void ProcessNode(CComPtr<IXMLDOMNode>& spNode)

{

CComBSTR bsNodeName;

spNode->get_nodeName(&bsNodeName);

AfxMessageBox(COLE2CT(bsNodeName));

CComVariant varVal;

spNode->get_nodeValue(&varVal);

AfxMessageBox(COLE2CT(varVal.bstrVal));

 

DOMNodeType eNodeType;

spNode->get_nodeType(&eNodeType);

if (eNodeType == NODE_ELEMENT) {

CComPtr<IXMLDOMNamedNodeMap> spNameNodeMap;

spNode->get_attributes(&spNameNodeMap);

long nLength;

spNameNodeMap->get_length(&nLength);

for (long i = 0; i != nLength; ++i)

{

CComPtr<IXMLDOMNode> spNodeAttrib;

spNameNodeMap->get_item(i, &spNodeAttrib);

ProcessNode(spNodeAttrib);

}

 

 

CComPtr<IXMLDOMNodeList> spNodeList;

spNode->get_childNodes(&spNodeList);

spNodeList->get_length(&nLength);

for (long i = 0; i != nLength; ++i)

{

CComPtr<IXMLDOMNode> spChildNode;

spNodeList->get_item(i, &spChildNode);

ProcessNode(spChildNode);

}

}

}


code:

 stocks.xml:

<?xml version="1.0" encoding="utf-8"?>

<root>

<node1>text1</node1>

<node2>

<childnode1 attrib1="value1" attrib2="value2"/>

<childnode2 attrib1="value1"

 

attrib2="value2">childtext1</childnode2>

</node2>

</root>


Link to comment
Share on other sites

You can get the free ->

Visual Studio Express Editions

 

I prefer C#, but you can use either ->

VB.NET or C#

 

The new LINQ stuff (in .NET 3.0) is absolutely awesome!!!

 

*The LINQ functionality isn't just for XML,

it is also very useful in other ways.

 

What you can do with XML data using the 'LINQ to XML' is amazing - it ROCKS!

Link to comment
Share on other sites

Thanks for the replies guys I'm liking the free version thing smile.gif Good way to get my feet wet!

 

I don't think I'm going to dive into any version of C anytime soon although I do find myself sitting here cursing because I want a program but don't know how to do it. I can edit posts, make excel macros and other simple stuff. I figure it's about time to dive in to programming and get it done the way I want.

 

Another question. If I plan on going from windows xp pro (32bit) to windows 7 (64bit) should I be concerned with how I make this program?

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.

Guest
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.

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.

Join us!

eMastercam - your online source for all things Mastercam.

Together, we are the strongest Mastercam community on the web with over 56,000 members, and our online store offers a wide selection of training materials for all applications and skill levels.

Follow us

×
×
  • Create New...