Page 1 of 1

RESTORE TO command

Posted: Thu Aug 06, 2015 12:37 am
by the_wesley_watkins
Could someone give me an example of how to use the RESTORE TO LABEL command?

I am trying to read in data from another file, so I setup labels within the file that has my data. It looks sort of like:

temps:
DATA dsfasdf
DATA dasdfa
DATA dasfasd

meds:
DATA dfasdf
DATA dasfsad



Here is the code I use to read in the data:

Code: Select all

numtemps = 0
WHILE 1=1
	READ hold$
	numtemps += 1
	IF hold$ = "201508030555*temp*98.6" THEN BREAK   'Breaks at the last temp
END WHILE

DIM holder$(200)
DIM tempstr$(numtemps)
DIM temp(5, numtemps)
DIM tempyrstr$(numtemps)
DIM tempyr(5, numtemps)
DIM tempmstr$(numtemps)
DIM tempm(5, numtemps)
DIM tempdstr$(numtemps)
DIM tempd(5, numtemps)
DIM temphrstr$(numtemps)
DIM temphr(5, numtemps)
DIM tempminstr$(numtemps)
DIM tempmin(5, numtemps)



RESTORE TO temps



FOR counter = 1 TO numtemps STEP 1
	READ hold$
	IF LEN(hold$) = 22 THEN
		tempstr$(counter) = SUBSTR$(hold$, 19, 22)
		temp(1, counter) = VAL(tempstr$(counter))
	ELSE
		tempstr$(counter) = SUBSTR$(hold$, 19, 23)
		temp(1, counter) = VAL(tempstr$(counter))
	END IF

	tempyrstr$(counter) = SUBSTR$(hold$, 1, 4)
	tempyr(1, counter) = VAL(tempyrstr$(counter))

	tempmstr$(counter) = SUBSTR$(hold$, 5, 6)
	tempm(1, counter) = VAL(tempmstr$(counter))

	tempdstr$(counter) = SUBSTR$(hold$, 7, 8)
	tempd(1, counter) = VAL(tempdstr$(counter))
	
	temphrstr$(counter) = SUBSTR$(hold$, 9, 10)
	temphr(1, counter) = VAL(temphrstr$(counter))

	tempminstr$(counter) = SUBSTR$(hold$, 11, 12)
	tempmin(1, counter) = VAL(tempminstr$(counter))

NEXT counter

Re: RESTORE TO command

Posted: Thu Aug 06, 2015 1:24 am
by Mr. Kibernetik
RESTORE TO is not for reading data from some file. It is similar to Basic RESTORE command:

Code: Select all

RESTORE TO lab
READ a
PRINT a
DATA 1
lab:
DATA 2

Re: RESTORE TO command

Posted: Thu Aug 06, 2015 1:53 am
by the_wesley_watkins
Can you use multiple RESTORE TO commands with multiple labels?

Re: RESTORE TO command

Posted: Thu Aug 06, 2015 4:55 am
by Mr. Kibernetik
Yes.