beautypg.com

Appendix b. data conversion computer program – Campbell Scientific DCP100 GOES Data Collection Platform User Manual

Page 27

background image

B-1

APPENDIX B. DATA CONVERSION COMPUTER PROGRAM

(WRITTEN IN BASIC)

1

REM THIS PROGRAM CONVERTS 3-BYTE ASCII DATA INTO DECIMAL

5

INPUT "RECEIVE FILE?", RF$

6

OPEN RF$ FOR OUTPUT AS #2

10

INPUT "NAME OF FILE CONTAINING GOES DATA"; NFL$

20

DIM DV$(200)

25

WIDTH "LPT1:", 120

30

OPEN NFL$ FOR INPUT AS #1

40

WHILE NOT EOF(1)

50

LINE INPUT #1, A$

55

A$ = MID$(A$, 38)

56

PRINT A$

100

J = INT(LEN(A$) / 3)

105

PRINT J

110

FOR I = 1 TO J

120

DV$(I) = MID$(A$, 3 * I - 2, 3)

130

NEXT I

140

B$ = RIGHT$(A$, LEN(A$) - 3 * J)

160

A$ = B$ + A$

170

K = INT(LEN(A$) / 3)

180

L = J

190

FOR I = J + 1 TO L

200

DV$(I) = MID$(A$, 3 * (I - J) - 2, 3)

210

NEXT I

270

FOR I = 1 TO L

280

A = ASC(LEFT$(DV$(I), 1)) AND 15

290

B = ASC(MID$(DV$(I), 2, 1)) AND 63

300

C = ASC(RIGHT$(DV$(I), 1)) AND 63

310

IF (A * 64) + B >= 1008 THEN DV = (B - 48) * 64 + C + 9000: GOTO 400

320

IF A AND 8 THEN SF = -1 ELSE SF = 1

330

IF A AND 4 THEN SF = SF * .01

340

IF A AND 2 THEN SF = SF * .1

350

IF A AND 1 THEN DV = 4096

360

DV = (DV + ((B AND 63) * 64) + (C AND 63)) * SF

400

PRINT #2, USING "####.### "; DV;

405

IF I MOD 17 = 0 THEN PRINT #2, CHR$(13)

406

DV = 0

410

NEXT I

1000

WEND