Home AMX User Forum AMX General Discussion

Quick Quiz

Here is a little pop quiz I'm throwing out because
A. I'm feeling nostalgic
B. I'm trying a help out some of the newer coders think like the compiler, and I am choosing this format to accomplish it :)

Given this bit of code:
define_constant
NUMBER_OF_TOUCHPANELS = 10;

define_variable
integer nOverviewMode[NUMBER_OF_TOUCHPANELS] = {1,2,3,1,2,3,4,1,4,1};
integer nAdminMode[NUMBER_OF_TOUCHPANELS] = {0,1,0,0,0,0,0,0,0,0,0}
.
.
.
define_function integer getAdminMode(integer nTpIndex){
	return nAdminMode[nTpIndex];
}

define_function integer getOverviewMode(integer nTpIndex){
    stack_var integer nResult;
	if(nTpIndex >0 and nTpIndex <= NUMBER_OF_TOUCHPANELS)
		if(getAdminMode(nTpIndex))
		    nResult = nOverviewMode[nTpIndex];
	else {
		debug("'Invalid Touch panel index pointer in getOverviewMode function'",DEBUG_WARNING);
		nResult =  99;
	}
        return nResult;
}

What would be the result of the following:
  send_string 0,"'Overview Mode: ',itoa(getOverviewMode(1),' - ', itoa(getOverviewMode(2),' - ',itoa(getOverviewMode(13)";



I invite everyone to play along, and I will post an explanation in a day or two.

Jeff

P.S.
I forgot that I am operating under the assumption that stack_vars are initialized to 0 when created.
Failed to load the poll.
Failed to load the poll.
Sign In or Register to comment.