Register | Login
Forum Index > Requests and Feedback > ZirToken
Author Message
Pages: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
Admin
Site Admin

avatar

(send private message)

Posts: 933
Topics: 55

Location:
OverHertz Studio
[388] - posted: 2011-11-05 21:05:39
ps

Code:
c = ord('A');


i will explain a little about '' and ""

anything inside ' is classed as a literal string and will be passed regardless as size as a pointer to a string, however inside " will be converted do the ordinal, it will accept strings sized 1-4

Code:
c = "A";


another good example is

Code:
eax = "BIG";

char myBuf[4];
myBuf = eax;

print('myBuf = ', @myBuf, '\r\n');


the final byte since there is only 3 will be a 0x00 smile

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
[389] - posted: 2011-11-06 10:13:57

ok , now i found an other problem.

i was trying to support array with dim keyword , something like that
Code:
DIM A3 [1024] AS char


and this is the paresing code
Code:
       /*********   dim k  [1024] as char;    **************/   
      state zirBracketOpen:              
        eax = Ziron_ExpectNextToken(zirNumber);
        if (eax == -1) {
          Ziron_FatalError('Expected max index number of array');
          return true;
        }
        H_strcpy(@tmp,Ziron_GetStringValue());                   
        eax = Ziron_ExpectNextToken(zirBracketClose);
        if (eax == -1) {
          Ziron_FatalError('Expected ]');
          return true;
        }     
        eax = Ziron_ExpectNextToken(zirAs);
        if (eax == -1) {
          Ziron_FatalError('Expected As');
          return true;
        }           
        eax = Ziron_ExpectNextToken(zirDATA_TYPE);
        if (eax == -1) {
          Ziron_FatalError('Expected data type');
          return true;
        }       
        eax =  Ziron_GetStringValue();
        H_strcat(@buf,eax); 
        H_strcat(@buf,' ');  
        H_strcat(@buf,@var);
        H_strcat(@buf,'[');
        H_strcat(@buf,@tmp);
        H_strcat(@buf,']'); 
        H_strcat(@buf,';');  
Ziron_ShowMessage(@buf);
        Len = H_strlen(@buf);          
/*   
        eax = Ziron_Execute(@buf,Len);
        if (eax == false) {
          Ziron_FatalError('Dim plugin is not compatible with this version of Ziron');
          return true;
        }  
*/           
        break;


the problem is the paresing code execute 2 times so it print this
Code:
char A3[1024];
char A3[1024];

and this gave error when compiling.
any help please.

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

avatar

(send private message)

Posts: 933
Topics: 55

Location:
OverHertz Studio
[394] - posted: 2011-11-06 14:48:28
i've just added it to the function i have from your main plugin post

Code:
function event_Dim() {
  uses edi;  
  Dword Len;
  char var[255];  
  char buf[1024]; 
  char tmp[16];
      
  repeat {         
    buf = 0; //make sure buf is initialized otherwise it may be filled with junk
    tmp = 0;
    
    eax = Ziron_ExpectNextToken(zirIdent);
    if (eax == -1) {
      Ziron_FatalError('Expected Variable Name');
      return true;
    }
    
    H_strcpy(@var,Ziron_GetStringValue());   
    Ziron_ShowMessage(@var);
  
    eax = Ziron_GetNextToken();
    //push eax; Ziron_ShowMessage(@var); pop eax;   
  
    case (eax) {
    
      /*********   Dim Var as int32;    **************/         
      state zirAs:
        eax = Ziron_ExpectNextToken(zirDATA_TYPE);
        if (eax == -1) {
          Ziron_FatalError('Expected data type');
          return true;
        }
        eax =  Ziron_GetStringValue();
        H_strcat(@buf,eax); 
        H_strcat(@buf,' ');  
        H_strcat(@buf,@var);
        H_strcat(@buf,';');  

        Len = H_strlen(@buf);          
        eax = Ziron_Execute(@buf,Len);
        if (eax == false) {
          Ziron_FatalError('Dim plugin is not compatible with this version of Ziron');
          return true;
        }  
        break;
        
      /*********   dim k%;    **************/        
      state zirModSym:
        H_strcat(@buf,'int32 '); 
        H_strcat(@buf,@var);
        H_strcat(@buf,';');   

        Len = H_strlen(@buf);          
        eax = Ziron_Execute(@buf,Len);
        if (eax == false) {
          Ziron_FatalError('Dim plugin is not compatible with this version of Ziron');
          return true;
        }
        break;
        
      /*********   dim k$;    **************/              
      state zirDollarSym:
        H_strcat(@buf,'char '); 
        H_strcat(@buf,@var);
        H_strcat(@buf,'[1024];');  

        Len = H_strlen(@buf);          
        eax = Ziron_Execute(@buf,Len);
        if (eax == false) {
          Ziron_FatalError('Dim plugin is not compatible with this version of Ziron');
          return true;
        }
        break;
        
      /*********   dim k!;    **************/          
      state zirExclamation:
        H_strcat(@buf,'single '); 
        H_strcat(@buf,@var);
        H_strcat(@buf,';');  

        Len = H_strlen(@buf);          
        eax = Ziron_Execute(@buf,Len);
        if (eax == false) {
          Ziron_FatalError('Dim plugin is not compatible with this version of Ziron');
          return true;
        }        
        break; 
        
      /*********   dim k#;    **************/          
      state zirHash:
        H_strcat(@buf,'double '); 
        H_strcat(@buf,@var);
        H_strcat(@buf,';');

        Len = H_strlen(@buf);          
        eax = Ziron_Execute(@buf,Len);
        if (eax == false) {
          Ziron_FatalError('Dim plugin is not compatible with this version of Ziron');
          return true;
        }                
        break;  
        
        
      /*********   dim k  [1024] as char;    **************/   
      state zirBracketOpen:              
        eax = Ziron_ExpectNextToken(zirNumber);
        if (eax == -1) {
          Ziron_FatalError('Expected max index number of array');
          return true;
        }
        H_strcpy(@tmp,Ziron_GetStringValue());                   
        eax = Ziron_ExpectNextToken(zirBracketClose);
        if (eax == -1) {
          Ziron_FatalError('Expected ]');
          return true;
        }     
        eax = Ziron_ExpectNextToken(zirAs);
        if (eax == -1) {
          Ziron_FatalError('Expected As');
          return true;
        }           
        eax = Ziron_ExpectNextToken(zirDATA_TYPE);
        if (eax == -1) {
          Ziron_FatalError('Expected data type');
          return true;
        }       
        eax =  Ziron_GetStringValue();
        H_strcat(@buf,eax); 
        H_strcat(@buf,' ');  
        H_strcat(@buf,@var);
        H_strcat(@buf,'[');
        H_strcat(@buf,@tmp);
        H_strcat(@buf,']'); 
        H_strcat(@buf,';');  
        
        Ziron_ShowMessage(@buf);
        
        Len = H_strlen(@buf);          
   
        eax = Ziron_Execute(@buf,Len);
        if (eax == false) {
          Ziron_FatalError('Dim plugin is not compatible with this version of Ziron');
          return true;
        }  
           
        break;        
        
      /*********       **************          
      //state zirIdent:
        //eax = Ziron_GetStringValue();  
        //break;
        
      /*********       **************/            
      default:
        Ziron_FatalError('Expected as Keyword');
        return true;
    }

    eax = Ziron_IsNextLineBreak(); 
    if (eax) {
      break;      // check end of line so we end without semicolon
    } 

    eax = Ziron_PeekNextToken();    
    if (eax == zirCOMMA) {
      Ziron_GetNextToken();
    } else {
      break;
    }
  };
  return true;
}


and it works like a charm, i do not seem any problem, i just tested with

Code:
dim myarr[1024] as char


if you still have a problem, can you paste your whole event code?

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
[395] - posted: 2011-11-06 15:09:05
ok here is the entire function, note i add code to pares \\\'=\\\' and \\\'*\\\'
Code:
function event_Dim() {
    uses edi;  
    Dword Len;
    char var[255];  
    char buf[1024]; 
    char tmp[255];  
  repeat {         
    buf = 0; 
    
    // get the variable name and hold it in Var 
    eax = Ziron_ExpectNextToken(zirIdent);
    if (eax == -1) {
      Ziron_FatalError('Expected Variable Name');
      return true;
    }
    H_strcpy(@var,Ziron_GetStringValue());   
  
    // get whatever after variable name
    eax = Ziron_GetNextToken();
       
    // let's pares it
    // it can be one of those  
    // As % $ ! # [] 
    case (eax) {
      /*********   Dim Var as int32;    **************/         
      state zirAs:
        eax = Ziron_ExpectNextToken(zirDATA_TYPE);
        if (eax == -1) {
          Ziron_FatalError('Expected data type');
          return true;
        }
        eax =  Ziron_GetStringValue();
        H_strcat(@buf,eax); 
        H_strcat(@buf,' ');  
        H_strcat(@buf,@var);
        H_strcat(@buf,';');  
        Len = H_strlen(@buf);          
        eax = Ziron_Execute(@buf,Len);
        if (eax == false) {
          Ziron_FatalError('Dim plugin is not compatible with this version of Ziron');
          return true;
        }  
        break;       
      /*********   dim k%;    **************/        
      state zirModSym:
        H_strcat(@buf,'int32 '); 
        H_strcat(@buf,@var);
        H_strcat(@buf,';');   
        Len = H_strlen(@buf);          
        eax = Ziron_Execute(@buf,Len);
        if (eax == false) {
          Ziron_FatalError('Dim plugin is not compatible with this version of Ziron');
          return true;
        }
        break;    
      /*********   dim k$;    **************/              
      state zirDollarSym:
        buf = 0;
        H_strcat(@buf,'char '); 
        H_strcat(@buf,@var);
        eax = Ziron_PeekNextToken();    
        if (eax == zirMulSym)
         {
             Ziron_GetNextToken(); // remove '*'
             eax = Ziron_ExpectNextToken(zirNumber);
             if (eax == -1) {
                 Ziron_FatalError('Expected number');
                 return true;
              }
             H_strcat(@buf,'[');
             H_strcat(@buf,Ziron_GetStringValue());  
             H_strcat(@buf,'];');     
         }
        else
         {         
           H_strcat(@buf,'[1024];');  
         }      
        Len = H_strlen(@buf);          
        eax = Ziron_Execute(@buf,Len);
        if (eax == false) {
          Ziron_FatalError('Dim plugin is not compatible with this version of Ziron');
          return true;
        }
        break;


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

avatar

(send private message)

Posts: 639
Topics: 104

Location:
Alex, Egypt
[396] - posted: 2011-11-06 15:10:29
sorry , forum refuse to post it in one post

so here is the rest part of function
Code:
      /*********   dim k!;    **************/          
      state zirExclamation:
        H_strcat(@buf,'single '); 
        H_strcat(@buf,@var);
        H_strcat(@buf,';');  
        Len = H_strlen(@buf);          
        eax = Ziron_Execute(@buf,Len);
        if (eax == false) {
          Ziron_FatalError('Dim plugin is not compatible with this version of Ziron');
          return true;
        }        
        break; 
      /*********   dim k#;    **************/          
      state zirHash:
        H_strcat(@buf,'double '); 
        H_strcat(@buf,@var);
        H_strcat(@buf,';');

        Len = H_strlen(@buf);          
        eax = Ziron_Execute(@buf,Len);
        if (eax == false) {
          Ziron_FatalError('Dim plugin is not compatible with this version of Ziron');
          return true;
        }              
        break;  
       /*********   dim k  [1024] as char;    **************/   
      state zirBracketOpen:         
        eax = Ziron_ExpectNextToken(zirNumber);
        if (eax == -1) {
          Ziron_FatalError('Expected max index number of array');
          return true;
        }
        H_strcpy(@tmp,Ziron_GetStringValue());                  
        eax = Ziron_ExpectNextToken(zirBracketClose);
        if (eax == -1) {
          Ziron_FatalError('Expected ]');
          return true;
        }   
        eax = Ziron_ExpectNextToken(zirAs);
        if (eax == -1) {
          Ziron_FatalError('Expected As');
          return true;
        }       
        eax = Ziron_ExpectNextToken(zirDATA_TYPE);
        if (eax == -1) {
          Ziron_FatalError('Expected data type');
          return true;
        }
        eax =  Ziron_GetStringValue();
        H_strcat(@buf,eax); 
        H_strcat(@buf,' ');  
        H_strcat(@buf,@var);
        H_strcat(@buf,'[');
        H_strcat(@buf,@tmp);
        H_strcat(@buf,']'); 
        H_strcat(@buf,';'); 
        Len = H_strlen(@buf);    
        eax = Ziron_Execute(@buf,Len);
        if (eax == false) {
          Ziron_FatalError('Dim plugin is not compatible with this version of Ziron');
          return true;
        }
        
        break;      
      /*********       **************          
      //state zirIdent:
        //eax = Ziron_GetStringValue();  
        //break;
        
      /*********       **************/            
      default:
        Ziron_FatalError('Expected as Keyword');
        return true;
    }
    eax = Ziron_IsNextLineBreak(); 
    if (eax) {
      break;      // check end of line so we end without semicolon
    }   
    eax = Ziron_PeekNextToken();    
    /*********  pares  Assignment '=' **************/ 
    if (eax == zirAssignment)
     {
        Ziron_GetNextToken();
        eax = Ziron_ExpectNextToken(zirNumber);
        if (eax == -1) {
          Ziron_FatalError('Expected max index number of array');
          return true;
        }
        H_strcpy(@tmp,Ziron_GetStringValue());   
        H_strcpy(@buf,@var);  
        H_strcat(@buf,' = '); 
        H_strcat(@buf,@tmp);
        H_strcat(@buf,';'); 
        Len = H_strlen(@buf);    
        eax = Ziron_Execute(@buf,Len);
        if (eax == false) {
          Ziron_FatalError('Dim plugin is not compatible with this version of Ziron');
          return true;
        }       
     }
    if (eax == zirCOMMA) {
      Ziron_GetNextToken();
    } else {
      break;
    }
  };
  return true;
}


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

avatar

(send private message)

Posts: 933
Topics: 55

Location:
OverHertz Studio
[399] - posted: 2011-11-06 17:13:44
I have just compiled that function you posted and it had no compile errors. Can you explain the problem you have when compiling, and can you quote the exact error message you receive?

Thanks.

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
[400] - posted: 2011-11-06 17:58:50

ok , here is the link contained 2 error , one for H_strjoin and the other for the plugin.http://spoilerspace.com//bcxdx/Ziron/basic.zip

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

avatar

(send private message)

Posts: 933
Topics: 55

Location:
OverHertz Studio
[402] - posted: 2011-11-06 18:21:01
hmm, that zip file is corrupt smile

Download Ziron
Get free hosting for Ziron related fan-sites and Ziron projects, contact me in private message.
Pages: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
create new reply


Quick reply:

Message:



Currently Active Users:
There are currently 6 user(s) online. 0 member(s) and 6 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