Skip to content

Is it possible to save value of a variable for later use in conditionals? #376

Answered by WerWolv
klei1984 asked this question in Get Help
Discussion options

You must be logged in to vote

Hi! The pattern language does have support for global variables. The only problem your code seems to have is that you're trying to set the global variable inside the struct. To do this, you have to define a function that does it and call that function from inside the struct.

Example:

u8 lastValue;

fn setLastValue(u8 value) {
    lastValue = value;
};

struct Test {
    u8 value;
	
    setLastValue(value);
}; 

Test test[10] @ 0x00;

Hope that helps

Replies: 3 comments

Comment options

You must be logged in to vote
0 replies
Answer selected by klei1984
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants