I am trying to design an algorithm that goes to the previous page with the help of a global variable. However, when I tried to define a variable (let’s say an
int i) I get the following error:
Error:Global variable definitions must precede all code in the program.c:int i;( Double click to jump to code)
I do not understand what’s the error here. Is it about the place of the variable? Then where should I define it. I am using Basic NX4832T035_011. I would love to have any comments.
Hi and welcome @ulasus23!
Since the error says that the placement is wrong I’d answer your question with yes, it is about the place of the variable. However, it’s not about what section/page/… you put it into, but about where you put it_within_ the Program.s section. You haven’t shown us your Program.s file so we can only make guesses about what it looks like. I suggest you put all your global variables at the top and everything else (assignments, if/else, loops, print commands, other commands, …) below. Following the error message that seems to be what the editor expects and requires.
I could not solve the problem, I was assigning variables inside the event command area, but I believe it wanted me to assign to Program.s as you said. Thanks for your help.
You need to place your code before page 0 command.
in original it is
your version can be like