Page 1 of 1

Combined DATA rows

Posted: Mon Mar 03, 2014 8:31 am
by David.B
My problem is folloving:
2 of data rows groups with 5 number in each row,for example
data 3,5,8,6,2
data 4,2,7,9,4
data5,1,7,9,3
data 6,3,1,4,2,
to be combined with
data 12,15,33,43,45
data 11,18,20,31,35
data 14,16,45,34,89
data 17,19,23,45,57
so that printing will be 16 rows ,all combined with eachather
3 5 8 6 2 12 15 33 43 45
3 5 8 6 2 11 18 20 31 35
e.t.c.
Can somebody help me?
(excuse for my English)
thanks

Re: Combined DATA rows

Posted: Mon Mar 03, 2014 3:28 pm
by burger2227
You can put DATA anywhere in the program and READ each value consecutively or READ specific labeled data fields by using line labels with RESTORE. Only problem is that it starts at the beginning of each field so you may have to read some more than once.

Code: Select all

FOR i = 1 TO 5
  READ dat 'can read first data w/o restore
  PRINT dat;
NEXT
RESTORE datafield2
FOR i = 1 TO 5
  READ dat 'can read second data block with restore
  PRINT dat;
NEXT


datafield1:
DATA 3,5,8,6,2
DATA 4,2,7,9,4
DATA 5,1,7,9,3
DATA 6,3,1,4,2,

'to be combined with
datafield2:
DATA 12,15,33,43,45
DATA 11,18,20,31,35
DATA 14,16,45,34,89
DATA 17,19,23,45,57
I'll let you figure out the rest...

Re: Combined DATA rows

Posted: Thu Mar 06, 2014 12:51 am
by Mentat
Hint: Combining the lines would be easier if you somehow could access the data like an array . . .

Re: Combined DATA rows

Posted: Sat Mar 08, 2014 2:34 pm
by semih
1. group data --> data1.txt
2. group data --> data2.txt

open data1.txt as #1
open data2.txt as #2
open new.txt as #3
do until eof(1) or eof(2)
  line input #1, a$
  line input #2, b$
  c$=a$+b$
  print #3,c$
loop
close

etc