DECLARE SUB GetRT (rt$(), rtsort$(), n%) DECLARE SUB GetHAR (har$(), harsort$(), m%) 'UPDATE: Program which updates the magnetic measurements to date. ' 'Phil Radusewicz 8/31/94 DIM rt$(1 TO 210), rtsort$(1 TO 210) DIM har$(1 TO 210), harsort$(1 TO 210) CALL GetRT(rt$(), rtsort$(), n%) CALL GetHAR(har$(), harsort$(), m%) asof$ = MID$(rt$(n%), 12, 8) IF n% <> m% THEN PRINT "There is a mismatch in the magnet count between files RTSUM.TXT and HARSUM.TXT" END END IF 'Create output update file of magnet testing to date fileout% = FREEFILE outfile$ = "c:\philr\bfact\dipole\summary\database.txt" OPEN outfile$ FOR OUTPUT AS fileout% 'Print quick summary sorted by date FOR i% = 1 TO n% mg$ = MID$(rt$(i%), 1, 3) rn$ = MID$(rt$(i%), 6, 1) ts$ = MID$(rt$(i%), 9, 1) dy$ = MID$(rt$(i%), 12, 8) tm$ = MID$(rt$(i%), 21, 5) rs$ = MID$(rt$(i%), 41, 5) cr$ = MID$(har$(i%), 28, 6) rat$ = MID$(har$(i%), 53, 7) bl$ = MID$(har$(i%), 61, 7) tf$ = MID$(har$(i%), 69, 7) PRINT #fileout%, USING "PEP-II HER,&,&,&,&,&,&,&,&,&,&"; dy$; tm$; mg$; rn$; ts$; cr$; rs$; rat$; bl$; tf$ NEXT CLOSE fileout% SHELL "type c:\philr\bfact\dipole\summary\database.txt | more" END SUB GetHAR (har$(), harsort$(), m%) 'Read information from file RTSUM.TXT filein% = FREEFILE infile$ = "c:\philr\bfact\dipole\summary\harsum.txt" OPEN infile$ FOR INPUT AS filein% FOR i = 1 TO 6 LINE INPUT #filein%, temp$ NEXT m% = 0 WHILE NOT EOF(filein%) m% = m% + 1 LINE INPUT #filein%, har$(m%) harsort$(m%) = har$(m%) WEND CLOSE filein% 'Sort magnet numbers: CONST FALSE = 0, TRUE = -1 Exchange = TRUE 'Force first pass through the array. WHILE Exchange 'Sort until no elements are exchanged. Exchange = FALSE 'Compare the array elements by pairs. When two are exchanged, 'force another pass by setting Exchange to TRUE. FOR i = 2 TO m% IF harsort$(i - 1) > harsort$(i) THEN Exchange = TRUE SWAP harsort$(i - 1), harsort$(i) END IF NEXT WEND END SUB SUB GetRT (rt$(), rtsort$(), n%) 'Read information from file RTSUM.TXT filein% = FREEFILE infile$ = "c:\philr\bfact\dipole\summary\rtsum.txt" OPEN infile$ FOR INPUT AS filein% FOR i = 1 TO 6 LINE INPUT #filein%, temp$ NEXT n% = 0 WHILE NOT EOF(filein%) n% = n% + 1 LINE INPUT #filein%, rt$(n%) rtsort$(n%) = rt$(n%) WEND CLOSE filein% 'Sort magnet numbers: CONST FALSE = 0, TRUE = -1 Exchange = TRUE 'Force first pass through the array. WHILE Exchange 'Sort until no elements are exchanged. Exchange = FALSE 'Compare the array elements by pairs. When two are exchanged, 'force another pass by setting Exchange to TRUE. FOR i = 2 TO n% IF rtsort$(i - 1) > rtsort$(i) THEN Exchange = TRUE SWAP rtsort$(i - 1), rtsort$(i) END IF NEXT WEND END SUB