Skip to content
Low-level programming · Higher-level thinking
Login Register
Forum / Source Help

H_join Error

A community discussion post from the original code:zIRON forum.

Emil_halim member
Posts
639
Threads
104
Location
Alex, Egypt

H_join Error

Hi

i have made a simple macro to make thing is more easy , but got access violation

here is the macro

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;
} 

inline procedure  H_join(;)
{
  $temp = 1;
  $repeat $argc:	
     H_strcat($arg[0],$arg[$temp]);  
  $temp++;
  $end
}

and here is the calling that make the error

H_join(@buf,eax,' ',@var,';');

any help please?

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

Replies

Colin admin
Posts
928
Threads
49
Location
Bulgaria

because you are repeating still the amount of args that exist

$repeat $argc:

try:

inline procedure  H_join(;)
{
  $temp = 1;
  $to = $argc-1;  //minus the first argument
  $repeat $to:  
    H_strcat($arg[0],$arg[$temp]);  
    $temp++;
  $end
}
Emil_halim member
Posts
639
Threads
104
Location
Alex, Egypt

i do as you said , but have this error

Invalid macro variable casting

H_strcat($arg[0],$arg[$temp]); 

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

Colin admin
Posts
928
Threads
49
Location
Bulgaria

I have just compiled this

program WIN32CUI 'test';

#include 'ch.zir';

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;
} 

inline procedure  H_join(;)
{
	$temp = 1;
	$to = $argc-1;
	$repeat $to:  
		H_strcat($arg[0],$arg[$temp]);  
		$temp++;
	$end
}


wait_key(nil);
ExitProcess(0);

and it compiled without an error, can you try this ^ sample to see if it compiles.

Emil_halim member
Posts
639
Threads
104
Location
Alex, Egypt

i have already post the error of this with Basic.zip file.

any way this refused to compile

program WIN32CUI 'test';

#include 'console.zir';
#include 'ch.zir';

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;
} 

inline procedure  H_join(;)
{
  $temp = 1;
  $to = $argc-1;
  $repeat $to:  
    H_strcat($arg[0],$arg[$temp]);  
    $temp++;
  $end
}

char tmp[1048];

H_join(@tmp , 'Emil', ' ', 'Halim');
print(@tmp);

wait_key(nil);
ExitProcess(0);

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

Colin admin
Posts
928
Threads
49
Location
Bulgaria

ok i see it has to do with the call, i will look into this now :)

Colin admin
Posts
928
Threads
49
Location
Bulgaria

ok i have re-uploaded a temporary fix, i need to spend some more time working on the macro engine - it needs a-lot of work, but this will fix it for now :)