' This is the sample order taking program. It makes use of several other ' files including ORDER.INF which contains the items available, ORDERINF.TXT, ' the text introduction file, and several country specific files such as ' GERMANY.INF that are sent if the order goes to a specific country. ' ' The format for ORDER.INF is 2 lines for each product. BOTH lines ' must be there for each. The first line is the product name, and the ' second line is the product cost (no dollar signs, commas, or decimal ' points are accepted for the cost). ' ' The completed orders are placed in ORDER.NEW. type ItemInfo description as string*70 price as integer end type const MaxItems = 40 dim Items(MaxItems) as ItemInfo dim TotalItems as integer sub ReadItems open progpath+"order.inf" for input as #1 TotalItems = 0 do while not eof(1) TotalItems = TotalItems + 1 input #1, Items(TotalItems).description if Items(TotalItems).description = "" then TotalItems = TotalItems - 1 exit do end if input #1, Items(TotalItems).price loop close #1 catch err_fileopen end end sub const UsMail = 0 const FedExPriority = 1 const FedExStandard = 2 const FedExEconomy = 3 const FedExAKHI = 4 const FedExCanada = 5 const FedExOverseas = 6 dim ShippingCost(6) as integer ShippingCost(UsMail ) = 3 ShippingCost(FedExPriority) = 33 ShippingCost(FedExStandard) = 18 ShippingCost(FedExEconomy ) = 10 ShippingCost(FedExAKHI ) = 15 ShippingCost(FedExCanada ) = 15 ShippingCost(FedExOverseas) = 35 dim ShippingNames(6) as string ShippingNames(UsMail ) = "US Mail" ShippingNames(FedExPriority) = "Federal Express Priority next day 10am delivery" ShippingNames(FedExStandard) = "Federal Express Standard next day 3pm delivery" ShippingNames(FedExEconomy ) = "Federal Express Economy 1-2 day delivery" ShippingNames(FedExAKHI ) = "Federal Express for ALASKA and HAWAII" ShippingNames(FedExCanada ) = "Federal Express for CANADA" ShippingNames(FedExOverseas) = "Federal Express for OVERSEAS" const MasterCard = 1 const Visa16 = 2 const Visa13 = 3 const AmericanExpress = 4 const Discover = 5 dim CardTypeNames(5) as string CardTypeNames(MasterCard ) = "MasterCard" CardTypeNames(Visa16 ) = "Visa" CardTypeNames(Visa13 ) = "Visa" CardTypeNames(AmericanExpress) = "American Express" CardTypeNames(Discover ) = "Discover" type OrderInfo itemcount as integer items(MaxItems) as integer name as string*40 street as string*70 cityetc as string*70 state as string*2 zip as string*10 country as string*20 regnumber as string*7 shipping as integer cardtype as integer cardnumber as string*19 cardexpire as string*5 phone as string*20 end type dim order as OrderInfo sub QuitNoOrder dim s as string print if inputyesno("@0E@NO ORDER TAKEN. Do you wish to leave a comment? ") then pushcommand "Y" comment end if print "@0E@Thank you!" waitenter end end sub function JustDigits(byval cardnumber as string) as string dim numbers as string numbers = "" dim i as integer for i = 1 to len(cardnumber) if mid(cardnumber, i, 1) >= "0" and mid(cardnumber, i, 1) <= "9" then numbers = numbers + mid(cardnumber, i, 1) end if next JustDigits = numbers end function function ValidCardNumber(byval cardnumber as string) as boolean dim numbers as string numbers = JustDigits(cardnumber) dim sum as integer sum = 0 dim m as integer m = 2 dim i as integer for i = len(numbers)-1 to 1 step -1 dim d as integer d = val(mid(numbers, i, 1)) * m if d >= 10 then d = (d mod 10) + 1 end if sum = sum + d m = 3 - m next ValidCardNumber = (10 - (sum mod 10)) mod 10 = val(right(numbers, 1)) end function dim i as integer dim total as integer call ReadItems order.itemcount = 0 order.name = "" order.street = "" order.cityetc = "" order.state = "" order.zip = "" order.country = "" order.regnumber = "" order.shipping = UsMail order.cardtype = 0 order.cardnumber = "" order.cardexpire = "" order.phone = "" del temppath+"comment" displaytextfile "c:\wildcat\codesamp\orderinf.txt" waitenter if not inputyesno("@0E@Do you want to purchase a product with a CREDIT CARD? ") then QuitNoOrder print if not inputyesno("@0E@Do you have your credit card NAME, NUMBER, and EXPIRATION DATE handy? ") then QuitNoOrder print print "@0E@Is this an order for a NEW product or an UPDATE?" print print "@0E@[@0F@1@0E@] NEW product" print "@0E@[@0F@2@0E@] UPDATE of a product I already own." print if inputnumber("@0E@Your choice: ", 1, 2) = 1 then print print "@0E@What country will the product be shipped to?" print print "@0E@[@0F@1@0E@] USA" print "@0E@[@0F@2@0E@] CANADA" print "@0E@[@0F@3@0E@] Scandinavia (Norway, Sweden, Denmark, or Finland)" print "@0E@[@0F@4@0E@] France" print "@0E@[@0F@5@0E@] The Netherlands (Holland)" print "@0E@[@0F@6@0E@] United Kingdom (Great Britain)" print "@0E@[@0F@7@0E@] OTHER" print select case inputnumber("@0E@Your choice: ", 1, 8) case 1 order.country = "USA" case 2 order.country = "CANADA" case 3 displaytextfile "c:\wildcat\codesamp\scandi.inf" waitenter end case 4 displaytextfile "c:\wildcat\codesamp\france.inf" waitenter end case 5 displaytextfile "c:\wildcat\codesamp\nether.inf" waitenter end case 6 displaytextfile "c:\wildcat\codesamp\uk.inf" waitenter end end select end if do print print "@0E@What product do you want to order?" print for i = 1 to TotalItems print "@0E@[@0F@"; leftpad(str(i), 2); "@0E@] @0B@"; pad(Items(i).description, 65); "@0F@$"; Items(i).price next print "@0E@[@0F@"; TotalItems+1; "@0E@] -------------------------> @0F@NONE@0E@ <-------------------------" print i = inputnumber("@0E@Your choice: ", 1, TotalItems+1) if i > 0 and i <= TotalItems then print print "@0E@Product selected: " print "@0B@"; Items(i).description; " ($"; Items(i).price; ")" print if inputyesno("@0E@Is this correct? ") then order.itemcount = order.itemcount + 1 order.items(order.itemcount) = i else print print "@0E@No product selected." end if else print print "@0E@No product selected." end if print print "@0E@Do you wish to order another product?" print print "@0E@[@0F@1@0E@] Yes, display the product choices again." print "@0E@[@0F@2@0E@] No, nothing more, but CONTINUE with payment and shipping." print "@0E@[@0F@3@0E@] No, and CANCEL this order request now." print i = inputnumber("@0E@Your choice: ", 1, 3) if i = 3 then QuitNoOrder loop until i = 2 if order.itemcount = 0 then print print "@0E@No items selected." QuitNoOrder end if print do print "@0E@What STREET ADDRESS do you want your order shipped to?@0F@" input order.street loop until len(order.street) > 5 print if order.country = "USA" then do print "@0E@What CITY do you want it shipped to (state and zip come next)?@0F@" input order.cityetc loop until len(order.cityetc) > 3 do print "@0E@What STATE do you want it shipped to?@0F@" order.state = ucase(inputmask("", "XX")) loop until len(order.state) = 2 do print "@0E@What ZIP do you want it shipped to?@0F@" order.zip = inputmask("", "99999-9999") loop until order.zip <> "-" elseif order.country = "CANADA" then do print "@0E@What CITY, PROVINCE, and POSTAL CODE do you want it shipped to?@0F@" input order.cityetc loop until len(order.cityetc) > 8 else print "@0E@What CITY and REGION do you want it shipped to?@0F@" input order.cityetc end if if order.country = "" then print print "@0E@What COUNTRY do you want it shipped to?@0F@" input order.country end if print if order.country = "USA" then print "@0E@All U.S. orders are shipped via FEDERAL EXPRESS to ensure" elseif order.country = "CANADA" then print "@0E@All Canadian orders are shipped via FEDERAL EXPRESS to ensure" else print "@0E@All overseas orders are shipped via FEDERAL EXPRESS to ensure" end if print "@0E@the fastest delivery and best service for our customers." print "@0E@If you cannot receive via FedEx, please cancel this" print "@0E@electronic order and call our business office at 805-873-2500" print "for alternatives." print if order.state = "AK" or order.state = "HI" then print "@0E@[@0F@1@0E@] "; ShippingNames(FedExAKHI) print print "@0E@[@0F@2@0E@] Please CANCEL this order." print select case inputnumber("@0E@Your choice: ", 1, 2) case 1 order.shipping = FedExAKHI case 2 QuitNoOrder end select elseif order.country = "USA" then print "@0E@[@0F@1@0E@] "; ShippingNames(FedExEconomy) print "@0E@[@0F@2@0E@] "; ShippingNames(FedExStandard) print "@0E@[@0F@3@0E@] "; ShippingNames(FedExPriority) print print "@0E@[@0F@4@0E@] Please CANCEL this order." print select case inputnumber("@0E@Your choice: ", 1, 5) case 1 order.shipping = FedExEconomy case 2 order.shipping = FedExStandard case 3 order.shipping = FedExPriority case 4 QuitNoOrder end select elseif order.country = "CANADA" then print "@0E@[@0F@1@0E@] "; ShippingNames(FedExCanada) print print "@0E@[@0F@2@0E@] Please CANCEL this order." print select case inputnumber("@0E@Your choice: ", 1, 2) case 1 order.shipping = FedExCanada case 2 QuitNoOrder end select else print "@0E@[@0F@1@0E@] "; ShippingNames(FedExOverseas) print print "@0E@[@0F@2@0E@] Please CANCEL this order." print select case inputnumber("@0E@Your choice: ", 1, 2) case 1 order.shipping = FedExOverseas case 2 QuitNoOrder end select end if AnotherCard: print do print "@0E@What is your EXACT NAME as it appears on your credit card?@0F@" input order.name loop until len(order.name) > 4 do print print "@0E@What type of credit card are you using?" print print "@0E@[@0F@1@0E@] MasterCard (5XXX-XXXX-XXXX-XXXX)" print "@0E@[@0F@2@0E@] VISA 16 digit (4XXX-XXXX-XXXX-XXXX)" print "@0E@[@0F@3@0E@] VISA 13 digit (4XXX-XXX-XXX-XXX)" print "@0E@[@0F@4@0E@] American Express (XXXX-XXXXXX-XXXXX)" print "@0E@[@0F@5@0E@] Discover (XXXX-XXXX-XXXX-XXXX)" print print "@0E@[@0F@6@0E@] NONE OF THE ABOVE - CANCEL ORDER" print order.cardtype = inputnumber("@0E@Your choice: ", 1, 6) if order.cardtype = 6 then QuitNoOrder print dim ok as integer ok = false select case order.cardtype case MasterCard print "@0E@Enter your MasterCard number:@0F@" order.cardnumber = inputmask("", "9999-9999-9999-9999") ok = left(order.cardnumber, 1) = "5" and len(trim(order.cardnumber)) = 19 case Visa16 print "@0E@Enter your Visa number:@0F@" order.cardnumber = inputmask("", "9999-9999-9999-9999") ok = left(order.cardnumber, 1) = "4" and len(trim(order.cardnumber)) = 19 case Visa13 print "@0E@Enter your Visa number:@0F@" order.cardnumber = inputmask("", "9999-999-999-999") ok = left(order.cardnumber, 1) = "4" and len(trim(order.cardnumber)) = 16 case AmericanExpress print "@0E@Enter your American Express number:@0F@" order.cardnumber = inputmask("", "9999-999999-99999") ok = len(trim(order.cardnumber)) = 17 case Discover print "@0E@Enter your Discover number:@0F@" order.cardnumber = inputmask("", "9999-9999-9999-9999") ok = len(trim(order.cardnumber)) = 19 end select ok = ok and ValidCardNumber(order.cardnumber) if not ok then print print "@0C@Sorry, you did not enter your credit card information correctly." print if not inputyesno("@0E@Do you want to try entering the card number again? ") then print if inputyesno("@0E@Do you want to try again with another credit card? ") then goto AnotherCard else QuitNoOrder end if end if end if loop until ok do print print "@0E@Enter the expiration date on your credit card (mm/yy):@0F@" order.cardexpire = inputmask("", "99/99") dim cardmonth as integer, cardyear as integer cardmonth = val(mid(order.cardexpire, 1, 2)) cardyear = val(mid(order.cardexpire, 4, 2)) dim nowmonth as integer, nowyear as integer dim nowdate as date currentdate nowdate nowmonth = val(formatdate(nowdate, "mm")) nowyear = val(formatdate(nowdate, "yy")) if cardmonth < 1 or cardmonth > 12 then print print "@0C@You have entered a date that is not correct." print if not inputyesno("@0E@Do you want to try entering the date again? ") then print if inputyesno("@0E@Do you want to try again with another credit card? ") then goto AnotherCard else QuitNoOrder end if end if elseif cardyear < nowyear or (cardyear = nowyear and cardmonth < nowmonth) then print print "@0C@Sorry, that credit card has expired." print if not inputyesno("@0E@Do you want to try entering the date again? ") then print if inputyesno("@0E@Do you want to try again with another credit card? ") then goto AnotherCard else QuitNoOrder end if end if else exit do end if loop print print "@0E@Please enter a DAYTIME VOICE phone number in the event" print "@0E@we need to contact you (also required for Federal Express):@0F@" input order.phone cls print "@0E@Order summary:" print print "@0E@Ship to: | Name: @0F@"; order.name print "@0E@ | Street: @0F@"; order.street print "@0E@ | City: @0F@"; order.cityetc if order.state <> "" then print "@0E@ | State: @0F@"; order.state if order.zip <> "" then print "@0E@ | Zip: @0F@"; order.zip print "@0E@ | Country: @0F@"; order.country print "@0E@ | Phone: @0F@"; order.phone print print "@0E@ Credit card type: @0F@"; CardTypeNames(order.cardtype) print "@0E@Credit card number: @0F@"; order.cardnumber print "@0E@ Expiration date: @0F@"; order.cardexpire print print "@0E@Items ordered: @0F@" total = 0 for i = 1 to order.itemcount print " @0F@"; pad(Items(order.items(i)).description, 65); "@0B@"; leftpad("$"+str(Items(order.items(i)).price), 4); " " total = total + Items(order.items(i)).price next print "@0E@ ---------------------------------------------------------------------" print "@0F@ "; pad(ShippingNames(order.shipping), 65); "@0B@"; leftpad("$"+str(ShippingCost(order.shipping)), 4) total = total + ShippingCost(order.shipping) if order.state = "CA" then print "@0B@ CALIFORNIA ORDERS WILL HAVE SALES TAX ADDED TO YOUR TOTAL" end if print "@0E@ =====================================================================" print "@0F@ Total @0B@"; leftpad("$"+str(total), 4) print if not inputyesno("@0E@Is the above information correct? ") then QuitNoOrder print if inputyesno("@0E@Thank you for your order! Do you wish to leave a comment? ") then editfile temppath+"comment", 10, "Online order comment" end if print "@0E@Thank you!" open "order.new" for append as #1 print #1, "Online order from: "; user.name " on node "; str(node) dim now as datetime currentdatetime now print #1, " Date/time: "; formatdate(now.d, "mm/dd/yy"); " "; formattime(now.t, "HH:mm") print #1, print #1, "Ship to: | Name: "; order.name print #1, " | Street: "; order.street print #1, " | City: "; order.cityetc if order.state <> "" then print #1, " | State: "; order.state if order.zip <> "" then print #1, " | Zip: "; order.zip print #1, " | Country: "; order.country print #1, " | Phone: "; order.phone print #1, print #1, " Credit card type: "; CardTypeNames(order.cardtype) print #1, "Credit card number: "; order.cardnumber print #1, " Expiration date: "; order.cardexpire print #1, print #1, "Items ordered: " total = 0 for i = 1 to order.itemcount print #1, " "; pad(Items(order.items(i)).description, 65); leftpad("$"+str(Items(order.items(i)).price), 4); " " total = total + Items(order.items(i)).price next print #1, " ---------------------------------------------------------------------" print #1, " "; pad(ShippingNames(order.shipping), 65); leftpad("$"+str(ShippingCost(order.shipping)), 4) total = total + ShippingCost(order.shipping) if order.state = "CA" then print #1, " CALIFORNIA ORDERS WILL HAVE SALES TAX ADDED TO THE TOTAL" end if print #1, " =====================================================================" print #1, " Total "; leftpad("$"+str(total), 4) if order.regnumber <> "" then print #1, print #1, print #1, "Registration number: "; order.regnumber end if if exists(temppath+"comment") then print #1, print #1, print #1, "Comments:" open temppath+"comment" for input as #2 do while not eof(2) dim s as string input #2, s print #1, s loop close #2 end if print #1, print #1, print #1, string(79, "Í") close #1 waitenter