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

Ziron_GetStringValue Eaxmple

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

Replies

Colin admin
Posts
928
Threads
49
Location
Bulgaria

no problem, i am happy to help :)

Colin admin
Posts
928
Threads
49
Location
Bulgaria

your function that i tested with just now

function event_Dim() {
	char var[255];  
	char buf[1024]; 
	buf = 0; //make sure buf is initialized otherwise it may be filled with junk
       
	eax = Ziron_ExpectNextToken(zirIdent);
	if (eax == -1) {
		Ziron_FatalError('Expected Variable Name');
		return true;
	}
    
	H_strcpy(@var,Ziron_GetStringValue()); 
         
	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;
	}
	eax = Ziron_GetStringValue();

	strAppend(@buf,eax,1023);
	if (eax == false) {
		Ziron_FatalError('strAppend failed\r\n');
	}
	strAppend(@buf,' ',1023);
	if (eax == false) {
		Ziron_FatalError('strAppend failed\r\n');
	}
	strAppend(@buf,@var,1023);
	if (eax == false) {
		Ziron_FatalError('strAppend failed\r\n');
	}
	strAppend(@buf,';',1023);
	if (eax == false) {
		Ziron_FatalError('strAppend failed\r\n');
	}
        
	Ziron_Execute(@buf, strLen(@buf));
  
	return true;
}
Emil_halim member
Posts
639
Threads
104
Location
Alex, Egypt

yes , and here is a test program , works as expected.

program WIN32CUI 'test';

#include 'console.zir';

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

Dim Var as int32;

Var = 1000;

print('Var = ', Var, '\r\n');

wait_key(nil);
ExitProcess(0);

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

Colin admin
Posts
928
Threads
49
Location
Bulgaria

note that if you want to enforce the semi colon ";" you will also need to do a expectNextToken, however in such case i don't think it is required, usually enforcement of semi colon is only useful when there is several different uses of a keyword, e.g. for mov opcode,

anyways, looking good, look forward to see what else you add :)

Emil_halim member
Posts
639
Threads
104
Location
Alex, Egypt

ok , i got it.

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