2 registered members (AndrewAMD, TipmyPip),
12,420
guests, and 5
spiders. |
Key:
Admin,
Global Mod,
Mod
|
|
|
Dll XML
#150605
08/27/07 21:19
08/27/07 21:19
|
Joined: Aug 2006
Posts: 78
amadeu
OP
Junior Member
|
OP
Junior Member
Joined: Aug 2006
Posts: 78
|
Hallo
I created one DLL to parse XML file. In this DLL I create some function to get some XML parameters. When I call the function in c-script it works, but when I call the same function in lite-c appear one error: can not converter "ARRAY" to "FIXED". The example above, I want to copy one string in XML file to other string in the game. The function Get_SAttributValue(file, xpath, attribut) return the value of attribut . the code in c-script is (works): dllfunction Get_SAttributValue(file, xpath, attribut); STRING* Nfile; var XMLAdvAppHandle; .... Function main() { XMLAdvAppHandle = dll_open("XMLDllNovo.dll"); str_cpy(Nfile, Get_SAttributValue(file,pathX,"src")); }
the code in lite-c is (don´t work): function Get_SAttributValue(file, xpath, attribut); STRING* Nfile; .... Function main() { dll_open("XMLDllNovo.dll"); str_cpy(Nfile, Get_SAttributValue(file,pathX,"src")); }
did I do something wrong?
|
|
|
Re: Dll XML
[Re: amadeu]
#150606
08/27/07 22:53
08/27/07 22:53
|
Joined: Jan 2002
Posts: 4,225 Germany / Essen
Uhrwerk
Expert
|
Expert
Joined: Jan 2002
Posts: 4,225
Germany / Essen
|
Please show us the header file of the .dll. You have obviously confused a type.
Always learn from history, to be sure you make the same mistakes again...
|
|
|
Re: Dll XML
[Re: Uhrwerk]
#150607
08/27/07 23:00
08/27/07 23:00
|
Joined: Aug 2006
Posts: 78
amadeu
OP
Junior Member
|
OP
Junior Member
Joined: Aug 2006
Posts: 78
|
HI, Why in c-script the function from Dll works and with lite-c doesn´t work? hier is the dll function code.
DLLFUNC BSTR Get_SAttributValue(STRING* file, STRING* xpath, STRING* attribut) { IXMLDOMDocumentPtr pXMLDom; HRESULT hr; BSTR bstrA; BSTR bstrB; _bstr_t bstrValue; STRING* error = NULL;
CoInitialize(NULL);
hr = pXMLDom.CreateInstance(__uuidof(DOMDocument30)); if (FAILED(hr)) { return dprintf("\t%S\n\n", L"Failed to instantiate DOMDocument30 class\n"); } pXMLDom->async = VARIANT_FALSE; if ( pXMLDom->load(_CHR(file)) != VARIANT_TRUE) { return dprintf("\t%S\n\n", L"Failed load xml data from file.\n"); }
// Query a single node. IXMLDOMNodePtr pNode = pXMLDom->selectSingleNode(_CHR(xpath)); if (pNode == NULL) { return dprintf("\t%S\n\n", L"Invalid node fetched.\n"); } else { return printf("Result from selectSingleNode:\nNode, <%s>:\n\t%s\n\n", (LPCSTR)pNode->nodeName, (LPCSTR)pNode->xml); }
// atributos
IXMLDOMNamedNodeMap* attributeMap;
bstrValue = _CHR(attribut); pNode->get_attributes(&attributeMap); attributeMap->raw_getNamedItem(bstrValue,&pNode); pNode->get_nodeName(&bstrA); pNode->get_text(&bstrB); dprintf("\t%S\n\n", bstrB); printf("Result from Atributos:\nNode, <%s>:\n\t%s\n\n", bstrValue, (LPCSTR)bstrB);
// Query a node-set. IXMLDOMNodeListPtr pnl = pXMLDom->selectNodes("//stock[1]/*"); for (int i=0; i<pnl->length; i++) { pNode = pnl->item; printf("Node (%d), <%s>:\n\t%s\n", i, (LPCSTR)pNode->nodeName, (LPCSTR)pnl->item->xml); }
pXMLDom.Release(); pNode.Release(); pnl.Release(); CoUninitialize(); return dprintf("%S", bstrB); }
|
|
|
Re: Dll XML
[Re: amadeu]
#150608
08/27/07 23:07
08/27/07 23:07
|
Joined: Jan 2002
Posts: 4,225 Germany / Essen
Uhrwerk
Expert
|
Expert
Joined: Jan 2002
Posts: 4,225
Germany / Essen
|
I didn't mean the .dll code, I meant the header you are using in the Lite-C File. However, i saw you have done this just in the Lite-C file. Change your header to "BSTR Get_SAttributValue(STRING* file, STRING* xpath, STRING* attribut)". Make sure you have defined BSTR in the lite-c file. However, you can't use str_copy with that type.
The difference is, that Lite-C cares about types. C-Script had no type check in its compiler. It's important now that you always use the correct type when calling .dll functions.
Always learn from history, to be sure you make the same mistakes again...
|
|
|
Re: Dll XML
[Re: amadeu]
#150611
08/28/07 02:49
08/28/07 02:49
|
Joined: Jan 2002
Posts: 4,225 Germany / Essen
Uhrwerk
Expert
|
Expert
Joined: Jan 2002
Posts: 4,225
Germany / Essen
|
On a first look everything looks alright. You just don't need to open the .dll explicitely, i.e. you can delete the line with dll_open and the declaration of the handle when the .dll file is in the plugin folder. Other than that you should cast the numbers ot fixed (or var which is the same) before you pass them to the dll function:
a = ldexpc((fixed)1,(fixed)2);
Always learn from history, to be sure you make the same mistakes again...
|
|
|
Re: Dll XML
[Re: amadeu]
#150613
08/28/07 10:40
08/28/07 10:40
|
Joined: Jan 2002
Posts: 4,225 Germany / Essen
Uhrwerk
Expert
|
Expert
Joined: Jan 2002
Posts: 4,225
Germany / Essen
|
No, I don't know where to find a tutorial, except for the one in the manual. Are you sure the .dll is opened? Have a look in your acklog.txt.
Always learn from history, to be sure you make the same mistakes again...
|
|
|
|