Register | Login
Forum Index > Plugins > Ziron_GetStringValue Eaxmple
Author Message
Pages: 1 2 3
Emil_halim
Ziron Beta Tester

avatar

(send private message)

Posts: 639
Topics: 104

Location:
Alex, Egypt
[316] Ziron_GetStringValue Eaxmple - posted: 2011-11-04 19:39:48

could you please post an example that demonstrate the Ziron_GetStringValue Function.

http://www.freewebs.com/ogremagic/index.htm
Admin
Site Admin

avatar

(send private message)

Posts: 933
Topics: 55

Location:
OverHertz Studio
[317] - posted: 2011-11-04 20:22:34
There is a bug, that i have fixed haha, anyways here is an example

Code:
const strLoaded = 'Test plugin has loaded!';

function event_KeyTest() {
  //first get string value of KeyTest
  eax = Ziron_GetStringValue();
  Ziron_ShowMessage(eax);

  eax = expectNextToken(zirConstString);
  if (eax == -1) {
    Ziron_FatalError('No constant string found');
    return true;
  }
  
  eax = Ziron_GetStringValue(); //get the string contents of 'the string'
  Ziron_ShowMessage(eax);
  
  eax = true;
}

function InitPlugin(pointer pGetF) {
  Ziron_LoadAll(pGetF); //use framework utility function to load all

  //register our keyword
  Ziron_RegisterKeyword('KeyTest', @event_Test);
  
  return strLoaded;
}


and usage:

Code:
program WIN32CUI 'test';

#include 'console.zir';

eax = 1;
print('eax = ', eax:int, '\r\n');

KeyTest 'my string';

print('eax = ', eax:int, '\r\n');

wait_key(nil);
ExitProcess(0);


this should output

KeyTest
my string

Download Ziron
Get free hosting for Ziron related fan-sites and Ziron projects, contact me in private message.
Emil_halim
Ziron Beta Tester

avatar

(send private message)

Posts: 639
Topics: 104

Location:
Alex, Egypt
[318] - posted: 2011-11-04 20:42:18

ok , here is my first step in creating Basic-like syntax , but have some problems.

so i want to pares this line
Code:
Dim Var as int32;


SO here is the Basic PlugIn
Code:
program WIN32DLL 'BASIC PLUGIN';

#include 'zirplug/framework.zir';

//////////////////////////////

const strLoaded = 'Basic plugin has loaded!';

function event_Dim() {
    uses edi;  
    eax = Ziron_ExpectNextToken(zirIdent);
  if (eax == -1) {
    Ziron_FatalError('Expected Variable Name');
    return true;
  }
    
    eax =  Ziron_GetStringValue();
  
    Ziron_ShowMessage(eax);   // this must print 'Var' but is does not 
         
    eax = Ziron_ExpectNextToken(zirAs);
  if (eax == -1) {
    Ziron_FatalError('Expected as Keyword');
    return true;
  }
  
  eax = Ziron_ExpectNextToken(zirDATA_TYPE);
  if (eax == -1) {
    Ziron_FatalError('Expected data type');
    return true;
  }
  edi = Ziron_GetTypeSize();
  
  
  return true;
}

function InitPlugin(pointer pGetF) {
  Ziron_LoadAll(pGetF); //use framework utility function to load all

  //register our keyword
  Ziron_RegisterKeyword('Dim', @event_Dim);
  
  return strLoaded;
}

entry function DLLMain(DWord iDLL; DWord iReason; Pointer iResult) {
  if (iReason == DLL_PROCESS_ATTACH) {
    return true;
  }

  return false;
}

exports InitPlugin;



http://www.freewebs.com/ogremagic/index.htm
Emil_halim
Ziron Beta Tester

avatar

(send private message)

Posts: 639
Topics: 104

Location:
Alex, Egypt
[319] - posted: 2011-11-04 20:53:33

i have tested with ver 1.1.26.1 alpha

it works fine , i will keep playing with Basic syntax.

http://www.freewebs.com/ogremagic/index.htm
Admin
Site Admin

avatar

(send private message)

Posts: 933
Topics: 55

Location:
OverHertz Studio
[320] - posted: 2011-11-04 20:54:24
did you get latest update i sent in PM ?

Download Ziron
Get free hosting for Ziron related fan-sites and Ziron projects, contact me in private message.
Admin
Site Admin

avatar

(send private message)

Posts: 933
Topics: 55

Location:
OverHertz Studio
[321] - posted: 2011-11-04 20:54:47
ok posted too late smile

Download Ziron
Get free hosting for Ziron related fan-sites and Ziron projects, contact me in private message.
Admin
Site Admin

avatar

(send private message)

Posts: 933
Topics: 55

Location:
OverHertz Studio
[322] - posted: 2011-11-04 20:55:25
btw, looking good, i look forward to your progress smile

ps:

Code:
  eax = Ziron_ExpectNextToken(zirDATA_TYPE);
  if (eax == -1) {
    Ziron_FatalError('Expected data type');
    return true;
  }
  edi = Ziron_GetTypeSize();
  


this here can be again getstringvalue, then you can build a buffer to output the ziron syntax 'datatype_str ident_str' via Ziron_Execute('...

Download Ziron
Get free hosting for Ziron related fan-sites and Ziron projects, contact me in private message.
Emil_halim
Ziron Beta Tester

avatar

(send private message)

Posts: 639
Topics: 104

Location:
Alex, Egypt
[323] - posted: 2011-11-04 21:33:48

oh , got access violation.
Code:
function  H_strcpy(Dword dst,src)
{ 
  Eax = dst; 
  Edx = src; 
  push Eax;
  BL =  [Edx]; 
  while ( BL != 0)  
   { 
      [Eax] = BL; 
      Eax++; Edx++; 
      BL =  [Edx]; 
   }  
  [Eax] = 0;
  pop Eax;
} 

function H_strcat(Dword dst,src) 
{ 
  Eax = dst; 
  Edx = src;
  push Eax;
  while (byte [Eax] != 0) { Eax++; } 
  while (byte [Edx] != 0)  
   { 
      BL =  [Edx]; 
      [Eax] = BL;  
      Edx++; Eax++; 
   } 
  [Eax] = 0;
  pop Eax;
} 


function event_Dim() {
    uses edi;  
    char var[255];  
    char buf[1024]; 
       
    eax = Ziron_ExpectNextToken(zirIdent);
    if (eax == -1) {
    Ziron_FatalError('Expected Variable Name');
    return true;
     }
    eax =  Ziron_GetStringValue();
    H_strcpy(@var,eax);
    Ziron_ShowMessage(@var);
         
    eax = Ziron_ExpectNextToken(zirAs);
    if (eax == -1) {
    Ziron_FatalError('Expected as Keyword');
    return true;
     }
    eax = Ziron_ExpectNextToken(zirDATA_TYPE);
    if (eax == -1) {
    Ziron_FatalError('Expected data type');
    return true;
     }
    edi = Ziron_GetTypeSize();
    eax =  Ziron_GetStringValue();
    Ziron_ShowMessage(eax);
    
    H_strcat(@buf,eax); 
    H_strcat(@buf,' ');  
    H_strcat(@buf,@var);
    H_strcat(@buf,';');  
    H_strcat(@buf,'\r\n'); 
    Ziron_ShowMessage(@buf);

    
}



http://www.freewebs.com/ogremagic/index.htm
Pages: 1 2 3
create new reply


Quick reply:

Message:



Currently Active Users:
There are currently 2 user(s) online. 0 member(s) and 2 guest(s)
Most users ever online was 1046, January 28, 2022, 2:08 pm.


Statistics:
Threads: 225 | Posts: 1848 | Members: 51 | Active Members: 51
Welcome to our newest member, yecate
const Copyright = '2011-2024 © OverHertz Ltd. All rights reserved.';
Web development by OverHertz Ltd