Example 4

Top  Previous  Next

Example 3

 

In this example, we've configured the filter script for a dispatching agency that needs all fire, rescue and accident calls dispatched but does not want non-emergency calls dispatched. To do this, the script reads in the entire input file and looks for certain keywords like FIRE,DISPATCHED or RESCUE,DISPATCHED or ACCID,DISPATCHED.

 

If it finds any of those three strings, the script then reformats the data, removes unwanted information, and determines who the message should be sent to.

 

In this particular example, all fire and rescue calls need to be separated from each other so that the fire calls go to the fire department and the rescue calls go to the rescue department, but all accident calls should go to both fire and rescue departments.

 

Note: Lines prefaced with # are comment lines for description purposes. The filter ignore any lines that begin with #

 

 

This section of the filter configures the script to accept whatever file name is passed by the preproc.bat file, to delete the input file when it's finished and to output the reformatted data to the c:\PageGateData\ASCII\ folder with a file name mirroring the original file but with a .asc extension instead of the original file's extension.

 

<InputFile>

 <Name>

         Parameter

 </Name>

 <Delete>

         True

 </Delete>

</InputFile>

 

<Debug>

 False

</Debug>

 

<OutputFile>

 <Name>

         c:\PageGateData\ASCII\%InputFileNameBase%.asc

 </Name>

</OutputFile>

 

# The next three sections of the Filters tells the script to look for any lines that have

# the text ,FIRE,DISPATCHED| or ,RESCUE,DISPATCHED| or ACCID,DISPATCHED| in the input file

# and sets the temporary Flag variable to True if any are found

 

# look for lines with station FIRE,DISPATCHED identifier

<Filter>

 <Search>

         <Section>

                 All

         </Section>

         <Type>

                 Literal

         </Type>

         <Text>

                 ,FIRE,DISPATCHED|

         </Text>

 </Search>

 <Replace>

         <Section>

                 Flag

         </Section>

         <Scope>

                 Section

         </Scope>

         <Type>

                 Or

         </Type>

         <Text>

                 True

         </Text>

 </Replace>

</Filter>

 

# look for lines with station RESCUE,DISPATCHED identifier

<Filter>

 <Search>

         <Section>

                 All

         </Section>

         <Type>

                 Literal

         </Type>

         <Text>

                 ,RESCUE,DISPATCHED|

         </Text>

 </Search>

 <Replace>

         <Section>

                 Flag

         </Section>

         <Scope>

                 Section

         </Scope>

         <Type>

                 Or

         </Type>

         <Text>

                 True

         </Text>

 </Replace>

</Filter>

 

# look for lines with station ACCID,DISPATCHED identifier

<Filter>

 <Search>

         <Section>

                 All

         </Section>

         <Type>

                 Literal

         </Type>

         <Text>

                 ,ACCID,DISPATCHED|

         </Text>

 </Search>

 <Replace>

         <Section>

                 Flag

         </Section>

         <Scope>

                 Section

         </Scope>

         <Type>

                 Or

         </Type>

         <Text>

                 True

         </Text>

 </Replace>

</Filter>

 

# This section test the value of the Flag variable

# and aborts out of the script if it is not set to True

# Note that the values in the <Replace> section really

# don't matter because the script is aborting

 

# abort if FIRE/RESCUE/ACCID DISPATCHED not found

<Filter>

 <Search>

         <Section>

                 Flag

         </Section>

         <Type>

                 Literal

         </Type>

         <Text>

                 False

         </Text>

 </Search>

 <Replace>

         <Section>

                 Flag

         </Section>

         <Scope>

                 Section

         </Scope>

         <Type>

                 And

         </Type>

         <Text>

                 False

         </Text>

 </Replace>

 <Continue>

         False

 </Continue>

</Filter>

 

# Now that the filter has determined that there is relevant data

# in the message file, these filter statements will search for

# department names and store what is found in the Temp variable

 

# look for lines with station F-BAY identifier

<Filter>

 <Search>

         <Section>

                 All

         </Section>

         <Type>

                 Literal

         </Type>

         <Text>

                 /F-BAY

         </Text>

 </Search>

 <Replace>

         <Section>

                 Temp

         </Section>

         <Scope>

                 Section

         </Scope>

         <Type>

                 Literal

         </Type>

         <Text>

                 F-BAY

         </Text>

 </Replace>

</Filter>

 

# look for lines with station F-STU identifier

<Filter>

 <Search>

         <Section>

                 All

         </Section>

         <Type>

                 Literal

         </Type>

         <Text>

                 /F-STU

         </Text>

 </Search>

 <Replace>

         <Section>

                 Temp

         </Section>

         <Scope>

                 Section

         </Scope>

         <Type>

                 Literal

         </Type>

         <Text>

                 F-STU

         </Text>

 </Replace>

</Filter>

 

# This Filter section tells the script to abort if no

# acceptable station is found within the data

# (the Temp variable is still blank)

<Filter>

 <Search>

         <Section>

                 Temp

         </Section>

         <Type>

                 Literal

         </Type>

         <Text>

         

         </Text>

 </Search>

 <Replace>

         <Section>

                 Flag

         </Section>

         <Scope>

                 Section

         </Scope>

         <Type>

                 And

         </Type>

         <Text>

                 False

         </Text>

 </Replace>

 <Continue>

         False

 </Continue>

</Filter>

 

# This Filter section tells the script to grab a portion of the data read for modification:

# It grabs everything between the first character of the line and ,DISPATCHED| keyword

# and removes everything else

<Filter>

 <Search>

         <Section>

                 All

         </Section>

         <Type>

                 Literal

         </Type>

         <Text>

                 *,DISPATCHED|

         </Text>

 </Search>

 <Replace>

         <Section>

                 All

         </Section>

         <Scope>

                 Section

         </Scope>

         <Type>

                 Literal

         </Type>

         <Text>

                 %Match%

         </Text>

 </Replace>

</Filter>

 

# This Filter flag takes the data read by the previous statement and modifies it:

# It gets rid of extra stuff between date/time and address and replaces it with

# a carriage return and line feed

<Filter>

 <Search>

         <Section>

                 All

         </Section>

         <Type>

                 Literal

         </Type>

         <Text>

                 (Eastern Daylight Time)*/%Temp%,F,

         </Text>

 </Search>

 <Replace>

         <Section>

                 All

         </Section>

         <Scope>

                 Match

         </Scope>

         <Type>

                 Literal

         </Type>

         <Text>

                 \013\010

         </Text>

 </Replace>

</Filter>

 

# The next two filter sections separate the rescue calls from the fire calls

# so that they go to two different agencies/organizations/units.

<Filter>

 <Search>

         <Section>

                 All

         </Section>

         <Type>

                 Literal

         </Type>

         <Text>

                 FIRE

         </Text>

 </Search>

 <Replace>

         <Section>

                 Temp

         </Section>

         <Scope>

                 Section

         </Scope>

         <Type>

                 Literal

         </Type>

         <Text>

                 %Temp%-FIRE

         </Text>

 </Replace>

</Filter>

 

<Filter>

 <Search>

         <Section>

                 All

         </Section>

         <Type>

                 Literal

         </Type>

         <Text>

                 RESCUE

         </Text>

 </Search>

 <Replace>

         <Section>

                 Temp

         </Section>

         <Scope>

                 Section

         </Scope>

         <Type>

                 Literal

         </Type>

         <Text>

                 %Temp%-RESCUE

         </Text>

 </Replace>

</Filter>

 

# The next three Filter sections remove the text ,DISPATCHED| from the message

# and replaces it with more readable text

 

# get rid of DISPATCHED on RESCUE

<Filter>

 <Search>

         <Section>

                 All

         </Section>

         <Type>

                 Literal

         </Type>

         <Text>

                 ,RESCUE,DISPATCHED|

         </Text>

 </Search>

 <Replace>

         <Section>

                 All

         </Section>

         <Scope>

                 Match

         </Scope>

         <Type>

                 Literal

         </Type>

         <Text>

                 \013\010RESCUE

         </Text>

 </Replace>

</Filter>

 

# get rid of DISPATCHED on FIRE

<Filter>

 <Search>

         <Section>

                 All

         </Section>

         <Type>

                 Literal

         </Type>

         <Text>

                 ,FIRE,DISPATCHED|

         </Text>

 </Search>

 <Replace>

         <Section>

                 All

         </Section>

         <Scope>

                 Match

         </Scope>

         <Type>

                 Literal

         </Type>

         <Text>

                 \013\010FIRE

         </Text>

 </Replace>

</Filter>

 

# get rid of DISPATCHED on ACCID

<Filter>

 <Search>

         <Section>

                 All

         </Section>

         <Type>

                 Literal

         </Type>

         <Text>

                 ,ACCID,DISPATCHED|

         </Text>

 </Search>

 <Replace>

         <Section>

                 All

         </Section>

         <Scope>

                 Match

         </Scope>

         <Type>

                 Literal

         </Type>

         <Text>

                 \013\010ACCID

         </Text>

 </Replace>

</Filter>

 

# This Filter section tells the script to output the file in the standard

# PageGate GetASCII file format for direct processing:

 

# convert to standard .asc format

<Filter>

 <Search>

         <Section>

                 Flag

         </Section>

         <Type>

                 Literal

         </Type>

         <Text>

                 True

         </Text>

 </Search>

 <Replace>

         <Section>

                 All

         </Section>

         <Scope>

                 Section

         </Scope>

         <Type>

                 Literal

         </Type>

         <Text>

                 %Temp%\013\010CAD\013\010Dispatch %Temp%\013\010%All%

         </Text>

 </Replace>

</Filter>