E enonod Well-Known Member Licensed User Longtime User Jan 24, 2013 #1 I have a message that a regular variable must be used with a For/Next loop. I was attempting... Code: Copy Type Fred(c as Byte, r as Byte) Dim cr as Fred For cr.c = 2 to 12 The message is clear but since cr.c can be set with a byte value I don't understand why this is not permitted without having to copy the value to/from another 'regular' variable. Is there a reason for this or just not allowed?
I have a message that a regular variable must be used with a For/Next loop. I was attempting... Code: Copy Type Fred(c as Byte, r as Byte) Dim cr as Fred For cr.c = 2 to 12 The message is clear but since cr.c can be set with a byte value I don't understand why this is not permitted without having to copy the value to/from another 'regular' variable. Is there a reason for this or just not allowed?
mc73 Well-Known Member Licensed User Longtime User Jan 24, 2013 #2 Why would you want to 'for' a type's element? Upvote 0
Erel B4X founder Staff member Licensed User Longtime User Jan 24, 2013 #3 It is a technical limitation related to the way 'for each' is implemented. Upvote 0
E enonod Well-Known Member Licensed User Longtime User Jan 24, 2013 #4 @:Erel. Thank you. @:mc73. I have a subroutine with a parameter as a Type being passed which works fine. I suddenly wish to use the same sub called from elsewhere when I only have available the individual c & r values so to pass them I had to copy them into the individual fields of the Type before passing them. I thought that rather than convert them I would use the Type fields in the first place and save a couple of lines of code. It obviously cannot be done and so back to the original. Upvote 0
@:Erel. Thank you. @:mc73. I have a subroutine with a parameter as a Type being passed which works fine. I suddenly wish to use the same sub called from elsewhere when I only have available the individual c & r values so to pass them I had to copy them into the individual fields of the Type before passing them. I thought that rather than convert them I would use the Type fields in the first place and save a couple of lines of code. It obviously cannot be done and so back to the original.