Gamestudio Links
Zorro Links
Newest Posts
Zorro 2.70
by jcl. 09/29/25 09:24
optimize global parameters SOLVED
by dBc. 09/27/25 17:07
ZorroGPT
by TipmyPip. 09/27/25 10:05
assetHistory one candle shift
by jcl. 09/21/25 11:36
Plugins update
by Grant. 09/17/25 16:28
AUM Magazine
Latest Screens
Rocker`s Revenge
Stug 3 Stormartillery
Iljuschin 2
Galactic Strike X
Who's Online Now
2 registered members (AndrewAMD, TipmyPip), 12,420 guests, and 5 spiders.
Key: Admin, Global Mod, Mod
Newest Members
krishna, DrissB, James168, Ed_Love, xtns
19168 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Dll XML #150605
08/27/07 21:19
08/27/07 21:19
Joined: Aug 2006
Posts: 78
A
amadeu Offline OP
Junior Member
amadeu  Offline OP
Junior Member
A

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 Offline
Expert
Uhrwerk  Offline
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
A
amadeu Offline OP
Junior Member
amadeu  Offline OP
Junior Member
A

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 Offline
Expert
Uhrwerk  Offline
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: Uhrwerk] #150609
08/27/07 23:16
08/27/07 23:16
Joined: Aug 2006
Posts: 78
A
amadeu Offline OP
Junior Member
amadeu  Offline OP
Junior Member
A

Joined: Aug 2006
Posts: 78
ok. I will see.

there is some tutorial that explain how use function with Dll in gamestudio?

thx

Re: Dll XML [Re: Uhrwerk] #150610
08/28/07 00:03
08/28/07 00:03
Joined: Aug 2006
Posts: 78
A
amadeu Offline OP
Junior Member
amadeu  Offline OP
Junior Member
A

Joined: Aug 2006
Posts: 78
Hi ,
I am confuse with lite-c and Dll. I did exactly what the "Getting started with the plugin SDK" said but when I run my file appear : crash in main. My code is:
1- In teste.dll
#include "stdafx.h"
#define DLL_USE
#include "adll.h"
#include <string.h>
#include <stdio.h>
#include <windows.h>
#include <tchar.h>


BOOL APIENTRY DllMain(
HANDLE hModule,
DWORD ul_reason_for_call,
LPVOID lpReserved)
{
engine_bind();
return TRUE;
}

DLLFUNC var ldexpc(var x,var n)
{
return (_VAR(_FLOAT(x)*(_FLOAT(n))));
}

2- in SED
#include <acknex.h>
#include <default.c>

var ldexpc(var x,var n);
var a;
var XMLAdvAppHandle;
void main()
{
video_mode = 7; // lite-C: start in 640x480 resolution
video_screen = 2; // lite-C: start settings for Fullscreen
level_load("VAH.wmb");
wait(2); // let level load
XMLAdvAppHandle = dll_open("XMLDllNovo.dll");
wait(2);
a = ldexpc(1,2);
}

What s wrong with my code? I need to declare the DLL file in somewhere of script?
I need help and more tutorial about SDK and Lite-c

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 Offline
Expert
Uhrwerk  Offline
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: Uhrwerk] #150612
08/28/07 05:24
08/28/07 05:24
Joined: Aug 2006
Posts: 78
A
amadeu Offline OP
Junior Member
amadeu  Offline OP
Junior Member
A

Joined: Aug 2006
Posts: 78
Hallo

I did what you said but doesn´t work. Appeared again "crash in main".
Do you have some example or tutorial for this?

thx

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 Offline
Expert
Uhrwerk  Offline
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...
Re: Dll XML [Re: Uhrwerk] #150614
08/28/07 16:54
08/28/07 16:54
Joined: Sep 2003
Posts: 9,859
F
FBL Offline
Senior Expert
FBL  Offline
Senior Expert
F

Joined: Sep 2003
Posts: 9,859
add a wdl file with the same name as the C file and specify PLUGIN_DIR "."; there.
Otherwise you'll have to copy the DLL to a subfoler ACKNEX_PLUGINS.


Moderated by  HeelX, Lukas, rayp, Rei_Ayanami, Superku, Tobias, TWO, VeT 

Gamestudio download | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1