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\summary\update.txt" OPEN outfile$ FOR OUTPUT AS fileout% PRINT #fileout%, " B-Factory Magnetic Measurement Test Update" PRINT #fileout%, "" PRINT #fileout%, USING " &"; asof$ PRINT #fileout%, "" PRINT #fileout%, USING " Total Magnets Tested: ###"; n% FOR i% = 1 TO 5 PRINT #fileout%, "" NEXT PRINT #fileout%, " Magnets Tested to Date" PRINT #fileout%, "" PRINT #fileout%, " "; FOR i% = 1 TO n% PRINT #fileout%, USING " &"; MID$(rtsort$(i%), 1, 3); IF i% MOD 10 = 0 THEN PRINT #fileout%, " " PRINT #fileout%, " "; END IF NEXT 'PRINT #fileout%, CHR$(12) FOR i% = 1 TO 5 PRINT #fileout%, "" NEXT PRINT #fileout%, " Test Summary Update: Sorted by Date" PRINT #fileout%, " " 'Print quick summary sorted by date PRINT #fileout%, " Date Mag Res Cur Ratio Int Bdl Tran Fun" PRINT #fileout%, " # (mOhm) (amps) VTXC/VTR (Tm) (Tm/kA)" PRINT #fileout%, " " FOR i% = 1 TO n% mg$ = MID$(rt$(i%), 1, 3) dy$ = MID$(rt$(i%), 12, 8) 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 " & & & & & & &"; dy$; mg$; rs$; cr$; rat$; bl$; tf$ NEXT CLOSE fileout% SHELL "type c:\philr\bfact\summary\update.txt | more" END SUB GetHAR (har$(), harsort$(), m%) 'Read information from file RTSUM.TXT filein% = FREEFILE infile$ = "c:\philr\bfact\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\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