A Alessandra Pellegri Active Member Licensed User Longtime User Sep 24, 2018 #1 If I do: Dim a as int May I be sure that a is zero ? And if i do: type myType( a as int ) dim x as myType x.a is always zero? Thank you
If I do: Dim a as int May I be sure that a is zero ? And if i do: type myType( a as int ) dim x as myType x.a is always zero? Thank you
LucaMs Expert Licensed User Longtime User Sep 24, 2018 #2 I think yes (just a very little doubt about "a" in myType). But... you can try spending 2 seconds, using just a simple Log Upvote 0
I think yes (just a very little doubt about "a" in myType). But... you can try spending 2 seconds, using just a simple Log
Daestrum Expert Licensed User Longtime User Sep 24, 2018 #3 The 'a' in the dim statement is not the same as the 'a' in the type statement. If the dim and type statements are in Process_Globals then The type statement creates a java class containing the field named 'a' which is only guaranteed to be 0 after the initialize method is called. Code: Copy public static class _mytype { public boolean IsInitialized; public int a; public void Initialize() { this.IsInitialized = true; this.a = 0; } The dim statement creates a java variable called '_a' which is set to 0. Code: Copy public static int _a = 0; Upvote 0
The 'a' in the dim statement is not the same as the 'a' in the type statement. If the dim and type statements are in Process_Globals then The type statement creates a java class containing the field named 'a' which is only guaranteed to be 0 after the initialize method is called. Code: Copy public static class _mytype { public boolean IsInitialized; public int a; public void Initialize() { this.IsInitialized = true; this.a = 0; } The dim statement creates a java variable called '_a' which is set to 0. Code: Copy public static int _a = 0;
MarkusR Well-Known Member Licensed User Longtime User Sep 24, 2018 #4 erel wrote only b4r did not initialized primitive datatype variables. its also special that u not need to initialize a Type, its automatical. Upvote 0
erel wrote only b4r did not initialized primitive datatype variables. its also special that u not need to initialize a Type, its automatical.
A Alessandra Pellegri Active Member Licensed User Longtime User Sep 25, 2018 #5 Thank you guys. In effect looking at myType.initialize tip: it says that it put all variables to their default value. So for structures isn't automatic, I have to initialize. Upvote 0
Thank you guys. In effect looking at myType.initialize tip: it says that it put all variables to their default value. So for structures isn't automatic, I have to initialize.
MarkusR Well-Known Member Licensed User Longtime User Sep 25, 2018 #6 from generated source code i would agree that u need to use .initialize for a structur class. but for any reason the integer inside have 0 as default value without the usage of initialize. Upvote 0
from generated source code i would agree that u need to use .initialize for a structur class. but for any reason the integer inside have 0 as default value without the usage of initialize.
A Alessandra Pellegri Active Member Licensed User Longtime User Sep 25, 2018 #7 MarkusR said: from generated source code i would agree that u need to use .initialize for a structur class. but for any reason the integer inside have 0 as default value without the usage of initialize. Click to expand... I think that the reason is that when you turn on the PC, all registers are zeros. So if a dram cell isn't still used until that moment, the related variable is zero. But you cannot be sure. Upvote 0
MarkusR said: from generated source code i would agree that u need to use .initialize for a structur class. but for any reason the integer inside have 0 as default value without the usage of initialize. Click to expand... I think that the reason is that when you turn on the PC, all registers are zeros. So if a dram cell isn't still used until that moment, the related variable is zero. But you cannot be sure.