home *** CD-ROM | disk | FTP | other *** search
/ Popular Mechanics - New Car Buyers Guide 1995 / Popular_Mechanics_New_Car_Buyers_Guide_1995_Books_That_Work_1994.iso / howto / ads / toyota / locator.dir / 00118_Script_118 < prev    next >
Text File  |  1994-09-14  |  3KB  |  89 lines

  1. on initializeFields
  2.   --put "" into field "zipHole"
  3.   put "Enter a five digit zip code and press Enter." into field "displayResults"
  4. end InitializeFields
  5.  
  6. on checkKey
  7.   set x = charToNum(the key)
  8.   if (x < 48 OR x > 57) AND x <> 8 then dontPassEvent
  9.   if length(field "zipHole") = 5 AND x <> 8 then dontPassEvent
  10.   if the key = RETURN then go to frame "sea"
  11. end checkKey
  12.  
  13. on searchAndReport
  14.   global index, zip, foist
  15.   set foist = 1
  16.   put EMPTY into field "displayResults" 
  17.   if length(field "zipHole") < 5 then
  18.     put "Please enter five digits and press Enter." into field "displayResults"
  19.     put empty into field "zipHole"
  20.   else
  21.     put "Let me look up zip code" && field "zipHole" & "." & RETURN ¼
  22.     & "Back in a flash!" into field "displayResults"
  23.     
  24.     
  25.     put field "zipHole" into zip
  26.     put (char 1 to 2 of field "zipHole") into xx
  27.     set flag = 0
  28.     
  29.     set index = 1
  30.     repeat while (line (index) of field xx <> empty)
  31.       if line (index) of field xx contains zip then
  32.         report (xx)
  33.         set flag = 1
  34.       end if  
  35.       set index = index + 5
  36.     end repeat  
  37.     
  38.     put string (value (xx) - 1) into xy
  39.     if value (xy) < 0 then put "00" into xy
  40.     if length (xy) < 2 then put "0" before xy
  41.     set index = 1
  42.     repeat while (line (index) of field xy <> empty)
  43.       if line (index) of field xy contains zip then
  44.         report (xy)
  45.         set flag = 1
  46.       end if  
  47.       set index = index + 5
  48.     end repeat  
  49.     
  50.     put string (value (xx) - 2) into xz
  51.     if value (xz) < 0 then put "00" into xz
  52.     if length (xz) < 2 then put "0" before xz
  53.     set index = 1
  54.     repeat while (line (index) of field xz <> empty)
  55.       if line (index) of field xz contains zip then
  56.         report (xz)
  57.         set flag = 1
  58.       end if  
  59.       set index = index + 5
  60.     end repeat  
  61.     
  62.     if flag = 0 then 
  63.   
  64.       put "To locate a dealer near you:" & RETURN & "Call 1-800-GO-TOYOTA!" into field "displayResults"
  65.    
  66.     end if
  67.     put EMPTY into field "zipHole"
  68.   end if
  69. end searchAndReport
  70.  
  71. on report zz
  72.   global index, zip, foist
  73.   if foist = 1 then put "The Toyota Dealer(s) nearest to zip code" && zip && "is(are):" & RETURN into field "displayResults"
  74.   put RETURN & line (index + 1) of field zz & RETURN & line (index + 2) of field zz & RETURN after field "displayResults"
  75.   put word 1 to 3 of line (index + 3) of field zz after field "displayResults"
  76.   set x = charToNum (char 1 of word 3 of line (index + 3) of field zz)
  77.   if (x < 48 OR x > 57) then put " " & word 4 of line (index + 3) of field zz after field "displayResults"
  78.   set x = charToNum (char 1 of word 4 of line (index + 3) of field zz)
  79.   if (x < 48 OR x > 57) then put " " & word 5 of line (index + 3) of field zz after field "displayResults"
  80.   set x = charToNum (char 1 of word 5 of line (index + 3) of field zz)
  81.   if (x < 48 OR x > 57) then put " " & word 6 of line (index + 3) of field zz after field "displayResults"
  82.   set x = charToNum (char 1 of word 6 of line (index + 3) of field zz)
  83.   if (x < 48 OR x > 57) then put " " & word 7 of line (index + 3) of field zz after field "displayResults"
  84.   
  85.   put RETURN & "(" & char 1 to 3 of line (index + 4) of field zz ¼
  86.     & ") " & char 4 to 6 of line (index + 4) of field zz ¼
  87.     & "-" & char 7 to 10 of line (index + 4) of field zz & return after field "displayResults"
  88.   set foist = 0
  89. end report