Ziron_RegisterUFunction example
hi Colin
can you please a working example of Ziron_RegisterUFunction function please.
http://www.freewebs.com/ogremagic/index.htm
A community discussion post from the original code:zIRON forum.
hi Colin
can you please a working example of Ziron_RegisterUFunction function please.
http://www.freewebs.com/ogremagic/index.htm
Hi , i really need a working example of Ziron_RegisterUFunction function.
and how to ues Ziron_CallUFunc .
http://www.freewebs.com/ogremagic/index.htm
Hi Emil, i have written a sample, but i'm making some changes and adding a new event before i post the sample, hopefully soon.
ok here is sample plugin of using these 2...
program WIN32DLL 'test plugin';
#include 'zirplug/framework.zir';
#include 'strings.zir';
const strLoaded = 'Sleep seconds plugin has loaded';
DWord u_Sleep_S;
function event_ssleep() {
if (u_Sleep_S == 0) {
return false;
}
uses edi;
char myBuf[64];
eax = Ziron_ExpectNextToken(zirNumber);
if (eax == -1) {
Ziron_FatalError('ssleep an integer value');
return true;
}
edi = Ziron_GetStringValue();
myBuf = 0;
strJoin(@myBuf, '(', edi, ')', 64);
eax = Ziron_ExpectNextToken(zirSemi_Colon);
if (eax == -1) {
Ziron_FatalError('ssleep expected ; after second sleep value');
return true;
}
//now call the function (will return false if failed
Ziron_CallUFunc(u_Sleep_S, @myBuf);
return eax;
}
function InitPlugin(pointer pGetF) {
Ziron_LoadAll(pGetF); //use framework utility function to load all
Ziron_RegisterKeyword('ssleep', @event_ssleep);
return strLoaded;
}
procedure ProgramBegin(char* apptype) {
//note that submitting includes should never be done inside InitPlugin.
Ziron_Exec('#include \'kernel32.zir\';'); //required for winapi function sleep
u_Sleep_S = Ziron_RegisterUFunction(
'function Sleep_S(DWord seconds) {'
+ ' eax = seconds;'
+ ' imul eax, 1000'
+ ' sleep(eax); }'
);
}
entry function DLLMain(DWord iDLL; DWord iReason; Pointer iResult) {
if (iReason == DLL_PROCESS_ATTACH) {
return true;
}
return false;
}
exports InitPlugin, ProgramBegin;
I will release the beta update after i finish adding another pf function.
this plugin would allow the usage of the following code inside a source:
ssleep 5;
i've updated the beta.
nice example.
l have add this for the sake of the simple strjoin , so i can use Ziron_GetStringValue directly in strjoin function.
inline function Ziron_GetStrValue()
{
edx = Ziron_GetStringValue();
$return edx;
}
so i can use this
myBuf = 0;
strJoin(@myBuf, '(', Ziron_GetStrValue(), ')', 64);
http://www.freewebs.com/ogremagic/index.htm