the goal is to collect similar sets of data in a common structure, so that they can be easily processed in a for-next-loop. This should be done with a multi dimensional array.
I think thats not very unusual, right?
The sets of data could be quite long, so the declaration of an complete array constant would quickly result in more than 1000 characters per line ... not to talk about the readability. So the array must be filled step by step.
Sadly I've found no nondestructive way to copy a 1-dimensional array as a whole into a 2-dimensional array until now. Loop controlled copy of single elements not considered.
How to handle subarrays is shortly described in the X11-Basic Manual (v 1.24), but unfortunately only in reverse direction (copy parts of a multi-dimensional array into a 1-dimensonal array). However, I've tried to use the subarray (:) operator.
I've reduced the problem as follows (3 lines of code):
a()=[301,402]
b()=[55,77]
c()=[1,2;3,4]
... and tried as 4th line:
c()=b()
c(:)=b()
c(0,0)=b() --- error
c(0,:)=b()
c(:,0)=b()
c(1,:)=b()
c(0,1:)=b()
c(,:)=b()
c(:1,)=b()
c(:0,)=b()
c(:,1)=b()
c(:1,0)=b()
c(:,)=b()
c(:1)=b()
As a result curiously the whole array c() will be overwritten with the following data:
c(0,0) - 55
c(0,1) - 55
c(1,0) - 77
c(1,1) - 77
It seems as if nearly everything between the parantheses on the left side will be ignored and the interpreter executes "c()=b()" always. That was not intended.
I can't believe there is no other way than to copy single element by element. How to solve this problem?
Thank you for any help.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
(sorry, the content of introducing posting was dropped)
Hello,
the goal is to collect similar sets of data in a common structure, so that they can be easily processed in a for-next-loop. This should be done with a multi dimensional array.
I think thats not very unusual, right?
The sets of data could be quite long, so the declaration of an complete array constant would quickly result in more than 1000 characters per line ... not to talk about the readability. So the array must be filled step by step.
Sadly I've found no non-destructive way to copy a 1-dimensional array as a whole into a 2-dimensional array until now. Loop controlled copy of single elements not considered.
How to handle subarrays is shortly described in the X11-Basic Manual (v 1.24), but unfortunatly only in reverse direction (copy parts of a multi-dimensional array into a 1-dimensonal array). However, I've tried to use the subarray (:) operator.
I've reduced the problem as follows (3 lines of code):
As a result curiously the whole array c() will be overwritten with the following data:
c(0,0) - 55
c(0,1) - 55
c(1,0) - 77
c(1,1) - 77
It seems as if nearly everything between the parantheses on the left side will be ignored and the interpreter executes "c()=b()" always. That was not intended.
I can't believe there is no other way than to copy single element by element. How to solve this problem?
Thank you for any help.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
View and moderate all "Help" comments posted by this user
Mark all as spam, and block user from posting to "Discussion"
Hello,
the goal is to collect similar sets of data in a common structure, so that they can be easily processed in a for-next-loop. This should be done with a multi dimensional array.
I think thats not very unusual, right?
The sets of data could be quite long, so the declaration of an complete array constant would quickly result in more than 1000 characters per line ... not to talk about the readability. So the array must be filled step by step.
Sadly I've found no nondestructive way to copy a 1-dimensional array as a whole into a 2-dimensional array until now. Loop controlled copy of single elements not considered.
How to handle subarrays is shortly described in the X11-Basic Manual (v 1.24), but unfortunately only in reverse direction (copy parts of a multi-dimensional array into a 1-dimensonal array). However, I've tried to use the subarray (:) operator.
I've reduced the problem as follows (3 lines of code):
a()=[301,402]
b()=[55,77]
c()=[1,2;3,4]
... and tried as 4th line:
c()=b()
c(:)=b()
c(0,0)=b() --- error
c(0,:)=b()
c(:,0)=b()
c(1,:)=b()
c(0,1:)=b()
c(,:)=b()
c(:1,)=b()
c(:0,)=b()
c(:,1)=b()
c(:1,0)=b()
c(:,)=b()
c(:1)=b()
As a result curiously the whole array c() will be overwritten with the following data:
c(0,0) - 55
c(0,1) - 55
c(1,0) - 77
c(1,1) - 77
It seems as if nearly everything between the parantheses on the left side will be ignored and the interpreter executes "c()=b()" always. That was not intended.
I can't believe there is no other way than to copy single element by element. How to solve this problem?
Thank you for any help.
View and moderate all "Help" comments posted by this user
Mark all as spam, and block user from posting to "Discussion"
(sorry, the content of introducing posting was dropped)
Hello,
the goal is to collect similar sets of data in a common structure, so that they can be easily processed in a for-next-loop. This should be done with a multi dimensional array.
I think thats not very unusual, right?
The sets of data could be quite long, so the declaration of an complete array constant would quickly result in more than 1000 characters per line ... not to talk about the readability. So the array must be filled step by step.
Sadly I've found no non-destructive way to copy a 1-dimensional array as a whole into a 2-dimensional array until now. Loop controlled copy of single elements not considered.
How to handle subarrays is shortly described in the X11-Basic Manual (v 1.24), but unfortunatly only in reverse direction (copy parts of a multi-dimensional array into a 1-dimensonal array). However, I've tried to use the subarray (:) operator.
I've reduced the problem as follows (3 lines of code):
... and tried as 4th line:
As a result curiously the whole array c() will be overwritten with the following data:
It seems as if nearly everything between the parantheses on the left side will be ignored and the interpreter executes "c()=b()" always. That was not intended.
I can't believe there is no other way than to copy single element by element. How to solve this problem?
Thank you for any help.
There was indeed a bug in X11-Basic. I have fixed it. It should work in the new release 1.23-34 of X11-basic. Thanks for mentioning!