' ' Weather - Filter input file from DUAT into better readable format ' V1.0 - Written by Stephen W. Nolen ' V2.0 - 11/16/93 - Rewrote Beta to use command line options ' v3.0 - 11/30/96 - Rewrote to use FTP data for home automation announcement ' v3.1 - 01/06/97 - Cleaned up and commented for online viewing ' DECLARE SUB Comline (NumArgs!, Args$(), MaxArgs!, Sub$) ON ERROR GOTO ProError Program$ = "WEATH.EXE" Version$ = "v3.1" Desc$ = "NWS Weather Filter System" Divider$ = STRING$(72, "-") CopyRight$ = "Copyright(c) 1993-97 Stephen W. Nolen, ProtoWrxs!" '-------- Get config file from command line DIM A$(8), L$(25) 'up to five parameters CALL Comline(Args, A$(), 8, COMMAND$) 'get command line TRUE = -1: FALSE = 0 'setup TRUE/FALSE const 'Flags used to control formatting LongLine = FALSE Extended = FALSE Filter = FALSE Current = FALSE UpCase = FALSE FOR Cnt = 1 TO 8: A$(Cnt) = UCASE$(A$(Cnt)): NEXT Cnt 'This is used IF you want to try to make long lines for each forecast line IF A$(3) = "/L" OR A$(4) = "/L" OR A$(5) = "/L" OR A$(6) = "/L" OR A$(7) = "/L" THEN LongLine = TRUE IF A$(3) = "/E" OR A$(4) = "/E" OR A$(5) = "/E" OR A$(6) = "/E" OR A$(7) = "/E" THEN Extended = TRUE IF A$(3) = "/F" OR A$(4) = "/F" OR A$(5) = "/F" OR A$(6) = "/F" OR A$(7) = "/F" THEN Filter = TRUE IF A$(3) = "/C" OR A$(4) = "/C" OR A$(5) = "/C" OR A$(6) = "/C" OR A$(7) = "/C" THEN Current = TRUE IF A$(3) = "/U" OR A$(4) = "/U" OR A$(5) = "/U" OR A$(6) = "/U" OR A$(7) = "/U" THEN UpCase = TRUE CLS PRINT Program$ + " - " + Version$ + " " + Desc$ PRINT CopyRight$ PRINT Divider$ IF Args < 2 THEN GOTO BadParms ' Open up In/Out files OPEN A$(1) FOR INPUT AS #1 OPEN A$(2) FOR OUTPUT AS #2 ' Skip first line since is *should* be blank LOOP1: LINE INPUT #1, A$ IF LEN(RTRIM$(A$)) = 0 GOTO LOOP1 ' For future filtering of words SBTalker has problems with GOSUB FilterIt ' Print the header information GOSUB PrintA GOSUB PrintCR 'If current flag is up then eat one line and setup current conditions IF NOT Current GOTO Loop2 LINE INPUT #1, A$ 'This *should* be the header for current conditions LINE INPUT #1, A$ 'This *should* be a line of equal signs LINE INPUT #1, A$ 'This is our baby so break it up X$ = A$ A$ = "CURRENT CONDITIONS:" GOSUB FilterIt: A$ = UCASE$(A$): GOSUB PrintA: GOSUB PrintCR A$ = "TEMPERATURE WAS " + LTRIM$(RTRIM$(MID$(X$, 2, 5))) + " DEGREES" GOSUB FilterIt: A$ = UCASE$(A$): GOSUB PrintA: GOSUB PrintCR A$ = "HUMIDTY WAS " + LTRIM$(RTRIM$(MID$(X$, 15, 3))) + " PERCENT" GOSUB FilterIt: A$ = UCASE$(A$): GOSUB PrintA: GOSUB PrintCR A$ = "WIND CONDITIONS WERE " + LTRIM$(RTRIM$(MID$(X$, 26, 15))) + " M P H" GOSUB FilterIt: A$ = UCASE$(A$): GOSUB PrintA: GOSUB PrintCR A$ = "GENERAL CONDITION WAS " + LTRIM$(RTRIM$(MID$(X$, 54, 15))) GOSUB FilterIt: A$ = UCASE$(A$): GOSUB PrintA: GOSUB PrintCR ' Main Loop - Looks for *todays* information and then goes to next loop ' Here we are looking for the trigger word(s) for current forecast Loop2: LINE INPUT #1, A$ IF INSTR(A$, "TONIGHT") GOTO Begin IF INSTR(A$, "TODAY") GOTO Begin IF INSTR(A$, "THIS EVENING") GOTO Begin IF INSTR(A$, "THIS AFTERNOON") GOTO Begin IF INSTR(A$, "CHRISTMAS") GOTO Begin IF INSTR(A$, "NEW YEARS") GOTO Begin GOTO Loop2 'Okay... this *should* be the current forecast and it *should* 'follow through to the next blank line... *usually* Begin: GOSUB PrintA GOSUB PrintIt Extend: IF NOT Extended GOTO Endit IF EOF(1) GOTO Endit LINE INPUT #1, A$ IF INSTR(A$, "EXTENDED") = 0 THEN GOTO Extend GOSUB PrintCR GOSUB PrintA GOSUB PrintIt Endit: CLOSE 1 CLOSE 2 END 'FUTURE! 'This routine filters our special words that SBTalker cannot handle 'and converts the to something it can. FilterIt: IF NOT Filter THEN RETURN 'Filter the months to full name X1$ = " jan ": X2$ = " january ": GOSUB FilterIt2 X1$ = " feb ": X2$ = " february ": GOSUB FilterIt2 X1$ = " mar ": X2$ = " march ": GOSUB FilterIt2 X1$ = " apr ": X2$ = " april ": GOSUB FilterIt2 X1$ = " may ": X2$ = " may ": GOSUB FilterIt2 X1$ = " jun ": X2$ = " june ": GOSUB FilterIt2 X1$ = " jul ": X2$ = " july ": GOSUB FilterIt2 X1$ = " aug ": X2$ = " august ": GOSUB FilterIt2 X1$ = " sep ": X2$ = " september ": GOSUB FilterIt2 X1$ = " oct ": X2$ = " october ": GOSUB FilterIt2 X1$ = " nov ": X2$ = " november ": GOSUB FilterIt2 X1$ = " dec ": X2$ = " december ": GOSUB FilterIt2 'Filter to time zones to full text X1$ = " cst ": X2$ = " central standard time ": GOSUB FilterIt2 X1$ = " est ": X2$ = " eastern standard time ": GOSUB FilterIt2 X1$ = " mst ": X2$ = " moutain standard time ": GOSUB FilterIt2 X1$ = " pst ": X2$ = " pacific standard time ": GOSUB FilterIt2 X1$ = " cdt ": X2$ = " central daylight time ": GOSUB FilterIt2 X1$ = " edt ": X2$ = " eastern daylight time ": GOSUB FilterIt2 X1$ = " mdt ": X2$ = " moutain daylight time ": GOSUB FilterIt2 X1$ = " pdt ": X2$ = " pacific daylight time ": GOSUB FilterIt2 'Various wind direction possiblities X1$ = " NNW ": X2$ = " NORTH NORTH WEST ": GOSUB FilterIt2 X1$ = " NNE ": X2$ = " NORTH NORTH EAST ": GOSUB FilterIt2 X1$ = " NW ": X2$ = " NORTH WEST ": GOSUB FilterIt2 X1$ = " NE ": X2$ = " NORTH EAST ": GOSUB FilterIt2 X1$ = " W ": X2$ = " WEST ": GOSUB FilterIt2 X1$ = " E ": X2$ = " EAST ": GOSUB FilterIt2 X1$ = " S ": X2$ = " SOUTH ": GOSUB FilterIt2 X1$ = " N ": X2$ = " NORTH ": GOSUB FilterIt2 X1$ = " SSW ": X2$ = " SOUTH SOUTH WEST ": GOSUB FilterIt2 X1$ = " SSE ": X2$ = " SOUTH SOUTH EAST ": GOSUB FilterIt2 X1$ = " SW ": X2$ = " SOUTH WEST ": GOSUB FilterIt2 X1$ = " SE ": X2$ = " SOUTH EAST ": GOSUB FilterIt2 'Time factors X1$ = " AM ": X2$ = " AY M ": GOSUB FilterIt2 X1$ = " PM ": X2$ = " P M ": GOSUB FilterIt2 'Fix any other words it has problems with X1$ = "MOSTLY": X2$ = "MOWSTLY": GOSUB FilterIt2 X1$ = "FORECAST": X2$ = "4CAST": GOSUB FilterIt2 RETURN FilterIt2: Y1$ = UCASE$(A$) Y2$ = UCASE$(X1$) IF INSTR(Y1$, Y2$) = 0 THEN RETURN Sloc = INSTR(Y1$, Y2$) Z$ = LEFT$(A$, Sloc - 1) + X2$ + RIGHT$(A$, LEN(A$) - Sloc - LEN(X1$) + 1) A$ = Z$ RETURN PrintIt: ' Now get lines until next blank one LoopBack: LINE INPUT #1, A$ IF LEN(LTRIM$(A$)) = 0 THEN RETURN GOSUB FilterIt IF LongLine THEN IF LEFT$(A$, 1) = " " THEN GOSUB PrintCR ELSE GOSUB PrintNoCR END IF ELSE GOSUB PrintCR END IF GOSUB PrintA GOTO LoopBack RETURN 'Print A$ Subroutine PrintA: IF UpCase THEN PRINT #2, UCASE$(A$); PRINT UCASE$(A$); ELSE PRINT #2, A$; PRINT A$; END IF RETURN PrintCR: PRINT #2, " " PRINT " " RETURN PrintNoCR: PRINT #2, " "; PRINT " "; RETURN ProError: Z$ = "Error in Weather operation... no forecast available." PRINT Z$ GOTO Endit BadParms: PRINT Divider$ PRINT Program$; " - "; Version$; " "; Desc$ PRINT Divider$ PRINT "Invalid number of parameters!" PRINT Divider$ PRINT "" PRINT Program$; " requires the following command line parameters;" PRINT " 1 - The input capture file" PRINT " 2 - The output file" PRINT " Options: " PRINT " /L - Attempt to make long lines for better speech" PRINT " /E - Include EXTENDED forecast data" PRINT " /C - Include Current Condition data on top" PRINT " /F - Peform filtering option" PRINT " /U - Force UPPER CASE on all data" PRINT "" PRINT "Example command line;" PRINT " "; Program$; " 4CAST.TXT 4CAST.SAY /L /E /C /F /U" PRINT " " PRINT Divider$ GOTO Endit 'ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ 'Comline - Get command line parameters 'ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ SUB Comline (NumArgs, Args$(), MaxArgs, Sub$) STATIC CONST TRUE = -1, FALSE = 0 NumArgs = 0: In = FALSE ' Get the command line using the COMMAND$ function. Cl$ = UCASE$(Sub$) L = LEN(Cl$) ' Go through the command line a character at a time. FOR I = 1 TO L C$ = MID$(Cl$, I, 1) 'Test for character being a blank or a tab. IF (C$ <> " " AND C$ <> CHR$(9)) THEN ' Neither blank nor tab. ' Test to see if you're already ' inside an argument. IF NOT In THEN ' You've found the start of a new argument. ' Test for too many arguments. IF NumArgs = MaxArgs THEN EXIT FOR NumArgs = NumArgs + 1 In = TRUE END IF ' Add the character to the current argument. Args$(NumArgs) = Args$(NumArgs) + C$ ELSE ' Found a blank or a tab. ' Set "Not in an argument" flag to FALSE. In = FALSE END IF NEXT I END SUB