el andy New Member Licensed User Longtime User Apr 6, 2018 #1 Hi when I try this (ESP32): Sub Process_Globals Type Type_Sys1(Serial1 As Serial) Public Sys1 As Type_Sys1 End Sub Private Sub AppStart Sys1.Serial1.Initialize(115200) Log("AppStart") End Sub I get a lot of errors when I run this code. Why ? Regards, el Andy (Sorry my english is not good)
Hi when I try this (ESP32): Sub Process_Globals Type Type_Sys1(Serial1 As Serial) Public Sys1 As Type_Sys1 End Sub Private Sub AppStart Sys1.Serial1.Initialize(115200) Log("AppStart") End Sub I get a lot of errors when I run this code. Why ? Regards, el Andy (Sorry my english is not good)
tigrot Well-Known Member Licensed User Longtime User Apr 7, 2018 #2 Can you show the errors? Mauro Upvote 0
el andy New Member Licensed User Longtime User Apr 7, 2018 #3 Hi Mauro, here the errors. Last edited: Apr 7, 2018 Upvote 0
el andy New Member Licensed User Longtime User Apr 7, 2018 #4 Hi Mauro, this is the standard way to do it, but i like to use structures, el Andy Last edited: Apr 7, 2018 Upvote 0
Erel B4X founder Staff member Licensed User Longtime User Apr 8, 2018 #5 1. Please use [code]code here...[/code] tags when posting code. 2. Post error and code as text, not screenshots. This code will work: Code: Copy Sub Process_Globals Type Type_Sys1(serial1 As Serial) Public Sys1 As Type_Sys1 Private serial As Serial End Sub Private Sub AppStart Sys1.serial1 = serial Sys1.serial1.Initialize(115200) Log("AppStart") End Sub Sys1.serial is a pointer to a Serial object. When you declared Sys1 as a global variable, the compiler only allocated the memory required for the structure. It didn't create a Serial object (it can't). So the only way to use custom types with non-numeric fields is by assigning them yourself in the code above. Upvote 0
1. Please use [code]code here...[/code] tags when posting code. 2. Post error and code as text, not screenshots. This code will work: Code: Copy Sub Process_Globals Type Type_Sys1(serial1 As Serial) Public Sys1 As Type_Sys1 Private serial As Serial End Sub Private Sub AppStart Sys1.serial1 = serial Sys1.serial1.Initialize(115200) Log("AppStart") End Sub Sys1.serial is a pointer to a Serial object. When you declared Sys1 as a global variable, the compiler only allocated the memory required for the structure. It didn't create a Serial object (it can't). So the only way to use custom types with non-numeric fields is by assigning them yourself in the code above.
el andy New Member Licensed User Longtime User Apr 8, 2018 #6 Muchas gracias Mauro and Erel for your reply. Last edited: Apr 9, 2018 Upvote 0