Struct example
Struct_example
#include <io>
#include <read>
#include <float>
#include <string>
#include <core>
#include <write>
#include <define>
#include <socket>
new msg[.text[40], .value] = [''Text'', 1];
new string[20];
main () {
Init(RS232, 9600, WORDLENGTH_8, STOPBITS_1, PARITY_NONE); // Baud rate: 9600, Word length: 8bit, Stop bit: 1, Parity: none
write_buf(RS232, strlen(msg.text), msg.text); // Print string via RS232
snprintf(string, sizeof(string), " msg value : %i\n", msg.value);
write_buf(RS232, strlen(string), string);
strcopy(msg.text, "Your message");
msg.value = 5;
while(1){
write_buf(RS232, strlen(msg.text), msg.text); // Print string via RS232
snprintf(string, sizeof(string), " msg value : %i\n", msg.value);
write_buf(RS232, strlen(string), string);
msg.value++;
Delay(1000);
}
}
/*
Result from RS232:
Text msg value : 1
Your message msg value : 5
Your message msg value : 6
Your message msg value : 7
*/