Hi

In Workshop 3 the following code is provided which calls a function 'compute' from function main(). I want to be able to call a function from a function other than main e.g. replace function main () with something like function resp1 (). When I do this with the code below and call the 'compute' function it will not work. It would seem that you can only call another function from function main (). Would this be correct and if not how do I achieve this?

This is the original code from Workshop 3:

Code:
////////////////////////////////////////////////////////////////////
#include <acknex.h>
#include <default.c>

var my_age = 33;
var days_a_year = 365;
var number_of_days; // we need to calculate this value

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

PANEL* pDisplay =
{
	digits (10, 10, 5, *, 1, number_of_days);
	flags = SHOW;
}

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

 function compute_days()
 {
 	number_of_days = my_age * days_a_year;
}
function main()
{
	screen_color.blue = 150;
	compute_days();
}




If I change the code to what is below it does not work:



Code:
////////////////////////////////////////////////////////////////////
#include <acknex.h>
#include <default.c>

var my_age = 33;
var days_a_year = 365;
var number_of_days; // we need to calculate this value

function resp1();

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

PANEL* pDisplay =
{
	digits (10, 10, 5, *, 1, number_of_days);
	flags = SHOW;
}

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

 function compute_days()
 {
 	number_of_days = my_age * days_a_year;
}
function resp1()
{
	screen_color.blue = 150;
	compute_days();
}



Thanks for your help

Last edited by JustSid; 11/15/12 14:35. Reason: Added code tags